Splint fiddles.

CVS patchset: 6736
CVS date: 2003/04/09 21:46:31
This commit is contained in:
jbj 2003-04-09 21:46:31 +00:00
parent 783219a832
commit 552d691608
11 changed files with 195 additions and 173 deletions

View File

@ -816,12 +816,11 @@ static void freeBadDeps(void)
*/ */
/*@-boundsread@*/ /*@-boundsread@*/
static int ignoreDep(const rpmte p, const rpmte q) static int ignoreDep(const rpmte p, const rpmte q)
/*@globals badDeps, badDepsInitialized @*/ /*@globals badDeps, badDepsInitialized, rpmGlobalMacroContext @*/
/*@modifies badDeps, badDepsInitialized @*/ /*@modifies badDeps, badDepsInitialized, rpmGlobalMacroContext @*/
{ {
struct badDeps_s * bdp; struct badDeps_s * bdp;
/*@-globs -mods@*/
if (!badDepsInitialized) { if (!badDepsInitialized) {
char * s = rpmExpand("%{?_dependency_whiteout}", NULL); char * s = rpmExpand("%{?_dependency_whiteout}", NULL);
const char ** av = NULL; const char ** av = NULL;
@ -856,7 +855,6 @@ static int ignoreDep(const rpmte p, const rpmte q)
s = _free(s); s = _free(s);
badDepsInitialized++; badDepsInitialized++;
} }
/*@=globs =mods@*/
/*@-compdef@*/ /*@-compdef@*/
if (badDeps != NULL) if (badDeps != NULL)
@ -1002,8 +1000,9 @@ static inline int addRelation(rpmts ts,
/*@dependent@*/ rpmte p, /*@dependent@*/ rpmte p,
unsigned char * selected, unsigned char * selected,
rpmds requires) rpmds requires)
/*@globals fileSystem, internalState @*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, p, *selected, fileSystem, internalState @*/ /*@modifies ts, p, *selected, rpmGlobalMacroContext,
fileSystem, internalState @*/
{ {
rpmtsi qi; rpmte q; rpmtsi qi; rpmte q;
tsortInfo tsi; tsortInfo tsi;
@ -1071,10 +1070,8 @@ static inline int addRelation(rpmts ts,
tsi->tsi_reqx = rpmdsIx(requires); tsi->tsi_reqx = rpmdsIx(requires);
tsi->tsi_next = rpmteTSI(q)->tsi_next; tsi->tsi_next = rpmteTSI(q)->tsi_next;
/*@-mods@*/
rpmteTSI(q)->tsi_next = tsi; rpmteTSI(q)->tsi_next = tsi;
rpmteTSI(q)->tsi_qcnt++; /* bump q successor count */ rpmteTSI(q)->tsi_qcnt++; /* bump q successor count */
/*@=mods@*/
return 0; return 0;
} }
/*@=mustmod@*/ /*@=mustmod@*/

View File

@ -389,8 +389,8 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data, static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data,
/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding, /*@unused@*/ char * formatPrefix, /*@unused@*/ int padding,
/*@unused@*/ int element) /*@unused@*/ int element)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/ /*@modifies fileSystem, internalState @*/
{ {
char * val, * t; char * val, * t;
@ -661,7 +661,6 @@ static int fssizesTag(Header h, /*@out@*/ rpmTagType * type,
* @retval *freeData data-was-malloc'ed indicator * @retval *freeData data-was-malloc'ed indicator
* @return 0 on success * @return 0 on success
*/ */
/*@-bounds@*/ /* LCL: segfault */
static int triggercondsTag(Header h, /*@out@*/ rpmTagType * type, static int triggercondsTag(Header h, /*@out@*/ rpmTagType * type,
/*@out@*/ const void ** data, /*@out@*/ int_32 * count, /*@out@*/ const void ** data, /*@out@*/ int_32 * count,
/*@out@*/ int * freeData) /*@out@*/ int * freeData)
@ -696,6 +695,7 @@ static int triggercondsTag(Header h, /*@out@*/ rpmTagType * type,
*data = conds = xmalloc(sizeof(*conds) * numScripts); *data = conds = xmalloc(sizeof(*conds) * numScripts);
*count = numScripts; *count = numScripts;
*type = RPM_STRING_ARRAY_TYPE; *type = RPM_STRING_ARRAY_TYPE;
/*@-bounds@*/
for (i = 0; i < numScripts; i++) { for (i = 0; i < numScripts; i++) {
chptr = xstrdup(""); chptr = xstrdup("");
@ -721,13 +721,13 @@ static int triggercondsTag(Header h, /*@out@*/ rpmTagType * type,
conds[i] = chptr; conds[i] = chptr;
} }
/*@=bounds@*/
names = hfd(names, tnt); names = hfd(names, tnt);
versions = hfd(versions, tvt); versions = hfd(versions, tvt);
return 0; return 0;
} }
/*@=bounds@*/
/** /**
* Retrieve trigger type info. * Retrieve trigger type info.
@ -767,6 +767,7 @@ static int triggertypeTag(Header h, /*@out@*/ rpmTagType * type,
*data = conds = xmalloc(sizeof(*conds) * numScripts); *data = conds = xmalloc(sizeof(*conds) * numScripts);
*count = numScripts; *count = numScripts;
*type = RPM_STRING_ARRAY_TYPE; *type = RPM_STRING_ARRAY_TYPE;
/*@-bounds@*/
for (i = 0; i < numScripts; i++) { for (i = 0; i < numScripts; i++) {
for (j = 0; j < numNames; j++) { for (j = 0; j < numNames; j++) {
if (indices[j] != i) if (indices[j] != i)
@ -785,6 +786,7 @@ static int triggertypeTag(Header h, /*@out@*/ rpmTagType * type,
/*@innerbreak@*/ break; /*@innerbreak@*/ break;
} }
} }
/*@=bounds@*/
return 0; return 0;
} }

View File

@ -134,8 +134,8 @@ exit:
* @return 0 on success * @return 0 on success
*/ */
static int getSignid(Header sig, int sigtag, unsigned char * signid) static int getSignid(Header sig, int sigtag, unsigned char * signid)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies *signid, fileSystem @*/ /*@modifies *signid, fileSystem, internalState @*/
{ {
void * pkt = NULL; void * pkt = NULL;
int_32 pkttyp = 0; int_32 pkttyp = 0;

View File

@ -264,8 +264,8 @@ int rpmtsCheck(rpmts ts)
* @return no. of (added) packages that could not be ordered * @return no. of (added) packages that could not be ordered
*/ */
int rpmtsOrder(rpmts ts) int rpmtsOrder(rpmts ts)
/*@globals fileSystem, internalState@*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, fileSystem, internalState @*/; /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmts /** \ingroup rpmts
* Process all package elements in a transaction set. * Process all package elements in a transaction set.
@ -276,10 +276,8 @@ int rpmtsOrder(rpmts ts)
* @return 0 on success, -1 on error, >0 with newProbs set * @return 0 on success, -1 on error, >0 with newProbs set
*/ */
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
/*@globals rpmGlobalMacroContext, /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
fileSystem, internalState@*/ /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
/*@modifies ts, rpmGlobalMacroContext,
fileSystem, internalState @*/;
/** \ingroup rpmts /** \ingroup rpmts
* Unreference a transaction instance. * Unreference a transaction instance.

View File

@ -54,28 +54,28 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
case PGPHASHALGO_MD5: case PGPHASHALGO_MD5:
ctx->digestlen = 16; ctx->digestlen = 16;
ctx->datalen = 64; ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /*@-sizeoftype@*/ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(md5Param); ctx->paramlen = sizeof(md5Param);
/*@=sizeoftype@*/ /*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) md5Reset; ctx->Reset = (void *) md5Reset;
ctx->Update = (void *) md5Update; ctx->Update = (void *) md5Update;
ctx->Digest = (void *) md5Digest; ctx->Digest = (void *) md5Digest;
/*@=type@*/ /*@=type@*/
break; break;
case PGPHASHALGO_SHA1: case PGPHASHALGO_SHA1:
ctx->digestlen = 20; ctx->digestlen = 20;
ctx->datalen = 64; ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /*@-sizeoftype@*/ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha1Param); ctx->paramlen = sizeof(sha1Param);
/*@=sizeoftype@*/ /*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) sha1Reset; ctx->Reset = (void *) sha1Reset;
ctx->Update = (void *) sha1Update; ctx->Update = (void *) sha1Update;
ctx->Digest = (void *) sha1Digest; ctx->Digest = (void *) sha1Digest;
/*@=type@*/ /*@=type@*/
break; break;
case PGPHASHALGO_RIPEMD160: case PGPHASHALGO_RIPEMD160:
case PGPHASHALGO_MD2: case PGPHASHALGO_MD2:
@ -111,6 +111,7 @@ DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->
/*@unchecked@*/ /*@unchecked@*/
static int _ie = 0x44332211; static int _ie = 0x44332211;
/*@-redef@*/ /*@-redef@*/
/*@unchecked@*/ /*@unchecked@*/
static union _dendian { static union _dendian {
@ -118,6 +119,7 @@ static union _dendian {
char b[4]; char b[4];
} *_endian = (union _dendian *)&_ie; } *_endian = (union _dendian *)&_ie;
/*@=redef@*/ /*@=redef@*/
#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') #define IS_BIG_ENDIAN() (_endian->b[0] == '\x44')
#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') #define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11')
@ -134,18 +136,18 @@ rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
digest = xmalloc(ctx->digestlen); digest = xmalloc(ctx->digestlen);
DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest)); DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest));
/*@-noeffectuncon@*/ /* FIX: check rc */ /*@-noeffectuncon@*/ /* FIX: check rc */
(void) (*ctx->Digest) (ctx->param, digest); (void) (*ctx->Digest) (ctx->param, digest);
/*@=noeffectuncon@*/ /*@=noeffectuncon@*/
/*@-sizeoftype@*/ /*@-sizeoftype@*/
if (IS_LITTLE_ENDIAN()) if (IS_LITTLE_ENDIAN())
for (i = 0; i < (ctx->digestlen/sizeof(uint32)); i++) for (i = 0; i < (ctx->digestlen/sizeof(uint32)); i++)
digest[i] = swapu32(digest[i]); digest[i] = swapu32(digest[i]);
/*@=sizeoftype@*/ /*@=sizeoftype@*/
/* Return final digest. */ /* Return final digest. */
/*@-branchstate@*/ /*@-branchstate@*/
if (!asAscii) { if (!asAscii) {
if (lenp) *lenp = ctx->digestlen; if (lenp) *lenp = ctx->digestlen;
if (datap) { if (datap) {
@ -166,7 +168,7 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp
*t = '\0'; *t = '\0';
} }
} }
/*@=branchstate@*/ /*@=branchstate@*/
if (digest) { if (digest) {
memset(digest, 0, ctx->digestlen); /* In case it's sensitive */ memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
free(digest); free(digest);

View File

@ -476,7 +476,6 @@ static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigty
for (i = 0; p < pend; i++, p += pgpMpiLen(p)) { for (i = 0; p < pend; i++, p += pgpMpiLen(p)) {
if (pubkey_algo == PGPPUBKEYALGO_RSA) { if (pubkey_algo == PGPPUBKEYALGO_RSA) {
if (i >= 1) break; if (i >= 1) break;
/*@-mods@*/
if (_dig && if (_dig &&
(sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT)) (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
{ {
@ -490,11 +489,9 @@ fprintf(stderr, "\t m**d = "), mp32println(stderr, _dig->c.size, _dig->c.data)
/*@switchbreak@*/ break; /*@switchbreak@*/ break;
} }
} }
/*@=mods@*/
pgpPrtStr("", pgpSigRSA[i]); pgpPrtStr("", pgpSigRSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_DSA) { } else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
if (i >= 2) break; if (i >= 2) break;
/*@-mods@*/
if (_dig && if (_dig &&
(sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT)) (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
{ {
@ -513,7 +510,6 @@ fprintf(stderr, "\t m**d = "), mp32println(stderr, _dig->c.size, _dig->c.data)
} }
if (xx) return xx; if (xx) return xx;
} }
/*@=mods@*/
pgpPrtStr("", pgpSigDSA[i]); pgpPrtStr("", pgpSigDSA[i]);
} else { } else {
if (_print) if (_print)
@ -527,6 +523,8 @@ fprintf(stderr, "\t m**d = "), mp32println(stderr, _dig->c.size, _dig->c.data)
} }
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
byte version = h[0]; byte version = h[0];
byte * p; byte * p;
@ -555,7 +553,6 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
pgpPrtHex(" signhash16", v->signhash16, sizeof(v->signhash16)); pgpPrtHex(" signhash16", v->signhash16, sizeof(v->signhash16));
pgpPrtNL(); pgpPrtNL();
/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) { if (_digp && _digp->pubkey_algo == 0) {
_digp->version = v->version; _digp->version = v->version;
_digp->hashlen = v->hashlen; _digp->hashlen = v->hashlen;
@ -567,7 +564,6 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
_digp->hash_algo = v->hash_algo; _digp->hash_algo = v->hash_algo;
memcpy(_digp->signhash16, v->signhash16, sizeof(_digp->signhash16)); memcpy(_digp->signhash16, v->signhash16, sizeof(_digp->signhash16));
} }
/*@=mods@*/
p = ((byte *)v) + sizeof(*v); p = ((byte *)v) + sizeof(*v);
rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen); rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen);
@ -590,12 +586,10 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
if (_debug && _print) if (_debug && _print)
fprintf(stderr, " hash[%u] -- %s\n", plen, pgpHexStr(p, plen)); fprintf(stderr, " hash[%u] -- %s\n", plen, pgpHexStr(p, plen));
/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) { if (_digp && _digp->pubkey_algo == 0) {
_digp->hashlen = sizeof(*v) + plen; _digp->hashlen = sizeof(*v) + plen;
_digp->hash = memcpy(xmalloc(_digp->hashlen), v, _digp->hashlen); _digp->hash = memcpy(xmalloc(_digp->hashlen), v, _digp->hashlen);
} }
/*@=mods@*/
(void) pgpPrtSubType(p, plen, v->sigtype); (void) pgpPrtSubType(p, plen, v->sigtype);
p += plen; p += plen;
@ -614,7 +608,6 @@ fprintf(stderr, " unhash[%u] -- %s\n", plen, pgpHexStr(p, plen));
pgpPrtHex(" signhash16", p, 2); pgpPrtHex(" signhash16", p, 2);
pgpPrtNL(); pgpPrtNL();
/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) { if (_digp && _digp->pubkey_algo == 0) {
_digp->version = v->version; _digp->version = v->version;
_digp->sigtype = v->sigtype; _digp->sigtype = v->sigtype;
@ -622,7 +615,6 @@ fprintf(stderr, " unhash[%u] -- %s\n", plen, pgpHexStr(p, plen));
_digp->hash_algo = v->hash_algo; _digp->hash_algo = v->hash_algo;
memcpy(_digp->signhash16, p, sizeof(_digp->signhash16)); memcpy(_digp->signhash16, p, sizeof(_digp->signhash16));
} }
/*@=mods@*/
p += 2; p += 2;
if (p > (h + hlen)) if (p > (h + hlen))
@ -686,15 +678,14 @@ static const char * pgpSecretELGAMAL[] = {
static const byte * pgpPrtPubkeyParams(byte pubkey_algo, static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen) /*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/ /*@modifies fileSystem, internalState @*/
{ {
int i; int i;
for (i = 0; p < &h[hlen]; i++, p += pgpMpiLen(p)) { for (i = 0; p < &h[hlen]; i++, p += pgpMpiLen(p)) {
if (pubkey_algo == PGPPUBKEYALGO_RSA) { if (pubkey_algo == PGPPUBKEYALGO_RSA) {
if (i >= 2) break; if (i >= 2) break;
/*@-mods@*/
if (_dig) { if (_dig) {
switch (i) { switch (i) {
case 0: /* n */ case 0: /* n */
@ -725,11 +716,9 @@ fprintf(stderr, "\t e = "), mp32println(stderr, _dig->rsa_pk.e.size, _dig->
/*@switchbreak@*/ break; /*@switchbreak@*/ break;
} }
} }
/*@=mods@*/
pgpPrtStr("", pgpPublicRSA[i]); pgpPrtStr("", pgpPublicRSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_DSA) { } else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
if (i >= 4) break; if (i >= 4) break;
/*@-mods@*/
if (_dig) { if (_dig) {
switch (i) { switch (i) {
case 0: /* p */ case 0: /* p */
@ -756,7 +745,6 @@ fprintf(stderr, "\t y = "), mp32println(stderr, _dig->y.size, _dig->y.data)
/*@switchbreak@*/ break; /*@switchbreak@*/ break;
} }
} }
/*@=mods@*/
pgpPrtStr("", pgpPublicDSA[i]); pgpPrtStr("", pgpPublicDSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_ELGAMAL_ENCRYPT) { } else if (pubkey_algo == PGPPUBKEYALGO_ELGAMAL_ENCRYPT) {
if (i >= 3) break; if (i >= 3) break;
@ -765,7 +753,6 @@ fprintf(stderr, "\t y = "), mp32println(stderr, _dig->y.size, _dig->y.data)
if (_print) if (_print)
fprintf(stderr, "%7d", i); fprintf(stderr, "%7d", i);
} }
/*@=mods@*/
pgpPrtStr("", pgpMpiStr(p)); pgpPrtStr("", pgpMpiStr(p));
pgpPrtNL(); pgpPrtNL();
} }
@ -848,6 +835,8 @@ static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
} }
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
byte version = *h; byte version = *h;
const byte * p; const byte * p;
@ -868,13 +857,11 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
fprintf(stderr, " valid %u days", plen); fprintf(stderr, " valid %u days", plen);
pgpPrtNL(); pgpPrtNL();
/*@-mods@*/
if (_digp && _digp->tag == tag) { if (_digp && _digp->tag == tag) {
_digp->version = v->version; _digp->version = v->version;
memcpy(_digp->time, v->time, sizeof(_digp->time)); memcpy(_digp->time, v->time, sizeof(_digp->time));
_digp->pubkey_algo = v->pubkey_algo; _digp->pubkey_algo = v->pubkey_algo;
} }
/*@=mods@*/
p = ((byte *)v) + sizeof(*v); p = ((byte *)v) + sizeof(*v);
p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen); p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
@ -889,13 +876,11 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t); fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
pgpPrtNL(); pgpPrtNL();
/*@-mods@*/
if (_digp && _digp->tag == tag) { if (_digp && _digp->tag == tag) {
_digp->version = v->version; _digp->version = v->version;
memcpy(_digp->time, v->time, sizeof(_digp->time)); memcpy(_digp->time, v->time, sizeof(_digp->time));
_digp->pubkey_algo = v->pubkey_algo; _digp->pubkey_algo = v->pubkey_algo;
} }
/*@=mods@*/
p = ((byte *)v) + sizeof(*v); p = ((byte *)v) + sizeof(*v);
p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen); p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
@ -912,18 +897,18 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
/*@-boundswrite@*/ /*@-boundswrite@*/
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
pgpPrtVal("", pgpTagTbl, tag); pgpPrtVal("", pgpTagTbl, tag);
if (_print) if (_print)
fprintf(stderr, " \"%.*s\"", (int)hlen, (const char *)h); fprintf(stderr, " \"%.*s\"", (int)hlen, (const char *)h);
pgpPrtNL(); pgpPrtNL();
/*@-mods@*/
if (_digp) { if (_digp) {
char * t; char * t;
_digp->userid = t = memcpy(xmalloc(hlen+1), h, hlen); _digp->userid = t = memcpy(xmalloc(hlen+1), h, hlen);
t[hlen] = '\0'; t[hlen] = '\0';
} }
/*@=mods@*/
return 0; return 0;
} }
/*@=boundswrite@*/ /*@=boundswrite@*/
@ -1062,9 +1047,9 @@ void pgpCleanDig(pgpDig dig)
mp32nfree(&dig->c); mp32nfree(&dig->c);
mp32nfree(&dig->rsahm); mp32nfree(&dig->rsahm);
} }
/*@-nullstate@*/ /*@-nullstate@*/
return; return;
/*@=nullstate@*/ /*@=nullstate@*/
} }
/*@=boundswrite@*/ /*@=boundswrite@*/
@ -1122,13 +1107,14 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
} }
int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing) int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
/*@globals _dig, _digp, _print @*/
/*@modifies _dig, _digp, *_digp, _print @*/
{ {
unsigned int val = *pkts; unsigned int val = *pkts;
const byte *p; const byte *p;
unsigned int pleft; unsigned int pleft;
int len; int len;
/*@-mods@*/
_print = printing; _print = printing;
_dig = dig; _dig = dig;
if (dig != NULL && (val & 0x80)) { if (dig != NULL && (val & 0x80)) {
@ -1137,7 +1123,6 @@ int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
_digp->tag = tag; _digp->tag = tag;
} else } else
_digp = NULL; _digp = NULL;
/*@=mods@*/
for (p = pkts, pleft = pktlen; p < (pkts + pktlen); p += len, pleft -= len) { for (p = pkts, pleft = pktlen; p < (pkts + pktlen); p += len, pleft -= len) {
len = pgpPrtPkt(p, pleft); len = pgpPrtPkt(p, pleft);

View File

@ -1159,8 +1159,8 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/; /*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP key packet. * Print/parse an OpenPGP key packet.
@ -1170,8 +1170,8 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/; /*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP userid packet. * Print/parse an OpenPGP userid packet.
@ -1181,8 +1181,8 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/; /*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP comment packet. * Print/parse an OpenPGP comment packet.
@ -1202,8 +1202,8 @@ int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
* @return -1 on error, otherwise this packet length * @return -1 on error, otherwise this packet length
*/ */
int pgpPrtPkt(const byte *pkt, unsigned int pleft) int pgpPrtPkt(const byte *pkt, unsigned int pleft)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/; /*@modifies fileSystem, internalState @*/;
/*@=exportlocal@*/ /*@=exportlocal@*/
/** /**
@ -1215,8 +1215,8 @@ int pgpPrtPkt(const byte *pkt, unsigned int pleft)
* @return -1 on error, 0 on success * @return -1 on error, 0 on success
*/ */
int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing) int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem @*/; /*@modifies dig, fileSystem, internalState @*/;
/** /**
* Parse armored OpenPGP packets from a file. * Parse armored OpenPGP packets from a file.

View File

@ -821,12 +821,13 @@ static /*@only@*/ char * ftpBuf = NULL;
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
/*@-boundswrite@*/ /*@-boundswrite@*/
/*@-mods@*/
static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall, static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
/*@out@*/ /*@null@*/ struct stat * st, /*@out@*/ /*@null@*/ struct stat * st,
/*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz) /*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz)
/*@globals fileSystem, internalState @*/ /*@globals ftpBufAlloced, ftpBuf,
/*@modifies *st, *rlbuf, fileSystem, internalState @*/ fileSystem, internalState @*/
/*@modifies *st, *rlbuf, ftpBufAlloced, ftpBuf,
fileSystem, internalState @*/
{ {
FD_t fd; FD_t fd;
const char * path; const char * path;
@ -1011,7 +1012,6 @@ exit:
(void) ufdClose(fd); (void) ufdClose(fd);
return rc; return rc;
} }
/*@=mods@*/
/*@=boundswrite@*/ /*@=boundswrite@*/
static const char * statstr(const struct stat * st, static const char * statstr(const struct stat * st,
@ -1035,34 +1035,30 @@ static const char * statstr(const struct stat * st,
static int ftp_st_ino = 0xdead0000; static int ftp_st_ino = 0xdead0000;
static int ftpStat(const char * path, /*@out@*/ struct stat *st) static int ftpStat(const char * path, /*@out@*/ struct stat *st)
/*@globals fileSystem, internalState @*/ /*@globals ftp_st_ino, fileSystem, internalState @*/
/*@modifies *st, fileSystem, internalState @*/ /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{ {
char buf[1024]; char buf[1024];
int rc; int rc;
rc = ftpNLST(path, DO_FTP_STAT, st, NULL, 0); rc = ftpNLST(path, DO_FTP_STAT, st, NULL, 0);
/* XXX fts(3) needs/uses st_ino, make something up for now. */ /* XXX fts(3) needs/uses st_ino, make something up for now. */
/*@-mods@*/
if (st->st_ino == 0) if (st->st_ino == 0)
st->st_ino = ftp_st_ino++; st->st_ino = ftp_st_ino++;
/*@=mods@*/
if (_ftp_debug) if (_ftp_debug)
fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf)); fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
return rc; return rc;
} }
static int ftpLstat(const char * path, /*@out@*/ struct stat *st) static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
/*@globals fileSystem, internalState @*/ /*@globals ftp_st_ino, fileSystem, internalState @*/
/*@modifies *st, fileSystem, internalState @*/ /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{ {
char buf[1024]; char buf[1024];
int rc; int rc;
rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0); rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0);
/* XXX fts(3) needs/uses st_ino, make something up for now. */ /* XXX fts(3) needs/uses st_ino, make something up for now. */
/*@-mods@*/
if (st->st_ino == 0) if (st->st_ino == 0)
st->st_ino = ftp_st_ino++; st->st_ino = ftp_st_ino++;
/*@=mods@*/
if (_ftp_debug) if (_ftp_debug)
fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf)); fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
return rc; return rc;
@ -1086,7 +1082,7 @@ struct __dirstream {
size_t size; /* Total valid data in the block. */ size_t size; /* Total valid data in the block. */
size_t offset; /* Current offset into the block. */ size_t offset; /* Current offset into the block. */
off_t filepos; /* Position of next entry to read. */ off_t filepos; /* Position of next entry to read. */
#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__) #if defined(HAVE_PTHREAD_H)
pthread_mutex_t lock; /* Mutex lock for this structure. */ pthread_mutex_t lock; /* Mutex lock for this structure. */
#endif #endif
}; };
@ -1111,7 +1107,6 @@ static int ftpmagicdir = 0x8440291;
#define ISFTPMAGIC(_dir) (!memcmp((_dir), &ftpmagicdir, sizeof(ftpmagicdir))) #define ISFTPMAGIC(_dir) (!memcmp((_dir), &ftpmagicdir, sizeof(ftpmagicdir)))
/*@-boundswrite@*/ /*@-boundswrite@*/
/*@-type@*/ /* FIX: abstract DIR */
/*@null@*/ /*@null@*/
static DIR * ftpOpendir(const char * path) static DIR * ftpOpendir(const char * path)
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
@ -1263,12 +1258,10 @@ static struct dirent * ftpReaddir(DIR * dir)
int ac; int ac;
int i; int i;
/*@+voidabstract@*/
if (mydir == NULL || !ISFTPMAGIC(mydir) || mydir->data == NULL) { if (mydir == NULL || !ISFTPMAGIC(mydir) || mydir->data == NULL) {
/* XXX TODO: EBADF errno. */ /* XXX TODO: EBADF errno. */
return NULL; return NULL;
} }
/*@=voidabstract@*/
dp = (struct dirent *) mydir->data; dp = (struct dirent *) mydir->data;
av = (const char **) (dp + 1); av = (const char **) (dp + 1);
@ -1284,6 +1277,7 @@ static struct dirent * ftpReaddir(DIR * dir)
mydir->offset = i; mydir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */ /* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */ dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */ dp->d_reclen = 0; /* W2DO? */
@ -1293,16 +1287,14 @@ static struct dirent * ftpReaddir(DIR * dir)
dp->d_type = dt[i]; dp->d_type = dt[i];
/*@=boundsread@*/ /*@=boundsread@*/
#endif #endif
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name)); strncpy(dp->d_name, av[i], sizeof(dp->d_name));
/*@+voidabstract@*/
if (_ftp_debug) if (_ftp_debug)
fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", (void *)mydir, dp, dp->d_name); fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", (void *)mydir, dp, dp->d_name);
/*@=voidabstract@*/
return dp; return dp;
} }
/*@=type@*/
static int ftpClosedir(/*@only@*/ DIR * dir) static int ftpClosedir(/*@only@*/ DIR * dir)
/*@globals fileSystem @*/ /*@globals fileSystem @*/
@ -1310,7 +1302,6 @@ static int ftpClosedir(/*@only@*/ DIR * dir)
{ {
FTPDIR mydir = (FTPDIR)dir; FTPDIR mydir = (FTPDIR)dir;
/*@+voidabstract@*/
if (_ftp_debug) if (_ftp_debug)
fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)mydir); fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)mydir);
if (mydir == NULL || !ISFTPMAGIC(mydir)) { if (mydir == NULL || !ISFTPMAGIC(mydir)) {
@ -1318,7 +1309,6 @@ fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)mydir);
return -1; return -1;
} }
free((void *)mydir); free((void *)mydir);
/*@=voidabstract@*/
mydir = NULL; mydir = NULL;
return 0; return 0;
} }
@ -1393,7 +1383,7 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
return -2; return -2;
/*@notreached@*/ break; /*@notreached@*/ break;
} }
/*@-compdef@*/ /*@-compdef@*/ /* FIX: *buf is undefined */
return readlink(path, buf, bufsiz); return readlink(path, buf, bufsiz);
/*@=compdef@*/ /*@=compdef@*/
} }
@ -1490,7 +1480,6 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
/*@=dependenttrans@*/ /*@=dependenttrans@*/
} }
/*@+voidabstract@*/
struct dirent * Readdir(DIR * dir) struct dirent * Readdir(DIR * dir)
{ {
if (_rpmio_debug) if (_rpmio_debug)
@ -1508,4 +1497,3 @@ fprintf(stderr, "*** Closedir(%p)\n", (void *)dir);
return ftpClosedir(dir); return ftpClosedir(dir);
return closedir(dir); return closedir(dir);
} }
/*@=voidabstract@*/

