*/
/*@-boundsread@*/
static int ignoreDep(const rpmte p, const rpmte q)
- /*@globals badDeps, badDepsInitialized @*/
- /*@modifies badDeps, badDepsInitialized @*/
+ /*@globals badDeps, badDepsInitialized, rpmGlobalMacroContext @*/
+ /*@modifies badDeps, badDepsInitialized, rpmGlobalMacroContext @*/
{
struct badDeps_s * bdp;
-/*@-globs -mods@*/
if (!badDepsInitialized) {
char * s = rpmExpand("%{?_dependency_whiteout}", NULL);
const char ** av = NULL;
s = _free(s);
badDepsInitialized++;
}
-/*@=globs =mods@*/
/*@-compdef@*/
if (badDeps != NULL)
/*@dependent@*/ rpmte p,
unsigned char * selected,
rpmds requires)
- /*@globals fileSystem, internalState @*/
- /*@modifies ts, p, *selected, fileSystem, internalState @*/
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies ts, p, *selected, rpmGlobalMacroContext,
+ fileSystem, internalState @*/
{
rpmtsi qi; rpmte q;
tsortInfo tsi;
tsi->tsi_reqx = rpmdsIx(requires);
tsi->tsi_next = rpmteTSI(q)->tsi_next;
-/*@-mods@*/
rpmteTSI(q)->tsi_next = tsi;
rpmteTSI(q)->tsi_qcnt++; /* bump q successor count */
-/*@=mods@*/
return 0;
}
/*@=mustmod@*/
static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data,
/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding,
/*@unused@*/ int element)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/
{
char * val, * t;
* @retval *freeData data-was-malloc'ed indicator
* @return 0 on success
*/
-/*@-bounds@*/ /* LCL: segfault */
static int triggercondsTag(Header h, /*@out@*/ rpmTagType * type,
/*@out@*/ const void ** data, /*@out@*/ int_32 * count,
/*@out@*/ int * freeData)
*data = conds = xmalloc(sizeof(*conds) * numScripts);
*count = numScripts;
*type = RPM_STRING_ARRAY_TYPE;
+/*@-bounds@*/
for (i = 0; i < numScripts; i++) {
chptr = xstrdup("");
conds[i] = chptr;
}
+/*@=bounds@*/
names = hfd(names, tnt);
versions = hfd(versions, tvt);
return 0;
}
-/*@=bounds@*/
/**
* Retrieve trigger type info.
*data = conds = xmalloc(sizeof(*conds) * numScripts);
*count = numScripts;
*type = RPM_STRING_ARRAY_TYPE;
+/*@-bounds@*/
for (i = 0; i < numScripts; i++) {
for (j = 0; j < numNames; j++) {
if (indices[j] != i)
/*@innerbreak@*/ break;
}
}
+/*@=bounds@*/
return 0;
}
* @return 0 on success
*/
static int getSignid(Header sig, int sigtag, unsigned char * signid)
- /*@globals fileSystem @*/
- /*@modifies *signid, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies *signid, fileSystem, internalState @*/
{
void * pkt = NULL;
int_32 pkttyp = 0;
* @return no. of (added) packages that could not be ordered
*/
int rpmtsOrder(rpmts ts)
- /*@globals fileSystem, internalState@*/
- /*@modifies ts, fileSystem, internalState @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmts
* Process all package elements in a transaction set.
* @return 0 on success, -1 on error, >0 with newProbs set
*/
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
- /*@globals rpmGlobalMacroContext,
- fileSystem, internalState@*/
- /*@modifies ts, rpmGlobalMacroContext,
- fileSystem, internalState @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmts
* Unreference a transaction instance.
case PGPHASHALGO_MD5:
ctx->digestlen = 16;
ctx->datalen = 64;
- /*@-sizeoftype@*/ /* FIX: union, not void pointer */
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(md5Param);
- /*@=sizeoftype@*/
+/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen);
- /*@-type@*/ /* FIX: cast? */
+/*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) md5Reset;
ctx->Update = (void *) md5Update;
ctx->Digest = (void *) md5Digest;
- /*@=type@*/
+/*@=type@*/
break;
case PGPHASHALGO_SHA1:
ctx->digestlen = 20;
ctx->datalen = 64;
- /*@-sizeoftype@*/ /* FIX: union, not void pointer */
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha1Param);
- /*@=sizeoftype@*/
+/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen);
- /*@-type@*/ /* FIX: cast? */
+/*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) sha1Reset;
ctx->Update = (void *) sha1Update;
ctx->Digest = (void *) sha1Digest;
- /*@=type@*/
+/*@=type@*/
break;
case PGPHASHALGO_RIPEMD160:
case PGPHASHALGO_MD2:
/*@unchecked@*/
static int _ie = 0x44332211;
+
/*@-redef@*/
/*@unchecked@*/
static union _dendian {
char b[4];
} *_endian = (union _dendian *)&_ie;
/*@=redef@*/
+
#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44')
#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11')
digest = xmalloc(ctx->digestlen);
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);
- /*@=noeffectuncon@*/
+/*@=noeffectuncon@*/
- /*@-sizeoftype@*/
+/*@-sizeoftype@*/
if (IS_LITTLE_ENDIAN())
for (i = 0; i < (ctx->digestlen/sizeof(uint32)); i++)
digest[i] = swapu32(digest[i]);
- /*@=sizeoftype@*/
+/*@=sizeoftype@*/
/* Return final digest. */
- /*@-branchstate@*/
+/*@-branchstate@*/
if (!asAscii) {
if (lenp) *lenp = ctx->digestlen;
if (datap) {
*t = '\0';
}
}
- /*@=branchstate@*/
+/*@=branchstate@*/
if (digest) {
memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
free(digest);
for (i = 0; p < pend; i++, p += pgpMpiLen(p)) {
if (pubkey_algo == PGPPUBKEYALGO_RSA) {
if (i >= 1) break;
- /*@-mods@*/
if (_dig &&
(sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
{
/*@switchbreak@*/ break;
}
}
- /*@=mods@*/
pgpPrtStr("", pgpSigRSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
if (i >= 2) break;
- /*@-mods@*/
if (_dig &&
(sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
{
}
if (xx) return xx;
}
- /*@=mods@*/
pgpPrtStr("", pgpSigDSA[i]);
} else {
if (_print)
}
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
+ /*@globals _digp @*/
+ /*@modifies *_digp @*/
{
byte version = h[0];
byte * p;
pgpPrtHex(" signhash16", v->signhash16, sizeof(v->signhash16));
pgpPrtNL();
-/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) {
_digp->version = v->version;
_digp->hashlen = v->hashlen;
_digp->hash_algo = v->hash_algo;
memcpy(_digp->signhash16, v->signhash16, sizeof(_digp->signhash16));
}
-/*@=mods@*/
p = ((byte *)v) + sizeof(*v);
rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen);
if (_debug && _print)
fprintf(stderr, " hash[%u] -- %s\n", plen, pgpHexStr(p, plen));
-/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) {
_digp->hashlen = sizeof(*v) + plen;
_digp->hash = memcpy(xmalloc(_digp->hashlen), v, _digp->hashlen);
}
-/*@=mods@*/
(void) pgpPrtSubType(p, plen, v->sigtype);
p += plen;
pgpPrtHex(" signhash16", p, 2);
pgpPrtNL();
-/*@-mods@*/
if (_digp && _digp->pubkey_algo == 0) {
_digp->version = v->version;
_digp->sigtype = v->sigtype;
_digp->hash_algo = v->hash_algo;
memcpy(_digp->signhash16, p, sizeof(_digp->signhash16));
}
-/*@=mods@*/
p += 2;
if (p > (h + hlen))
static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/
{
int i;
for (i = 0; p < &h[hlen]; i++, p += pgpMpiLen(p)) {
if (pubkey_algo == PGPPUBKEYALGO_RSA) {
if (i >= 2) break;
- /*@-mods@*/
if (_dig) {
switch (i) {
case 0: /* n */
/*@switchbreak@*/ break;
}
}
- /*@=mods@*/
pgpPrtStr("", pgpPublicRSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
if (i >= 4) break;
- /*@-mods@*/
if (_dig) {
switch (i) {
case 0: /* p */
/*@switchbreak@*/ break;
}
}
- /*@=mods@*/
pgpPrtStr("", pgpPublicDSA[i]);
} else if (pubkey_algo == PGPPUBKEYALGO_ELGAMAL_ENCRYPT) {
if (i >= 3) break;
if (_print)
fprintf(stderr, "%7d", i);
}
- /*@=mods@*/
pgpPrtStr("", pgpMpiStr(p));
pgpPrtNL();
}
}
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
+ /*@globals _digp @*/
+ /*@modifies *_digp @*/
{
byte version = *h;
const byte * p;
fprintf(stderr, " valid %u days", plen);
pgpPrtNL();
-/*@-mods@*/
if (_digp && _digp->tag == tag) {
_digp->version = v->version;
memcpy(_digp->time, v->time, sizeof(_digp->time));
_digp->pubkey_algo = v->pubkey_algo;
}
-/*@=mods@*/
p = ((byte *)v) + sizeof(*v);
p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
pgpPrtNL();
-/*@-mods@*/
if (_digp && _digp->tag == tag) {
_digp->version = v->version;
memcpy(_digp->time, v->time, sizeof(_digp->time));
_digp->pubkey_algo = v->pubkey_algo;
}
-/*@=mods@*/
p = ((byte *)v) + sizeof(*v);
p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
/*@-boundswrite@*/
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
+ /*@globals _digp @*/
+ /*@modifies *_digp @*/
{
pgpPrtVal("", pgpTagTbl, tag);
if (_print)
fprintf(stderr, " \"%.*s\"", (int)hlen, (const char *)h);
pgpPrtNL();
-/*@-mods@*/
if (_digp) {
char * t;
_digp->userid = t = memcpy(xmalloc(hlen+1), h, hlen);
t[hlen] = '\0';
}
-/*@=mods@*/
return 0;
}
/*@=boundswrite@*/
mp32nfree(&dig->c);
mp32nfree(&dig->rsahm);
}
- /*@-nullstate@*/
+/*@-nullstate@*/
return;
- /*@=nullstate@*/
+/*@=nullstate@*/
}
/*@=boundswrite@*/
}
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;
const byte *p;
unsigned int pleft;
int len;
- /*@-mods@*/
_print = printing;
_dig = dig;
if (dig != NULL && (val & 0x80)) {
_digp->tag = tag;
} else
_digp = NULL;
- /*@=mods@*/
for (p = pkts, pleft = pktlen; p < (pkts + pktlen); p += len, pleft -= len) {
len = pgpPrtPkt(p, pleft);
* @return 0 on success
*/
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
/**
* Print/parse an OpenPGP key packet.
* @return 0 on success
*/
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
/**
* Print/parse an OpenPGP userid packet.
* @return 0 on success
*/
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
/**
* Print/parse an OpenPGP comment packet.
* @return -1 on error, otherwise this packet length
*/
int pgpPrtPkt(const byte *pkt, unsigned int pleft)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
/*@=exportlocal@*/
/**
* @return -1 on error, 0 on success
*/
int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies dig, fileSystem, internalState @*/;
/**
* Parse armored OpenPGP packets from a file.
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
/*@-boundswrite@*/
-/*@-mods@*/
static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
/*@out@*/ /*@null@*/ struct stat * st,
/*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz)
- /*@globals fileSystem, internalState @*/
- /*@modifies *st, *rlbuf, fileSystem, internalState @*/
+ /*@globals ftpBufAlloced, ftpBuf,
+ fileSystem, internalState @*/
+ /*@modifies *st, *rlbuf, ftpBufAlloced, ftpBuf,
+ fileSystem, internalState @*/
{
FD_t fd;
const char * path;
(void) ufdClose(fd);
return rc;
}
-/*@=mods@*/
/*@=boundswrite@*/
static const char * statstr(const struct stat * st,
static int ftp_st_ino = 0xdead0000;
static int ftpStat(const char * path, /*@out@*/ struct stat *st)
- /*@globals fileSystem, internalState @*/
- /*@modifies *st, fileSystem, internalState @*/
+ /*@globals ftp_st_ino, fileSystem, internalState @*/
+ /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{
char buf[1024];
int rc;
rc = ftpNLST(path, DO_FTP_STAT, st, NULL, 0);
/* XXX fts(3) needs/uses st_ino, make something up for now. */
- /*@-mods@*/
if (st->st_ino == 0)
st->st_ino = ftp_st_ino++;
- /*@=mods@*/
if (_ftp_debug)
fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
return rc;
}
static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
- /*@globals fileSystem, internalState @*/
- /*@modifies *st, fileSystem, internalState @*/
+ /*@globals ftp_st_ino, fileSystem, internalState @*/
+ /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{
char buf[1024];
int rc;
rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0);
/* XXX fts(3) needs/uses st_ino, make something up for now. */
- /*@-mods@*/
if (st->st_ino == 0)
st->st_ino = ftp_st_ino++;
- /*@=mods@*/
if (_ftp_debug)
fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
return rc;
size_t size; /* Total valid data in the block. */
size_t offset; /* Current offset into the block. */
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. */
#endif
};
#define ISFTPMAGIC(_dir) (!memcmp((_dir), &ftpmagicdir, sizeof(ftpmagicdir)))
/*@-boundswrite@*/
-/*@-type@*/ /* FIX: abstract DIR */
/*@null@*/
static DIR * ftpOpendir(const char * path)
/*@globals fileSystem, internalState @*/
int ac;
int i;
- /*@+voidabstract@*/
if (mydir == NULL || !ISFTPMAGIC(mydir) || mydir->data == NULL) {
/* XXX TODO: EBADF errno. */
return NULL;
}
- /*@=voidabstract@*/
dp = (struct dirent *) mydir->data;
av = (const char **) (dp + 1);
mydir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
+/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */
dp->d_type = dt[i];
/*@=boundsread@*/
#endif
+/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
-/*@+voidabstract@*/
if (_ftp_debug)
fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", (void *)mydir, dp, dp->d_name);
-/*@=voidabstract@*/
return dp;
}
-/*@=type@*/
static int ftpClosedir(/*@only@*/ DIR * dir)
/*@globals fileSystem @*/
{
FTPDIR mydir = (FTPDIR)dir;
- /*@+voidabstract@*/
if (_ftp_debug)
fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)mydir);
if (mydir == NULL || !ISFTPMAGIC(mydir)) {
return -1;
}
free((void *)mydir);
- /*@=voidabstract@*/
mydir = NULL;
return 0;
}
return -2;
/*@notreached@*/ break;
}
-/*@-compdef@*/
+/*@-compdef@*/ /* FIX: *buf is undefined */
return readlink(path, buf, bufsiz);
/*@=compdef@*/
}
/*@=dependenttrans@*/
}
-/*@+voidabstract@*/
struct dirent * Readdir(DIR * dir)
{
if (_rpmio_debug)
return ftpClosedir(dir);
return closedir(dir);
}
-/*@=voidabstract@*/
-/*@-unrecog@*/
/** \ingroup rpmio
* \file rpmio/rpmsq.c
*/
#include "system.h"
#if defined(__LCLINT__)
-struct qelem;
+#define _BITS_SIGTHREAD_H /* XXX avoid __sigset_t heartburn. */
+
/*@-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)
- /*@modifies __elem, prev @*/;
+ /*@modifies __elem, __prev @*/;
extern void remque(struct qelem * __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@*/
#endif
#include <sys/wait.h>
#include <search.h>
-#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__)
+#if defined(HAVE_PTHREAD_H)
#include <pthread.h>
/*@unchecked@*/
+/*@-type@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+/*@=type@*/
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
#define DO_UNLOCK() pthread_mutex_unlock(&rpmsigTbl_lock);
#define INIT_LOCK() \
- { pthread_mutexattr_t attr; \
- pthread_mutexattr_init(&attr); \
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
- pthread_mutex_init (&rpmsigTbl_lock, &attr); \
- pthread_mutexattr_destroy(&attr); \
+ { pthread_mutexattr_t attr; \
+ (void) pthread_mutexattr_init(&attr); \
+ (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
+ (void) pthread_mutex_init (&rpmsigTbl_lock, &attr); \
+ (void) pthread_mutexattr_destroy(&attr); \
rpmsigTbl_sigchld->active = 0; \
- }
+ }
#define ADD_REF(__tbl) (__tbl)->active++
#define SUB_REF(__tbl) --(__tbl)->active
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) \
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr)); \
+ (void) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr));\
pthread_cleanup_push((__handler), (__arg));
#define CLEANUP_RESET(__execute, __oldtype) \
- pthread_cleanup_pop(__execute); \
- pthread_setcanceltype ((__oldtype), &(__oldtype));
+ (void) pthread_cleanup_pop(__execute); \
+ (void) pthread_setcanceltype ((__oldtype), &(__oldtype));
#define SAME_THREAD(_a, _b) pthread_equal(((pthread_t)_a), ((pthread_t)_b))
rpmsq rpmsqQueue = &rpmsqRock;
/*@=compmempass@*/
-/*@-mustmod@*/
-int rpmsqInsert(void * elem, /*@unused@*/ void * prev)
+int rpmsqInsert(void * elem, void * prev)
{
rpmsq sq = (rpmsq) elem;
int ret = -1;
if (sq != NULL) {
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
-/*@=modfilesys@*/
#endif
ret = sighold(SIGCHLD);
if (ret == 0) {
sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
-/*@-unqualifiedtrans@*/
sq->id = ME();
-/*@=unqualifiedtrans@*/
ret = pthread_mutex_init(&sq->mutex, NULL);
ret = pthread_cond_init(&sq->cond, NULL);
-#if !defined(__LCLINT__) /* XXX FIXME */
- insque(elem, (prev ? prev : rpmsqQueue));
-#endif
+ insque(elem, (prev != NULL ? prev : rpmsqQueue));
ret = sigrelse(SIGCHLD);
}
}
return ret;
}
-/*@=mustmod@*/
int rpmsqRemove(void * elem)
{
if (elem != NULL) {
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
-/*@=modfilesys@*/
#endif
ret = sighold (SIGCHLD);
if (ret == 0) {
};
/*@=fullinitblock@*/
-/*@-incondefs@*/
void rpmsqAction(int signum,
/*@unused@*/ void * info, /*@unused@*/ void * context)
- /*@globals rpmsqQueue @*/
- /*@modifies rpmsqQueue @*/
{
int save = errno;
rpmsig tbl;
/*@innercontinue@*/ continue;
sq->reaped = reaped;
sq->status = status;
-#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__)
(void) pthread_cond_signal(&sq->cond);
-#endif
/*@innerbreak@*/ break;
}
}
}
errno = save;
}
-/*@=incondefs@*/
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
/*@globals rpmsigTbl @*/
rpmsig tbl;
int ret = -1;
- DO_LOCK ();
-#if !defined(__LCLINT__)
+ (void) DO_LOCK ();
if (rpmsqQueue->id == NULL)
rpmsqQueue->id = ME();
-#endif
for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) {
if (tblsignum != tbl->signum)
continue;
ret = tbl->active;
break;
}
- DO_UNLOCK ();
+ (void) DO_UNLOCK ();
return ret;
}
if (sq->reaper) {
xx = rpmsqInsert(sq, NULL);
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
-/*@=modfilesys@*/
#endif
xx = rpmsqEnable(SIGCHLD, NULL);
}
/*@=bounds@*/
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Child(%p): %p child %d\n", ME(), sq, getpid());
-/*@=modfilesys@*/
#endif
} else { /* Parent. */
sq->child = pid;
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child);
-/*@=modfilesys@*/
#endif
}
xx = pthread_mutex_unlock(&sq->mutex);
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Wake(%p): %p child %d reaper %d ret %d\n", ME(), sq, sq->child, sq->reaper, ret);
-/*@=modfilesys@*/
#endif
xx = rpmsqRemove(sq);
xx = rpmsqEnable(-SIGCHLD, NULL);
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Disable(%p): %p\n", ME(), sq);
-/*@=modfilesys@*/
#endif
return ret;
{
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Wait(%p): %p child %d reaper %d\n", ME(), sq, sq->child, sq->reaper);
-/*@=modfilesys@*/
#endif
if (sq->reaper) {
sq->reaped = reaped;
sq->status = status;
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Waitpid(%p): %p child %d reaped %d\n", ME(), sq, sq->child, sq->reaped);
-/*@=modfilesys@*/
#endif
}
#ifdef _RPMSQ_DEBUG
-/*@-modfilesys@*/
if (_rpmsq_debug)
fprintf(stderr, " Fini(%p): %p child %d status 0x%x\n", ME(), sq, sq->child, sq->status);
-/*@=modfilesys@*/
#endif
return sq->reaped;
*/
static void
sigchld_cancel (void *arg)
- /*@globals fileSystem, internalState @*/
- /*@modifies fileSystem, internalState @*/
+ /*@globals rpmsigTbl, fileSystem, internalState @*/
+ /*@modifies rpmsigTbl, fileSystem, internalState @*/
{
pid_t child = *(pid_t *) arg;
pid_t result;
result = waitpid(child, NULL, 0);
} while (result == (pid_t)-1 && errno == EINTR);
- DO_LOCK ();
+ (void) DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0) {
(void) rpmsqEnable(-SIGQUIT, NULL);
(void) rpmsqEnable(-SIGINT, NULL);
}
- DO_UNLOCK ();
+ (void) DO_UNLOCK ();
}
/**
* Execute a command, returning its status.
*/
-/*@-bounds@*/
int
rpmsqExecve (const char ** argv)
+ /*@globals rpmsigTbl @*/
+ /*@modifies rpmsigTbl @*/
{
int oldtype;
int status = -1;
- pid_t pid;
+ pid_t pid = 0;
pid_t result;
sigset_t newMask, oldMask;
rpmsq sq = memset(alloca(sizeof(*sq)), 0, sizeof(*sq));
- DO_LOCK ();
+ (void) DO_LOCK ();
if (ADD_REF (rpmsigTbl_sigchld) == 0) {
if (rpmsqEnable(SIGINT, NULL) < 0) {
SUB_REF (rpmsigTbl_sigchld);
goto out_restore_sigint;
}
}
- DO_UNLOCK ();
+ (void) DO_UNLOCK ();
(void) sigemptyset (&newMask);
(void) sigaddset (&newMask, SIGCHLD);
if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) {
- DO_LOCK ();
+ (void) DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0)
goto out_restore_sigquit_and_sigint;
goto out;
CLEANUP_RESET(0, oldtype);
- DO_LOCK ();
+ (void) DO_LOCK ();
if ((SUB_REF (rpmsigTbl_sigchld) == 0 &&
(rpmsqEnable(-SIGINT, NULL) < 0 || rpmsqEnable (-SIGQUIT, NULL) < 0))
|| sigprocmask (SIG_SETMASK, &oldMask, NULL) != 0)
out_restore_sigint:
(void) rpmsqEnable(-SIGINT, NULL);
out:
- DO_UNLOCK ();
+ (void) DO_UNLOCK ();
return status;
}
-/*@=bounds@*/
-/*@=unrecog@*/
rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */
int reaper; /*!< Register SIGCHLD handler? */
int pipes[2]; /*!< Parent/child interlock. */
+/*@shared@*/
void * id; /*!< Blocking thread id (pthread_t). */
pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */
pthread_cond_t cond;
*/
/*@-exportlocal@*/
int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
- /*@modifies elem @*/;
+ /*@globals systemState @*/
+ /*@modifies elem, prev, systemState @*/;
/*@=exportlocal@*/
/**
*/
/*@-exportlocal@*/
void rpmsqAction(int signum, void * info, void * context)
- /*@globals rpmsqCaught, errno, fileSystem @*/
- /*@modifies rpmsqCaught, errno, fileSystem @*/;
+ /*@globals rpmsqCaught, rpmsqQueue, errno, fileSystem @*/
+ /*@modifies rpmsqCaught, rpmsqQueue, errno, fileSystem @*/;
/*@=exportlocal@*/
/**
* @return no. of refs, -1 on error
*/
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
- /*@globals rpmsqCaught, fileSystem, internalState @*/
- /*@modifies rpmsqCaught, fileSystem, internalState @*/;
+ /*@globals rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/
+ /*@modifies rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/;
/**
* Fork a child process.
rpmsw rpmswNow(rpmsw sw)
{
-/*@-noeffect@*/
if (!rpmsw_initialized)
(void) rpmswInit();
-/*@=noeffect@*/
if (sw == NULL)
return NULL;
switch (rpmsw_type) {
}
#if defined(HP_TIMING_NOW)
-/*@-type@*/
static rpmtime_t rpmswCalibrate(void)
/*@globals internalState @*/
/*@modifies internalState @*/
req.tv_sec = 0;
req.tv_nsec = 20 * 1000 * 1000;
for (i = 0; i < 100; i++) {
-/*@-compdef@*/
rc = nanosleep(&req, &rem);
-/*@=compdef@*/
if (rc == 0)
break;
if (rem.tv_sec == 0 && rem.tv_nsec == 0)
return ticks;
}
-/*@=type@*/
#endif
rpmtime_t rpmswInit(void)
return rpmsw_overhead;
}
-/*@-mods@*/
int rpmswEnter(rpmop op, ssize_t rc)
{
if (op == NULL)
}
return usecs;
}
-
-/*@=mods@*/