View File

@ -1,4 +1,3 @@
/*@-unrecog@*/
/** \ingroup rpmio /** \ingroup rpmio
* \file rpmio/rpmsq.c * \file rpmio/rpmsq.c
*/ */
@ -6,12 +5,103 @@
#include "system.h" #include "system.h"
#if defined(__LCLINT__) #if defined(__LCLINT__)
struct qelem; #define _BITS_SIGTHREAD_H /* XXX avoid __sigset_t heartburn. */
/*@-exportheader@*/ /*@-exportheader@*/
/*@constant int SA_SIGINFO@*/
extern int sighold(int sig)
/*@globals errno, systemState @*/;
extern int sigignore(int sig)
/*@globals errno, systemState @*/;
extern int sigpause(int sig)
/*@globals errno, systemState @*/;
extern int sigrelse(int sig)
/*@globals errno, systemState @*/;
extern void (*sigset(int sig, void (*disp)(int)))(int)
/*@globals errno, systemState @*/;
struct qelem;
extern void insque(struct qelem * __elem, struct qelem * __prev) extern void insque(struct qelem * __elem, struct qelem * __prev)
/*@modifies __elem, prev @*/; /*@modifies __elem, __prev @*/;
extern void remque(struct qelem * __elem) extern void remque(struct qelem * __elem)
/*@modifies __elem @*/; /*@modifies __elem @*/;
extern pthread_t pthread_self(void)
/*@*/;
extern int pthread_equal(pthread_t t1, pthread_t t2)
/*@*/;
extern int pthread_create(/*@out@*/ pthread_t *restrict thread,
const pthread_attr_t *restrict attr,
void *(*start_routine)(void*), void *restrict arg)
/*@modifies *thread @*/;
extern int pthread_join(pthread_t thread, /*@out@*/ void **value_ptr)
/*@modifies *value_ptr @*/;
extern int pthread_setcancelstate(int state, /*@out@*/ int *oldstate)
/*@globals internalState @*/
/*@modifies *oldstate, internalState @*/;
extern int pthread_setcanceltype(int type, /*@out@*/ int *oldtype)
/*@globals internalState @*/
/*@modifies *oldtype, internalState @*/;
extern void pthread_testcancel(void)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern void pthread_cleanup_pop(int execute)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern void pthread_cleanup_push(void (*routine)(void*), void *arg)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern void _pthread_cleanup_pop(/*@out@*/ struct _pthread_cleanup_buffer *__buffer, int execute)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern void _pthread_cleanup_push(/*@out@*/ struct _pthread_cleanup_buffer *__buffer, void (*routine)(void*), /*@out@*/ void *arg)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
/*@modifies *attr @*/;
extern int pthread_mutexattr_init(/*@out@*/ pthread_mutexattr_t *attr)
/*@modifies *attr @*/;
int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr,
/*@out@*/ int *restrict type)
/*@modifies *type @*/;
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
/*@modifies *attr @*/;
extern int pthread_mutex_destroy(pthread_mutex_t *mutex)
/*@modifies *mutex @*/;
extern int pthread_mutex_init(/*@out@*/ pthread_mutex_t *restrict mutex,
const pthread_mutexattr_t *restrict attr)
/*@modifies *mutex @*/;
extern int pthread_mutex_lock(pthread_mutex_t *mutex)
/*@modifies *mutex @*/;
extern int pthread_mutex_trylock(pthread_mutex_t *mutex)
/*@modifies *mutex @*/;
extern int pthread_mutex_unlock(pthread_mutex_t *mutex)
/*@modifies *mutex @*/;
extern int pthread_cond_destroy(pthread_cond_t *cond)
/*@modifies *cond @*/;
extern int pthread_cond_init(/*@out@*/ pthread_cond_t *restrict cond,
const pthread_condattr_t *restrict attr)
/*@modifies *cond @*/;
extern int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime)
/*@modifies *cond, *mutex @*/;
extern int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex)
/*@modifies *cond, *mutex @*/;
extern int pthread_cond_broadcast(pthread_cond_t *cond)
/*@modifies *cond @*/;
extern int pthread_cond_signal(pthread_cond_t *cond)
/*@modifies *cond @*/;
/*@=exportheader@*/ /*@=exportheader@*/
#endif #endif
@ -20,31 +110,33 @@ extern void remque(struct qelem * __elem)
#include <sys/wait.h> #include <sys/wait.h>
#include <search.h> #include <search.h>
#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__) #if defined(HAVE_PTHREAD_H)
#include <pthread.h> #include <pthread.h>
/*@unchecked@*/ /*@unchecked@*/
/*@-type@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/*@=type@*/
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock); #define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
#define DO_UNLOCK() pthread_mutex_unlock(&rpmsigTbl_lock); #define DO_UNLOCK() pthread_mutex_unlock(&rpmsigTbl_lock);
#define INIT_LOCK() \ #define INIT_LOCK() \
{ pthread_mutexattr_t attr; \ { pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \ (void) pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \ (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
pthread_mutex_init (&rpmsigTbl_lock, &attr); \ (void) pthread_mutex_init (&rpmsigTbl_lock, &attr); \
pthread_mutexattr_destroy(&attr); \ (void) pthread_mutexattr_destroy(&attr); \
rpmsigTbl_sigchld->active = 0; \ rpmsigTbl_sigchld->active = 0; \
} }
#define ADD_REF(__tbl) (__tbl)->active++ #define ADD_REF(__tbl) (__tbl)->active++
#define SUB_REF(__tbl) --(__tbl)->active #define SUB_REF(__tbl) --(__tbl)->active
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) \ #define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) \
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr)); \ (void) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr));\
pthread_cleanup_push((__handler), (__arg)); pthread_cleanup_push((__handler), (__arg));
#define CLEANUP_RESET(__execute, __oldtype) \ #define CLEANUP_RESET(__execute, __oldtype) \
pthread_cleanup_pop(__execute); \ (void) pthread_cleanup_pop(__execute); \
pthread_setcanceltype ((__oldtype), &(__oldtype)); (void) pthread_setcanceltype ((__oldtype), &(__oldtype));
#define SAME_THREAD(_a, _b) pthread_equal(((pthread_t)_a), ((pthread_t)_b)) #define SAME_THREAD(_a, _b) pthread_equal(((pthread_t)_a), ((pthread_t)_b))
@ -82,18 +174,15 @@ static struct rpmsqElem rpmsqRock;
rpmsq rpmsqQueue = &rpmsqRock; rpmsq rpmsqQueue = &rpmsqRock;
/*@=compmempass@*/ /*@=compmempass@*/
/*@-mustmod@*/ int rpmsqInsert(void * elem, void * prev)
int rpmsqInsert(void * elem, /*@unused@*/ void * prev)
{ {
rpmsq sq = (rpmsq) elem; rpmsq sq = (rpmsq) elem;
int ret = -1; int ret = -1;
if (sq != NULL) { if (sq != NULL) {
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Insert(%p): %p\n", ME(), sq); fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
/*@=modfilesys@*/
#endif #endif
ret = sighold(SIGCHLD); ret = sighold(SIGCHLD);
if (ret == 0) { if (ret == 0) {
@ -105,20 +194,15 @@ fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/ /*@=bounds@*/
/*@-unqualifiedtrans@*/
sq->id = ME(); sq->id = ME();
/*@=unqualifiedtrans@*/
ret = pthread_mutex_init(&sq->mutex, NULL); ret = pthread_mutex_init(&sq->mutex, NULL);
ret = pthread_cond_init(&sq->cond, NULL); ret = pthread_cond_init(&sq->cond, NULL);
#if !defined(__LCLINT__) /* XXX FIXME */ insque(elem, (prev != NULL ? prev : rpmsqQueue));
insque(elem, (prev ? prev : rpmsqQueue));
#endif
ret = sigrelse(SIGCHLD); ret = sigrelse(SIGCHLD);
} }
} }
return ret; return ret;
} }
/*@=mustmod@*/
int rpmsqRemove(void * elem) int rpmsqRemove(void * elem)
{ {
@ -128,10 +212,8 @@ int rpmsqRemove(void * elem)
if (elem != NULL) { if (elem != NULL) {
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Remove(%p): %p\n", ME(), sq); fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
/*@=modfilesys@*/
#endif #endif
ret = sighold (SIGCHLD); ret = sighold (SIGCHLD);
if (ret == 0) { if (ret == 0) {
@ -183,11 +265,8 @@ static struct rpmsig_s {
}; };
/*@=fullinitblock@*/ /*@=fullinitblock@*/
/*@-incondefs@*/
void rpmsqAction(int signum, void rpmsqAction(int signum,
/*@unused@*/ void * info, /*@unused@*/ void * context) /*@unused@*/ void * info, /*@unused@*/ void * context)
/*@globals rpmsqQueue @*/
/*@modifies rpmsqQueue @*/
{ {
int save = errno; int save = errno;
rpmsig tbl; rpmsig tbl;
@ -218,9 +297,7 @@ void rpmsqAction(int signum,
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
sq->reaped = reaped; sq->reaped = reaped;
sq->status = status; sq->status = status;
#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__)
(void) pthread_cond_signal(&sq->cond); (void) pthread_cond_signal(&sq->cond);
#endif
/*@innerbreak@*/ break; /*@innerbreak@*/ break;
} }
} }
@ -232,7 +309,6 @@ void rpmsqAction(int signum,
} }
errno = save; errno = save;
} }
/*@=incondefs@*/
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
/*@globals rpmsigTbl @*/ /*@globals rpmsigTbl @*/
@ -243,11 +319,9 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
rpmsig tbl; rpmsig tbl;
int ret = -1; int ret = -1;
DO_LOCK (); (void) DO_LOCK ();
#if !defined(__LCLINT__)
if (rpmsqQueue->id == NULL) if (rpmsqQueue->id == NULL)
rpmsqQueue->id = ME(); rpmsqQueue->id = ME();
#endif
for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) { for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) {
if (tblsignum != tbl->signum) if (tblsignum != tbl->signum)
continue; continue;
@ -279,7 +353,7 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
ret = tbl->active; ret = tbl->active;
break; break;
} }
DO_UNLOCK (); (void) DO_UNLOCK ();
return ret; return ret;
} }
@ -291,10 +365,8 @@ pid_t rpmsqFork(rpmsq sq)
if (sq->reaper) { if (sq->reaper) {
xx = rpmsqInsert(sq, NULL); xx = rpmsqInsert(sq, NULL);
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Enable(%p): %p\n", ME(), sq); fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
/*@=modfilesys@*/
#endif #endif
xx = rpmsqEnable(SIGCHLD, NULL); xx = rpmsqEnable(SIGCHLD, NULL);
} }
@ -323,10 +395,8 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
/*@=bounds@*/ /*@=bounds@*/
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Child(%p): %p child %d\n", ME(), sq, getpid()); fprintf(stderr, " Child(%p): %p child %d\n", ME(), sq, getpid());
/*@=modfilesys@*/
#endif #endif
} else { /* Parent. */ } else { /* Parent. */
@ -334,10 +404,8 @@ fprintf(stderr, " Child(%p): %p child %d\n", ME(), sq, getpid());
sq->child = pid; sq->child = pid;
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child); fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child);
/*@=modfilesys@*/
#endif #endif
} }
@ -393,19 +461,15 @@ static int rpmsqWaitUnregister(rpmsq sq)
xx = pthread_mutex_unlock(&sq->mutex); xx = pthread_mutex_unlock(&sq->mutex);
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Wake(%p): %p child %d reaper %d ret %d\n", ME(), sq, sq->child, sq->reaper, ret); fprintf(stderr, " Wake(%p): %p child %d reaper %d ret %d\n", ME(), sq, sq->child, sq->reaper, ret);
/*@=modfilesys@*/
#endif #endif
xx = rpmsqRemove(sq); xx = rpmsqRemove(sq);
xx = rpmsqEnable(-SIGCHLD, NULL); xx = rpmsqEnable(-SIGCHLD, NULL);
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Disable(%p): %p\n", ME(), sq); fprintf(stderr, " Disable(%p): %p\n", ME(), sq);
/*@=modfilesys@*/
#endif #endif
return ret; return ret;
@ -415,10 +479,8 @@ pid_t rpmsqWait(rpmsq sq)
{ {
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Wait(%p): %p child %d reaper %d\n", ME(), sq, sq->child, sq->reaper); fprintf(stderr, " Wait(%p): %p child %d reaper %d\n", ME(), sq, sq->child, sq->reaper);
/*@=modfilesys@*/
#endif #endif
if (sq->reaper) { if (sq->reaper) {
@ -432,18 +494,14 @@ fprintf(stderr, " Wait(%p): %p child %d reaper %d\n", ME(), sq, sq->child,
sq->reaped = reaped; sq->reaped = reaped;
sq->status = status; sq->status = status;
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Waitpid(%p): %p child %d reaped %d\n", ME(), sq, sq->child, sq->reaped); fprintf(stderr, " Waitpid(%p): %p child %d reaped %d\n", ME(), sq, sq->child, sq->reaped);
/*@=modfilesys@*/
#endif #endif
} }
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
if (_rpmsq_debug) if (_rpmsq_debug)
fprintf(stderr, " Fini(%p): %p child %d status 0x%x\n", ME(), sq, sq->child, sq->status); fprintf(stderr, " Fini(%p): %p child %d status 0x%x\n", ME(), sq, sq->child, sq->status);
/*@=modfilesys@*/
#endif #endif
return sq->reaped; return sq->reaped;
@ -478,8 +536,8 @@ int rpmsqThreadEqual(void * thread)
*/ */
static void static void
sigchld_cancel (void *arg) sigchld_cancel (void *arg)
/*@globals fileSystem, internalState @*/ /*@globals rpmsigTbl, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/ /*@modifies rpmsigTbl, fileSystem, internalState @*/
{ {
pid_t child = *(pid_t *) arg; pid_t child = *(pid_t *) arg;
pid_t result; pid_t result;
@ -490,29 +548,30 @@ sigchld_cancel (void *arg)
result = waitpid(child, NULL, 0); result = waitpid(child, NULL, 0);
} while (result == (pid_t)-1 && errno == EINTR); } while (result == (pid_t)-1 && errno == EINTR);
DO_LOCK (); (void) DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0) { if (SUB_REF (rpmsigTbl_sigchld) == 0) {
(void) rpmsqEnable(-SIGQUIT, NULL); (void) rpmsqEnable(-SIGQUIT, NULL);
(void) rpmsqEnable(-SIGINT, NULL); (void) rpmsqEnable(-SIGINT, NULL);
} }
DO_UNLOCK (); (void) DO_UNLOCK ();
} }
/** /**
* Execute a command, returning its status. * Execute a command, returning its status.
*/ */
/*@-bounds@*/
int int
rpmsqExecve (const char ** argv) rpmsqExecve (const char ** argv)
/*@globals rpmsigTbl @*/
/*@modifies rpmsigTbl @*/
{ {
int oldtype; int oldtype;
int status = -1; int status = -1;
pid_t pid; pid_t pid = 0;
pid_t result; pid_t result;
sigset_t newMask, oldMask; sigset_t newMask, oldMask;
rpmsq sq = memset(alloca(sizeof(*sq)), 0, sizeof(*sq)); rpmsq sq = memset(alloca(sizeof(*sq)), 0, sizeof(*sq));
DO_LOCK (); (void) DO_LOCK ();
if (ADD_REF (rpmsigTbl_sigchld) == 0) { if (ADD_REF (rpmsigTbl_sigchld) == 0) {
if (rpmsqEnable(SIGINT, NULL) < 0) { if (rpmsqEnable(SIGINT, NULL) < 0) {
SUB_REF (rpmsigTbl_sigchld); SUB_REF (rpmsigTbl_sigchld);
@ -523,12 +582,12 @@ rpmsqExecve (const char ** argv)
goto out_restore_sigint; goto out_restore_sigint;
} }
} }
DO_UNLOCK (); (void) DO_UNLOCK ();
(void) sigemptyset (&newMask); (void) sigemptyset (&newMask);
(void) sigaddset (&newMask, SIGCHLD); (void) sigaddset (&newMask, SIGCHLD);
if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) { if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) {
DO_LOCK (); (void) DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0) if (SUB_REF (rpmsigTbl_sigchld) == 0)
goto out_restore_sigquit_and_sigint; goto out_restore_sigquit_and_sigint;
goto out; goto out;
@ -561,7 +620,7 @@ rpmsqExecve (const char ** argv)
CLEANUP_RESET(0, oldtype); CLEANUP_RESET(0, oldtype);
DO_LOCK (); (void) DO_LOCK ();
if ((SUB_REF (rpmsigTbl_sigchld) == 0 && if ((SUB_REF (rpmsigTbl_sigchld) == 0 &&
(rpmsqEnable(-SIGINT, NULL) < 0 || rpmsqEnable (-SIGQUIT, NULL) < 0)) (rpmsqEnable(-SIGINT, NULL) < 0 || rpmsqEnable (-SIGQUIT, NULL) < 0))
|| sigprocmask (SIG_SETMASK, &oldMask, NULL) != 0) || sigprocmask (SIG_SETMASK, &oldMask, NULL) != 0)
@ -575,8 +634,6 @@ out_restore_sigquit_and_sigint:
out_restore_sigint: out_restore_sigint:
(void) rpmsqEnable(-SIGINT, NULL); (void) rpmsqEnable(-SIGINT, NULL);
out: out:
DO_UNLOCK (); (void) DO_UNLOCK ();
return status; return status;
} }
/*@=bounds@*/
/*@=unrecog@*/

View File

@ -43,6 +43,7 @@ struct rpmsqElem {
rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */ rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */
int reaper; /*!< Register SIGCHLD handler? */ int reaper; /*!< Register SIGCHLD handler? */
int pipes[2]; /*!< Parent/child interlock. */ int pipes[2]; /*!< Parent/child interlock. */
/*@shared@*/
void * id; /*!< Blocking thread id (pthread_t). */ void * id; /*!< Blocking thread id (pthread_t). */
pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */ pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */
pthread_cond_t cond; pthread_cond_t cond;
@ -68,7 +69,8 @@ extern sigset_t rpmsqCaught;
*/ */
/*@-exportlocal@*/ /*@-exportlocal@*/
int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev) int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
/*@modifies elem @*/; /*@globals systemState @*/
/*@modifies elem, prev, systemState @*/;
/*@=exportlocal@*/ /*@=exportlocal@*/
/** /**
@ -90,8 +92,8 @@ int rpmsqRemove(/*@null@*/ void * elem)
*/ */
/*@-exportlocal@*/ /*@-exportlocal@*/
void rpmsqAction(int signum, void * info, void * context) void rpmsqAction(int signum, void * info, void * context)
/*@globals rpmsqCaught, errno, fileSystem @*/ /*@globals rpmsqCaught, rpmsqQueue, errno, fileSystem @*/
/*@modifies rpmsqCaught, errno, fileSystem @*/; /*@modifies rpmsqCaught, rpmsqQueue, errno, fileSystem @*/;
/*@=exportlocal@*/ /*@=exportlocal@*/
/** /**
@ -101,8 +103,8 @@ void rpmsqAction(int signum, void * info, void * context)
* @return no. of refs, -1 on error * @return no. of refs, -1 on error
*/ */
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
/*@globals rpmsqCaught, fileSystem, internalState @*/ /*@globals rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/
/*@modifies rpmsqCaught, fileSystem, internalState @*/; /*@modifies rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/;
/** /**
* Fork a child process. * Fork a child process.

View File

@ -79,10 +79,8 @@ static int rpmsw_initialized = 0;
rpmsw rpmswNow(rpmsw sw) rpmsw rpmswNow(rpmsw sw)
{ {
/*@-noeffect@*/
if (!rpmsw_initialized) if (!rpmsw_initialized)
(void) rpmswInit(); (void) rpmswInit();
/*@=noeffect@*/
if (sw == NULL) if (sw == NULL)
return NULL; return NULL;
switch (rpmsw_type) { switch (rpmsw_type) {
@ -144,7 +142,6 @@ rpmtime_t rpmswDiff(rpmsw end, rpmsw begin)
} }
#if defined(HP_TIMING_NOW) #if defined(HP_TIMING_NOW)
/*@-type@*/
static rpmtime_t rpmswCalibrate(void) static rpmtime_t rpmswCalibrate(void)
/*@globals internalState @*/ /*@globals internalState @*/
/*@modifies internalState @*/ /*@modifies internalState @*/
@ -161,9 +158,7 @@ static rpmtime_t rpmswCalibrate(void)
req.tv_sec = 0; req.tv_sec = 0;
req.tv_nsec = 20 * 1000 * 1000; req.tv_nsec = 20 * 1000 * 1000;
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
/*@-compdef@*/
rc = nanosleep(&req, &rem); rc = nanosleep(&req, &rem);
/*@=compdef@*/
if (rc == 0) if (rc == 0)
break; break;
if (rem.tv_sec == 0 && rem.tv_nsec == 0) if (rem.tv_sec == 0 && rem.tv_nsec == 0)
@ -176,7 +171,6 @@ static rpmtime_t rpmswCalibrate(void)
return ticks; return ticks;
} }
/*@=type@*/
#endif #endif
rpmtime_t rpmswInit(void) rpmtime_t rpmswInit(void)
@ -244,7 +238,6 @@ rpmtime_t rpmswInit(void)
return rpmsw_overhead; return rpmsw_overhead;
} }
/*@-mods@*/
int rpmswEnter(rpmop op, ssize_t rc) int rpmswEnter(rpmop op, ssize_t rc)
{ {
if (op == NULL) if (op == NULL)
@ -300,5 +293,3 @@ rpmtime_t rpmswSub(rpmop to, rpmop from)
} }
return usecs; return usecs;
} }
/*@=mods@*/