extern int
nanosleep (const struct timespec *__requested_time,
/*@out@*/ /*@null@*/ struct timespec *__remaining)
- /*@modifies errno @*/;
+ /*@modifies *__remaining, errno @*/;
extern void
aio_init (const struct aioinit *__init)
typedef /*@abstract@*/ struct cpioSourceArchive_s {
unsigned int cpioArchiveSize;
FD_t cpioFdIn;
-/*@refcounted@*/
+/*@refcounted@*/ /*@relnull@*/
rpmfi cpioList;
/*@only@*/
struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */
/*@=type@*/
/*@=sizeoftype@*/
if (rc != Z_OK) {
- (void) fprintf(stderr,"%s: zlib: %s\n", __progname, z.msg);
+ fprintf(stderr,"%s: zlib: %s\n", __progname,
+ (z.msg != NULL ? z.msg : ""));
return 0;
}
rc = inflate(&z, Z_SYNC_FLUSH);
/*@=type@*/
if (rc != Z_OK && rc != Z_STREAM_END) {
- fprintf(stderr,"%s: zlib: %s\n", __progname, z.msg);
+ fprintf(stderr,"%s: zlib: %s\n", __progname,
+ (z.msg != NULL ? z.msg : ""));
return 0;
}
-redecl
-bufferoverflowhigh
+-nullpass
+
# --- +partial artifacts
-declundef
-exportheadervar
memset(data, 0, sizeof(*data));
data->data = datap;
data->size = datalen;
+/*@-nullstate@*/ /* FIX: data->data may be NULL */
xx = dbiGet(dbi, dbcursor, key, data, DB_SET);
+/*@=nullstate@*/
DNEVR = key->data;
DNEVRlen = key->size;
datap = data->data;
size_t len = 0;
int c;
- while ((c = *s++) != '\0') {
+/*@-boundsread@*/
+ while ((c = *s++) != '\0')
+/*@=boundsread@*/
+ {
switch (c) {
case '<': case '>': len += 4; /*@switchbreak@*/ break;
case '&': len += 5; /*@switchbreak@*/ break;
char * te = t;
int c;
+/*@-bounds@*/
while ((c = *s++) != '\0') {
switch (c) {
case '<': te = stpcpy(te, "<"); /*@switchbreak@*/ break;
}
}
*te = '\0';
+/*@=bounds@*/
return t;
}
* @param element (unused)
* @return formatted string
*/
+/*@-bounds@*/
static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
char * formatPrefix, int padding,
/*@unused@*/ int element)
const char * s = NULL;
char * t, * te;
unsigned long anint = 0;
+ int xx;
+/*@-branchstate@*/
switch (type) {
case RPM_I18NSTRING_TYPE:
case RPM_STRING_TYPE:
break;
case RPM_BIN_TYPE:
{ int cpl = b64encode_chars_per_line;
+/*@-mods@*/
b64encode_chars_per_line = 0;
+/*@=mods@*/
+/*@-formatconst@*/
s = base64Format(type, data, formatPrefix, padding, element);
+/*@=formatconst@*/
+/*@-mods@*/
b64encode_chars_per_line = cpl;
+/*@=mods@*/
xtag = "base64";
} break;
case RPM_CHAR_TYPE:
return xstrdup(_("(invalid xml type)"));
/*@notreached@*/ break;
}
+/*@=branchstate@*/
+/*@-branchstate@*/
if (s == NULL) {
int tlen = 32;
t = memset(alloca(tlen+1), 0, tlen+1);
- snprintf(t, tlen, "%lu", anint);
+ xx = snprintf(t, tlen, "%lu", anint);
s = t;
xtag = "integer";
}
+/*@=branchstate@*/
nb = 2 * strlen(xtag) + sizeof("\t<></>") + xmlstrlen(s);
te = t = alloca(nb);
te = stpcpy( stpcpy( stpcpy(te, "</"), xtag), ">");
/* XXX s was malloc'd */
+/*@-branchstate@*/
if (!strcmp(xtag, "base64"))
s = _free(s);
+/*@=branchstate@*/
nb += padding;
val = xmalloc(nb+1);
/*@-boundswrite@*/
strcat(formatPrefix, "s");
/*@=boundswrite@*/
- snprintf(val, nb, formatPrefix, t);
+/*@-formatconst@*/
+ xx = snprintf(val, nb, formatPrefix, t);
+/*@=formatconst@*/
val[nb] = '\0';
return val;
}
+/*@=bounds@*/
/**
* Display signature fingerprint and time.
/*@-usereleased -onlytrans@*/
struct fsinfo {
-/*@only@*/ const char * mntPoint; /*!< path to mount point. */
- dev_t dev; /*!< devno for mount point. */
- int rdonly; /*!< is mount point read only? */
+/*@only@*/ /*@relnull@*/
+ const char * mntPoint; /*!< path to mount point. */
+ dev_t dev; /*!< devno for mount point. */
+ int rdonly; /*!< is mount point read only? */
};
/*@unchecked@*/
-/*@only@*/ /*@null@*/ static struct fsinfo * filesystems = NULL;
+/*@only@*/ /*@null@*/
+static struct fsinfo * filesystems = NULL;
/*@unchecked@*/
-/*@only@*/ /*@null@*/ static const char ** fsnames = NULL;
+/*@only@*/ /*@null@*/
+static const char ** fsnames = NULL;
/*@unchecked@*/
static int numFilesystems = 0;
fsnames[numFilesystems] = NULL;
/*@=boundswrite@*/
+/*@-nullstate@*/ /* FIX: fsnames[] may be NULL */
return 0;
+/*@=nullstate@*/
}
#endif /* HAVE_MNTCTL */
#include <rpmlib.h>
#include "cpio.h"
+
#include "fsm.h"
+#define fsmUNSAFE fsmStage
+
#include "rpmerr.h"
#define _RPMFI_INTERNAL
#define _FSM_DEBUG 0
/*@unchecked@*/
int _fsm_debug = _FSM_DEBUG;
+
+/*@-exportheadervar@*/
/*@unchecked@*/
int _fsm_threads = 0;
+/*@=exportheadervar@*/
/* XXX Failure to remove is not (yet) cause for failure. */
/*@-exportlocal -exportheadervar@*/
/** \ingroup payload
*/
-static inline int dnlCount(const DNLI_t dnli)
+static inline int dnlCount(/*@null@*/ const DNLI_t dnli)
/*@*/
{
return (dnli ? dnli->fi->dc : 0);
/** \ingroup payload
*/
-static inline int dnlIndex(const DNLI_t dnli)
+static inline int dnlIndex(/*@null@*/ const DNLI_t dnli)
/*@*/
{
return (dnli ? dnli->isave : -1);
*/
/*@-boundsread@*/
/*@-usereleased@*/
-static /*@only@*/ void * dnlInitIterator(/*@special@*/ const FSM_t fsm,
+static /*@only@*/ /*@null@*/
+void * dnlInitIterator(/*@special@*/ const FSM_t fsm,
int reverse)
/*@uses fsm->iter @*/
/*@*/
* @return next directory name
*/
/*@-boundsread@*/
-static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
+static /*@observer@*/ /*@null@*/
+const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
/*@modifies dnli @*/
{
const char * dn = NULL;
/*@=boundsread@*/
static void * fsmThread(void * arg)
- /*@modifies arg @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies arg, fileSystem, internalState @*/
{
FSM_t fsm = arg;
+/*@-unqualifiedtrans@*/
return ((void *) fsmStage(fsm, fsm->nstage));
+/*@=unqualifiedtrans@*/
}
int fsmNext(FSM_t fsm, fileStage nstage)
- /*@modifies fsm @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
fsm->nstage = nstage;
if (_fsm_threads)
/*@uses fsm->links, fsm->ix, fsm->sb, fsm->goal, fsm->nsuffix @*/
/*@defines fsm->li @*/
/*@releases fsm->path @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
struct stat * st = &fsm->sb;
int rc = 0;
*fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos);
/*@=boundswrite@*/
+/*@-nullstate@*/ /* FIX: *fsm->failedFile may be NULL */
return ec;
+/*@=nullstate@*/
}
int fsmTeardown(FSM_t fsm)
* @param fsm file state machine data
* @return 0 on success
*/
+/*@-compdef@*/
static int expandRegular(/*@special@*/ FSM_t fsm)
- /*@uses fsm->sb @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@uses fsm->fmd5sum, fsm->md5sum, fsm->sb, fsm->wfd @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const struct stat * st = &fsm->sb;
int left = st->st_size;
if (rc)
goto exit;
- if (st->st_size > 0 && (fsm->fmd5sum || fsm->md5sum))
+ if (st->st_size > 0 && (fsm->fmd5sum != NULL || fsm->md5sum != NULL))
fdInitDigest(fsm->wfd, PGPHASHALGO_MD5, 0);
while (left) {
(void) fsmNext(fsm, FSM_WCLOSE);
return rc;
}
+/*@=compdef@*/
/** \ingroup payload
* Write next item to payload stream.
* @param writeData should data be written?
* @return 0 on success
*/
-static int writeFile(/*@special@*/ FSM_t fsm, int writeData)
+/*@-compdef -compmempass@*/
+static int writeFile(/*@special@*/ /*@partial@*/ FSM_t fsm, int writeData)
/*@uses fsm->path, fsm->opath, fsm->sb, fsm->osb, fsm->cfd @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const char * path = fsm->path;
const char * opath = fsm->opath;
/*@=branchstate@*/
if (fsm->mapFlags & CPIO_MAP_ABSOLUTE) {
-/*@-compdef@*/ /* FIX: dirName/baseName annotations ? */
/*@-boundswrite@*/
int nb = strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof(".");
char * t = alloca(nb);
*t++ = '.';
t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName);
/*@=boundswrite@*/
-/*@=compdef@*/
} else if (fsm->mapFlags & CPIO_MAP_PATH) {
rpmfi fi = fsmGetFi(fsm);
fsm->path =
}
#if HAVE_MMAP
+/*@-branchstate@*/
if (mapped != (void *)-1) {
xx = msync(mapped, nmapped, MS_ASYNC);
#if defined(MADV_DONTNEED)
xx = madvise(mapped, nmapped, MADV_DONTNEED);
#endif
- /*@-noeffect@*/ xx = munmap(mapped, nmapped) /*@=noeffect@*/;
+/*@-noeffect@*/
+ xx = munmap(mapped, nmapped);
+/*@=noeffect@*/
fsm->rdbuf = rdbuf;
}
+/*@=branchstate@*/
#endif
} else if (writeData && S_ISLNK(st->st_mode)) {
exit:
if (fsm->rfd != NULL)
(void) fsmNext(fsm, FSM_RCLOSE);
- /*@-dependenttrans@*/
+/*@-dependenttrans@*/
fsm->opath = opath;
fsm->path = path;
- /*@=dependenttrans@*/
+/*@=dependenttrans@*/
return rc;
}
+/*@=compdef =compmempass@*/
/** \ingroup payload
* Write set of linked files to payload stream.
* @param fsm file state machine data
* @return 0 on success
*/
-static int writeLinkedFile(/*@special@*/ FSM_t fsm)
+static int writeLinkedFile(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->path, fsm->nsuffix, fsm->ix, fsm->li, fsm->failedFile @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const char * path = fsm->path;
const char * nsuffix = fsm->nsuffix;
fsm->ix = -1;
/*@-boundswrite@*/
+/*@-branchstate@*/
for (i = fsm->li->nlink - 1; i >= 0; i--) {
if (fsm->li->filex[i] < 0) continue;
fsm->ix = fsm->li->filex[i];
+/*@-compdef@*/
rc = fsmNext(fsm, FSM_MAP);
+/*@=compdef@*/
/* Write data after last link. */
rc = writeFile(fsm, (i == 0));
fsm->path = _free(fsm->path);
fsm->li->filex[i] = -1;
}
+/*@=branchstate@*/
/*@=boundswrite@*/
fsm->ix = iterIndex;
* @return 0 on success
*/
/*@-boundsread@*/
-static int fsmMakeLinks(/*@special@*/ FSM_t fsm)
+/*@-compdef@*/
+static int fsmMakeLinks(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->path, fsm->opath, fsm->nsuffix, fsm->ix, fsm->li @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const char * path = fsm->path;
const char * opath = fsm->opath;
fsm->opath = opath;
return ec;
}
+/*@=compdef@*/
/*@=boundsread@*/
/** \ingroup payload
* @param fsm file state machine data
* @return 0 on success
*/
-static int fsmCommitLinks(/*@special@*/ FSM_t fsm)
+/*@-compdef@*/
+static int fsmCommitLinks(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->path, fsm->nsuffix, fsm->ix, fsm->sb,
fsm->li, fsm->links @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const char * path = fsm->path;
const char * nsuffix = fsm->nsuffix;
fsm->path = path;
return rc;
}
+/*@=compdef@*/
/**
* Remove (if created) directories not explicitly included in package.
* @param fsm file state machine data
* @return 0 on success
*/
-static int fsmRmdirs(/*@special@*/ FSM_t fsm)
+static int fsmRmdirs(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->path, fsm->dnlx, fsm->ldn, fsm->rdbuf, fsm->iter @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
const char * path = fsm->path;
void * dnli = dnlInitIterator(fsm, 1);
do {
if (*te == '/') {
*te = '\0';
+/*@-compdef@*/
rc = fsmNext(fsm, FSM_RMDIR);
+/*@=compdef@*/
*te = '/';
}
if (rc)
* @param fsm file state machine data
* @return 0 on success
*/
-static int fsmMkdirs(/*@special@*/ FSM_t fsm)
+static int fsmMkdirs(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->path, fsm->sb, fsm->osb, fsm->rdbuf, fsm->iter,
fsm->ldn, fsm->ldnlen, fsm->ldnalloc @*/
/*@defines fsm->dnlx, fsm->ldn @*/
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
struct stat * st = &fsm->sb;
struct stat * ost = &fsm->osb;
* @param fsm file state machine data
* @return 0 on success
*/
-static int fsmStat(FSM_t fsm)
- /*@globals errno, fileSystem, internalState @*/
- /*@modifies fsm, errno, fileSystem, internalState @*/
+static int fsmStat(/*@special@*/ /*@partial@*/ FSM_t fsm)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fsm, fileSystem, internalState @*/
{
- int saveerrno = errno;
int rc = 0;
if (fsm->path != NULL) {
/* Detect and create directories not explicitly in package. */
if (fsm->goal == FSM_PKGINSTALL) {
+/*@-compdef@*/
rc = fsmNext(fsm, FSM_MKDIRS);
+/*@=compdef@*/
if (!rc) fsm->mkdirsdone = 1;
}
rc = fsmNext(fsm, FSM_RENAME);
if (!rc)
rpmMessage(RPMMESS_WARNING,
- _("%s saved as %s\n"), fsm->opath, fsm->path);
+ _("%s saved as %s\n"),
+ (fsm->opath ? fsm->opath : ""),
+ (fsm->path ? fsm->path : ""));
fsm->path = _free(fsm->path);
fsm->opath = opath;
}
rc = fsmNext(fsm, FSM_RENAME);
if (!rc) {
rpmMessage(RPMMESS_WARNING, _("%s saved as %s\n"),
- fsm->opath, fsm->path);
+ (fsm->opath ? fsm->opath : ""),
+ (fsm->path ? fsm->path : ""));
}
fsm->path = _free(fsm->path);
fsm->path = path;
if (!rc && fsm->nsuffix) {
const char * opath = fsmFsPath(fsm, st, NULL, NULL);
rpmMessage(RPMMESS_WARNING, _("%s created as %s\n"),
- (opath ? opath : ""), fsm->path);
+ (opath ? opath : ""),
+ (fsm->path ? fsm->path : ""));
opath = _free(opath);
}
fsm->opath = _free(fsm->opath);
fsm->path, (rc < 0 ? strerror(errno) : ""));
if (rc < 0)
switch (errno) {
- case ENOENT: rc = CPIOERR_ENOENT; break;
- case ENOTEMPTY: rc = CPIOERR_ENOTEMPTY; break;
- default: rc = CPIOERR_RMDIR_FAILED; break;
+ case ENOENT: rc = CPIOERR_ENOENT; /*@switchbreak@*/ break;
+ case ENOTEMPTY: rc = CPIOERR_ENOTEMPTY; /*@switchbreak@*/ break;
+ default: rc = CPIOERR_RMDIR_FAILED; /*@switchbreak@*/ break;
}
break;
case FSM_CHOWN:
* Keeps track of the set of all hard links to a file in an archive.
*/
struct hardLink_s {
-/*@owned@*/ struct hardLink_s * next;
-/*@owned@*/ const char ** nsuffix;
-/*@owned@*/ int * filex;
+/*@owned@*/ /*@relnull@*/
+ struct hardLink_s * next;
+/*@owned@*/
+ const char ** nsuffix;
+/*@owned@*/
+ int * filex;
struct stat sb;
int nlink;
int linksLeft;
* File name and stat information.
*/
struct fsm_s {
-/*@owned@*/
+/*@owned@*/ /*@relnull@*/
const char * path; /*!< Current file name. */
-/*@owned@*/
+/*@owned@*/ /*@relnull@*/
const char * opath; /*!< Original file name. */
+/*@relnull@*/
FD_t cfd; /*!< Payload file handle. */
+/*@relnull@*/
FD_t rfd; /*!< read: File handle. */
-/*@dependent@*/
+/*@dependent@*/ /*@relnull@*/
char * rdbuf; /*!< read: Buffer. */
-/*@owned@*/
+/*@owned@*/ /*@relnull@*/
char * rdb; /*!< read: Buffer allocated. */
size_t rdsize; /*!< read: Buffer allocated size. */
size_t rdlen; /*!< read: Number of bytes requested.*/
size_t rdnb; /*!< read: Number of bytes returned. */
FD_t wfd; /*!< write: File handle. */
-/*@dependent@*/
+/*@dependent@*/ /*@relnull@*/
char * wrbuf; /*!< write: Buffer. */
-/*@owned@*/
+/*@owned@*/ /*@relnull@*/
char * wrb; /*!< write: Buffer allocated. */
size_t wrsize; /*!< write: Buffer allocated size. */
size_t wrlen; /*!< write: Number of bytes requested.*/
/*@only@*/ /*@null@*/
FSMI_t iter; /*!< File iterator. */
int ix; /*!< Current file iterator index. */
-/*@only@*/
+/*@only@*/ /*@relnull@*/
struct hardLink_s * links; /*!< Pending hard linked file(s). */
-/*@only@*/
+/*@only@*/ /*@relnull@*/
struct hardLink_s * li; /*!< Current hard linked file(s). */
/*@kept@*/ /*@null@*/
unsigned int * archiveSize; /*!< Pointer to archive size. */
/*@kept@*/ /*@null@*/
const char ** failedFile; /*!< First file name that failed. */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * subdir; /*!< Current file sub-directory. */
/*@unused@*/
char subbuf[64]; /* XXX eliminate */
-/*@observer@*/
+/*@observer@*/ /*@relnull@*/
const char * osuffix; /*!< Old, preserved, file suffix. */
-/*@observer@*/
+/*@observer@*/ /*@relnull@*/
const char * nsuffix; /*!< New, created, file suffix. */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * suffix; /*!< Current file suffix. */
char sufbuf[64]; /* XXX eliminate */
/*@only@*/ /*@null@*/
int rc; /*!< External file stage return code. */
int commit; /*!< Commit synchronously? */
cpioMapFlags mapFlags; /*!< Bit(s) to control mapping. */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * dirName; /*!< File directory name. */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * baseName; /*!< File base name. */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * fmd5sum; /*!< Hex MD5 sum (NULL disables). */
-/*@shared@*/
+/*@shared@*/ /*@relnull@*/
const char * md5sum; /*!< Binary MD5 sum (NULL disables). */
unsigned fflags; /*!< File flags. */
/**
* Create file state machine instance.
- * @return file state machine data
+ * @return file state machine
*/
/*@only@*/ FSM_t newFSM(void)
/*@*/;
/**
* Destroy file state machine instance.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @return always NULL
*/
/*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
/**
* Load external data into file state machine.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @param goal
* @param ts transaction set
* @param fi transaction element file info
/**
* Clean file state machine.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @return 0 on success
*/
int fsmTeardown(FSM_t fsm)
/*@-exportlocal@*/
/**
* Retrieve transaction set from file state machine iterator.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @return transaction set
*/
rpmts fsmGetTs(const FSM_t fsm)
/**
* Retrieve transaction element file info from file state machine iterator.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @return transaction element file info
*/
rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
/**
* Map next file path and action.
- * @param fsm file state machine data
+ * @param fsm file state machine
*/
int fsmMapPath(FSM_t fsm)
/*@modifies fsm @*/;
/**
* Map file stat(2) info.
- * @param fsm file state machine data
+ * @param fsm file state machine
*/
int fsmMapAttrs(FSM_t fsm)
/*@modifies fsm @*/;
/*@=exportlocal@*/
+/**
+ * File state machine driver.
+ * @param fsm file state machine
+ * @param nstage next stage
+ * @return 0 on success
+ */
int fsmNext(FSM_t fsm, fileStage nstage)
- /*@modifies fsm @*/;
+ /*@globals errno, fileSystem, internalState @*/
+ /*@modifies fsm, errno, fileSystem, internalState @*/;
/**
* File state machine driver.
- * @param fsm file state machine data
+ * @param fsm file state machine
* @param stage next stage
* @return 0 on success
*/
+/*@-exportlocal@*/
int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
/*@globals errno, fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/;
-#define fsmUNSAFE fsmStage
+/*@=exportlocal@*/
#ifdef __cplusplus
}
list[i] = NULL;
+/*@-nullret@*/ /* FIX: list[i] is NULL */
return list;
+/*@=nullret@*/
}
/*@=bounds@*/
fprintf(stderr, "*** GLOB maxb %d diskURL %d %*s globURL %p %s\n", (int)maxb, (int)nb, (int)nb, av[j], globURL, globURL);
/*@-branchstate@*/
+#ifdef DYING
if (argc == 0)
argv = xmalloc((gl.gl_pathc+1) * sizeof(*argv));
else if (gl.gl_pathc > 0)
+#endif
argv = xrealloc(argv, (argc+gl.gl_pathc+1) * sizeof(*argv));
/*@=branchstate@*/
+
+ if (argv != NULL)
for (i = 0; i < gl.gl_pathc; i++) {
const char * globFile = &(gl.gl_pathv[i][0]);
if (globRoot > globURL && globRoot[-1] == '/')
exit:
av = _free(av);
+/*@-branchstate@*/
if (rc || argvPtr == NULL) {
+/*@-dependenttrans -unqualifiedtrans@*/
if (argv != NULL)
for (i = 0; i < argc; i++)
argv[i] = _free(argv[i]);
argv = _free(argv);
+/*@=dependenttrans =unqualifiedtrans@*/
}
+/*@=branchstate@*/
return rc;
}
/*@unchecked@*/
extern int _fsm_debug;
+
+/*@unchecked@*/
extern int _fsm_threads;
/*@unchecked@*/
/*@unchecked@*/
extern int _psm_debug;
+
+/*@unchecked@*/
extern int _psm_threads;
/*@unchecked@*/
NULL))
epochTwo = NULL;
- if (epochOne && !epochTwo)
+ if (epochOne != NULL && epochTwo == NULL)
return 1;
- else if (!epochOne && epochTwo)
+ else if (epochOne == NULL && epochTwo != NULL)
return -1;
- else if (epochOne && epochTwo) {
+ else if (epochOne != NULL && epochTwo != NULL) {
/*@-boundsread@*/
if (*epochOne < *epochTwo)
return -1;
/*@-onlytrans@*/ /* FIX: te reference */
fi->te = rpmtsElement(ts, 0);
/*@=onlytrans@*/
+ if (fi->te == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ goto exit;
+ }
+
/*@-nullpass@*/ /* FIX fi->h may be null */
fi->te->h = headerLink(fi->h);
/*@=nullpass@*/
}
maxPrefixLength = 0;
+ if (prefixes != NULL)
for (i = 0; i < numPrefixes; i++) {
len = strlen(prefixes[i]);
if (len > maxPrefixLength) maxPrefixLength = len;
/*@-branchstate@*/
if (makeTempFile((!rpmtsChrootDone(ts) ? rootDir : "/"), &fn, &fd)) {
- if (freePrefixes) free(prefixes);
+ if (prefixes != NULL && freePrefixes) free(prefixes);
return RPMRC_FAIL;
}
/*@=branchstate@*/
/*@=modobserver@*/
}
+ if (prefixes != NULL)
for (i = 0; i < numPrefixes; i++) {
sprintf(prefixBuf, "RPM_INSTALL_PREFIX%d=%s", i, prefixes[i]);
xx = doputenv(prefixBuf);
psm->stepName, sln, n, v, r,
argv[0], (unsigned)getpid());
unsetenv("MALLOC_CHECK_");
+/*@-nullstate@*/
xx = execv(argv[0], (char *const *)argv);
+/*@=nullstate@*/
break;
default:
break;
if (numPackage < 0)
return RPMRC_NOTFOUND;
- if (fi->h != NULL) /* XXX can't happen */
+ if (fi != NULL && fi->h != NULL) /* XXX can't happen */
{ Header triggeredH;
rpmdbMatchIterator mi;
int countCorrection = psm->countCorrection;
}
static void * rpmpsmThread(void * arg)
- /*@modifies psm @*/
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies arg, rpmGlobalMacroContext, fileSystem, internalState @*/
{
rpmpsm psm = arg;
+/*@-unqualifiedtrans@*/
return ((void *) rpmpsmStage(psm, psm->nstage));
+/*@=unqualifiedtrans@*/
}
static int rpmpsmNext(rpmpsm psm, pkgStage nstage)
- /*@modifies psm @*/
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/
{
psm->nstage = nstage;
if (_psm_threads)
rpmts ts; /*!< transaction set */
/*@dependent@*/ /*@null@*/
rpmte te; /*!< current transaction element */
-/*@refcounted@*/
+/*@refcounted@*/ /*@relnull@*/
rpmfi fi; /*!< transaction element file info */
+/*@relnull@*/
FD_t cfd; /*!< Payload file handle. */
+/*@relnull@*/
FD_t fd; /*!< Repackage file handle. */
Header oh; /*!< Repackage header. */
/*@null@*/
* @param msg
* @return new package state machine reference
*/
-/*@unused@*/ /*@newref@*/
+/*@unused@*/ /*@newref@*/ /*@null@*/
rpmpsm rpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg)
/*@modifies psm @*/;
/** @todo Remove debugging entry from the ABI. */
/*@-exportlocal@*/
-/*@newref@*/
+/*@newref@*/ /*@null@*/
rpmpsm XrpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg,
const char * fn, unsigned ln)
/*@modifies psm @*/;
* @param fi file info set
* @return new package state machine
*/
+/*@null@*/
rpmpsm rpmpsmNew(rpmts ts, /*@null@*/ rpmte te, rpmfi fi)
/*@modifies ts, fi @*/;
}
/* Read list of packages from manifest. */
+/*@-nullstate@*/ /* FIX: *av may be NULL */
res = rpmReadPackageManifest(fd, &ac, &av);
+/*@=nullstate@*/
if (res != RPMRC_OK) {
rpmError(RPMERR_MANIFEST,
_("%s: not an rpm package (or package manifest): %s\n"),
/**
*/
/*@-boundsread@*/
-static int manageFile(FD_t *fdp, const char **fnp, int flags,
- /*@unused@*/ int rc)
+static int manageFile(/*@out@*/ FD_t *fdp,
+ /*@null@*/ /*@out@*/ const char **fnp,
+ int flags, /*@unused@*/ int rc)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies *fdp, *fnp, rpmGlobalMacroContext,
fileSystem, internalState @*/
const char *fn;
FD_t fd;
- if (fdp == NULL) { /* programmer error */
+ if (fdp == NULL) /* programmer error */
return 1;
- }
/*@-boundswrite@*/
/* close and reset *fdp to NULL */
}
/* open a file and set *fdp */
- if (*fdp == NULL && fnp && *fnp) {
+ if (*fdp == NULL && fnp != NULL && *fnp != NULL) {
fd = Fopen(*fnp, ((flags & O_WRONLY) ? "w.ufdio" : "r.ufdio"));
if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_OPEN, _("%s: open failed: %s\n"), *fnp,
rpmError(RPMERR_MAKETEMP, _("makeTempFile failed\n"));
return 1;
}
- if (fnp)
+ if (fnp != NULL)
*fnp = fn;
*fdp = fdLink(fd, "manageFile return");
fd = fdFree(fd, "manageFile return");
/*@=boundswrite@*/
/* no operation */
- if (*fdp && fnp && *fnp) {
+ if (*fdp != NULL && fnp != NULL && *fnp != NULL)
return 0;
- }
/* XXX never reached */
return 1;
t = stpcpy(t, argv[ac]) + 1;
}
av[ac] = NULL;
+/*@-nullret@*/
return av;
+/*@=nullret@*/
}
/*@=bounds@*/
+/*@null@*/
static rpmds rpmdsDup(const rpmds ods)
/*@modifies ods @*/
{
}
/*@=branchstate@*/
ds = *dsp;
+ if (ds == NULL)
+ return -1;
/*
* Add new entries.
* @param msg
* @return new dependency set reference
*/
-/*@unused@*/ /*@newref@*/
+/*@unused@*/ /*@newref@*/ /*@null@*/
rpmds rpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg)
/*@modifies ds @*/;
/** @todo Remove debugging entry from the ABI. */
-/*@newref@*/
+/*@newref@*/ /*@null@*/
rpmds XrpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg,
const char * fn, unsigned ln)
/*@modifies ds @*/;
fn = xrealloc(fn, fileAlloced);
}
/*@=branchstate@*/
+
+ if (fn == NULL) /* XXX can't happen */
+ continue;
*fn = '\0';
fnlen = stpcpy( stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn;
}
if (j < 0) continue;
+/*@-nullderef@*/ /* FIX: fModes may be NULL */
ft = whatis(fModes[i]);
+/*@=nullderef@*/
/* On install, a relocate to NULL means skip the path. */
if (relocations[j].newPath == NULL) {
baseNames = hfd(baseNames, RPM_STRING_ARRAY_TYPE);
dirNames = hfd(dirNames, RPM_STRING_ARRAY_TYPE);
+/*@-dependenttrans@*/
fn = _free(fn);
+/*@=dependenttrans@*/
return h;
}
/*@only@*/ /*?null?*/
const char ** dnl; /*!< Directory name(s) (from header) */
-/*@only@*/ /*?null?*/
+/*@only@*/ /*@relnull@*/
const char ** fmd5s; /*!< File MD5 sum(s) (from header) */
-/*@only@*/ /*?null?*/
+/*@only@*/ /*@relnull@*/
const char ** flinks; /*!< File link(s) (from header) */
/*@only@*/ /*@null@*/
const char ** flangs; /*!< File lang(s) (from header) */
int_32 fc; /*!< No. of files. */
/*=============================*/
-/*@dependent@*/
+/*@dependent@*/ /*@relnull@*/
rpmte te;
HGE_t hge; /*!< Vector to headerGetEntry() */
gid_t gid; /*!< File gid (default). */
uint_32 flags; /*!< File flags (default). */
fileAction action; /*!< File disposition (default). */
-/*@owned@*/
+/*@owned@*/ /*@relnull@*/
fileAction * actions; /*!< File disposition(s). */
/*@owned@*/
struct fingerPrint_s * fps; /*!< File fingerprint(s). */
/*@unused@*/
int_32 * odil; /*!< Original dirindex(s) (from header) */
-/*@only@*/
+/*@only@*/ /*@relnull@*/
unsigned char * md5s; /*!< File md5 sums in binary. */
/*@only@*/ /*@null@*/
* @param msg
* @return new file info set reference
*/
-/*@unused@*/
+/*@unused@*/ /*@null@*/
rpmfi rpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg)
/*@modifies fi @*/;
* @param ln
* @return NULL always
*/
+/*@null@*/
rpmfi XrpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg,
const char * fn, unsigned ln)
/*@modifies fi @*/;
}
/* Read list of packages from manifest. */
+/*@-nullstate@*/ /* FIX: *eiu->argv can be NULL */
rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
+/*@=nullstate@*/
if (rc != RPMRC_OK)
rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"),
*eiu->fnp, Fstrerror(eiu->fd));
tidp = NULL;
/*@-branchstate@*/
- if (hge(h, tag, &type, (void **) &tidp, &count) && tidp) {
+ if (hge(h, tag, &type, (void **) &tidp, &count) && tidp != NULL) {
idtx = IDTXgrow(idtx, 1);
if (idtx == NULL || idtx->idt == NULL)
/*@observer@*/ /*@unchecked@*/
static const char * platform = "/etc/rpm/platform";
-/*@only@*/ /*@relnul@*/ /*@unchecked@*/
+/*@only@*/ /*@relnull@*/ /*@unchecked@*/
static const char ** platpat = NULL;
/*@unchecked@*/
static int nplatpat = 0;
* @param tsi transaction element iterator
* @return transaction element, NULL on termination
*/
-static /*@dependent@*/ /*@null@*/
+static /*@null@*/ /*@dependent@*/
rpmte rpmtsiNextElement(rpmtsi tsi)
/*@modifies tsi @*/
{
struct rpmte_s {
rpmElementType type; /*!< Package disposition (installed/removed). */
-/*@refcounted@*/ /*@null@*/
+/*@refcounted@*/ /*@relnull@*/
Header h; /*!< Package header. */
/*@only@*/
const char * NEVR; /*!< Package name-version-release. */
* @param pte new parent transaction element
* @return previous parent transaction element
*/
+/*@null@*/
rpmte rpmteSetParent(rpmte te, rpmte pte)
/*@modifies te @*/;
/*@null@*/
int (*solve) (rpmts ts, rpmds key, const void * data)
/*@modifies ts @*/; /*!< Search for NEVRA key. */
+/*@relnull@*/
const void * solveData; /*!< Solve callback data */
int nsuggests; /*!< No. of depCheck suggestions. */
/*@only@*/ /*@null@*/
* Return (ordered) transaction set element.
* @param ts transaction set
* @param ix transaction element index
- * @return transaction element
+ * @return transaction element (or NULL)
*/
+/*@null@*/ /*@dependent@*/
rpmte rpmtsElement(rpmts ts, int ix)
/*@*/;
*/
/*@newref@*/
rpmts rpmtsCreate(void)
- /*@globals rpmGlobalMacroContext @*/
- /*@modifies rpmGlobalMacroContext @*/;
+ /*@globals rpmGlobalMacroContext, internalState @*/
+ /*@modifies rpmGlobalMacroContext, internalState @*/;
/** \ingroup rpmts
* Add package to be installed to transaction set.
/*
* Skip i18n language specific files.
*/
- if (fi->flangs && languages && *fi->flangs[i]) {
+ if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
const char **lang, *l, *le;
for (lang = languages; *lang != NULL; lang++) {
if (!strcmp(*lang, "all"))
}
}
+/*@-dependenttrans@*/
if (netsharedPaths) freeSplitString(netsharedPaths);
#ifdef DYING /* XXX freeFi will deal with this later. */
fi->flangs = _free(fi->flangs);
#endif
if (languages) freeSplitString((char **)languages);
+/*@=dependenttrans@*/
}
/*@=bounds@*/
/*@=mustmod@*/
continue; /* XXX can't happen */
psm = rpmpsmNew(ts, p, fi);
+assert(psm != NULL);
psm->unorderedSuccessor =
(rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
fi->fstates = NULL;
fi->actions = NULL;
+/*@-nullstate@*/ /* FIX: fi->actions is NULL */
fi = rpmfiFree(fi);
+/*@=nullstate@*/
savep = rpmtsSetRelocateElement(ts, p);
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
rpmpsm psm = rpmpsmNew(ts, NULL, fi);
int rc = 0;
+ if (psm == NULL) /* XXX can't happen */
+ return rc;
+
if (scriptFd != NULL)
rpmtsSetScriptFd(psm->ts, scriptFd);
DIGEST_CTX
rpmDigestDup(DIGEST_CTX octx)
{
- DIGEST_CTX nctx = memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
+ DIGEST_CTX nctx;
+ nctx = memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
return nctx;
}
int
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
{
+ if (ctx == NULL)
+ return -1;
+
DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data)));
/*@-boundsread@*/
return (*ctx->Update) (ctx->param, data, len);
/*@-boundswrite@*/
int
-rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap,
- /*@out@*/ size_t *lenp, int asAscii)
+rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
{
- uint32 * digest = xmalloc(ctx->digestlen);
+ uint32 * digest;
char * t;
int i;
+ if (ctx == NULL)
+ return -1;
+ 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 */
(void) (*ctx->Digest) (ctx->param, digest);
register FTSENT *freep, *p;
int saved_errno;
+ if (sp == NULL)
+ return 0;
+
/*
* This still works if we haven't read anything -- the dummy structure
* points to the root list, so we step through to the end of the root
int saved_errno;
/* If finished or unrecoverable error, return NULL. */
- if (sp->fts_cur == NULL || ISSET(FTS_STOP))
+ if (sp == NULL || sp->fts_cur == NULL || ISSET(FTS_STOP))
return (NULL);
/* Set current node pointer. */
* @param sp file hierarchy state
* @return 0 on sucess, -1 on error
*/
-int Fts_close (/*@only@*/ FTS * sp) __THROW
+int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
* @return file set member
*/
/*@null@*/
-FTSENT *Fts_read (FTS * sp) __THROW
+FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
/** \ingroup rpmio
*/
+/*@-uniondef@*/
/*@unused@*/ static inline
void fdstat_enter(/*@null@*/ FD_t fd, int opx)
/*@globals internalState @*/
fd->stats->begin = end; /* structure assignment */
/*@=boundswrite@*/
}
+/*@=uniondef@*/
/** \ingroup rpmio
*/
* @param len no. bytes of data
* @return 0 on success
*/
-int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
+int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
/*@modifies ctx @*/;
/** \ingroup rpmio
* @param asAscii return digest as ascii string?
* @return 0 on success
*/
-int rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
+int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx,
/*@null@*/ /*@out@*/ void ** datap,
/*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
/*@modifies *datap, *lenp @*/;
+/*@-unrecog@*/
/** \ingroup rpmio
* \file rpmio/rpmsq.c
*/
#include "system.h"
-
+
+#if defined(__LCLINT__)
+struct qelem;
+/*@-exportheader@*/
+extern void insque(struct qelem * __elem, struct qelem * __prev)
+ /*@modifies __elem, prev @*/;
+extern void remque(struct qelem * __elem)
+ /*@modifies __elem @*/;
+/*@=exportheader@*/
+#endif
+
+#include <signal.h>
+#include <sys/signal.h>
+#include <sys/wait.h>
+#include <search.h>
+
#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__)
#include <pthread.h>
+/*@unchecked@*/
+static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
#define DO_UNLOCK() pthread_mutex_unlock(&rpmsigTbl_lock);
#define INIT_LOCK() \
#define DO_LOCK()
#define DO_UNLOCK()
#define INIT_LOCK()
-#define ADD_REF(__tbl)
-#define SUB_REF(__tbl)
+#define ADD_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
+#define SUB_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
#define CLEANUP_RESET(__execute, __oldtype)
#define SAME_THREAD(_a, _b) (42)
-#define ME() (((void *))getpid())
+#define ME() (((void *)getpid()))
#endif /* HAVE_PTHREAD_H */
/*@unchecked@*/
static struct rpmsqElem rpmsqRock;
+
+/*@-compmempass@*/
/*@unchecked@*/
rpmsq rpmsqQueue = &rpmsqRock;
+/*@=compmempass@*/
-int rpmsqInsert(void * elem, void * prev)
+/*@-mustmod@*/
+int rpmsqInsert(void * elem, /*@unused@*/ void * prev)
{
rpmsq sq = (rpmsq) elem;
int ret = -1;
sq->reaped = 0;
sq->status = 0;
sq->reaper = 1;
+/*@-bounds@*/
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
ret = sigrelse(SIGCHLD);
}
}
return ret;
}
+/*@=mustmod@*/
int rpmsqRemove(void * elem)
{
ret = pthread_cond_destroy(&sq->cond);
ret = pthread_mutex_destroy(&sq->mutex);
sq->id = NULL;
- if (sq->pipes[1]) close(sq->pipes[1]);
- if (sq->pipes[0]) close(sq->pipes[0]);
+/*@-bounds@*/
+ if (sq->pipes[1]) ret = close(sq->pipes[1]);
+ if (sq->pipes[0]) ret = close(sq->pipes[0]);
sq->pipes[0] = sq->pipes[1] = -1;
+/*@=bounds@*/
#ifdef NOTYET /* rpmpsmWait debugging message needs */
sq->reaper = 1;
sq->status = 0;
sigset_t rpmsqCaught;
/*@unchecked@*/
-static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-
-/*@unchecked@*/
/*@-fullinitblock@*/
static struct rpmsig_s {
int signum;
- void (*handler) (int signum, siginfo_t * info, void * context);
+ void (*handler) (int signum, void * info, void * context);
int active;
struct sigaction oact;
} rpmsigTbl[] = {
/*@=fullinitblock@*/
/*@-incondefs@*/
-void rpmsqAction(int signum, siginfo_t * info, void * context)
+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;
}
}
/*@=incondefs@*/
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
+ /*@globals rpmsigTbl @*/
+ /*@modifies rpmsigTbl @*/
{
int tblsignum = (signum >= 0 ? signum : -signum);
struct sigaction sa;
int ret = -1;
DO_LOCK ();
+#if !defined(__LCLINT__)
if (rpmsqQueue->id == NULL)
rpmsqQueue->id = ME();
+#endif
for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) {
if (tblsignum != tbl->signum)
continue;
if (signum >= 0) { /* Enable. */
if (ADD_REF(tbl) <= 0) {
(void) sigdelset(&rpmsqCaught, tbl->signum);
- sigemptyset (&sa.sa_mask);
+ (void) sigemptyset (&sa.sa_mask);
+/*@-compdef -type @*/
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = (handler != NULL ? handler : tbl->handler);
if (sigaction(tbl->signum, &sa, &tbl->oact) < 0) {
SUB_REF(tbl);
break;
}
+/*@=compdef =type @*/
tbl->active = 1; /* XXX just in case */
if (handler != NULL)
tbl->handler = handler;
pid = fork();
if (pid < (pid_t) 0) { /* fork failed. */
+/*@-bounds@*/
xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1;
+/*@=bounds@*/
goto out;
} else if (pid == (pid_t) 0) { /* Child. */
int yy;
/* Block to permit parent to wait. */
+/*@-bounds@*/
xx = close(sq->pipes[1]);
xx = read(sq->pipes[0], &yy, sizeof(yy));
xx = close(sq->pipes[0]);
sq->pipes[0] = sq->pipes[1] = -1;
+/*@=bounds@*/
#ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/
#endif
#ifdef DYING
+/*@-bounds@*/
/* Unblock child. */
xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1;
+/*@=bounds@*/
#endif
}
*/
static int rpmsqWaitUnregister(rpmsq sq)
/*@globals fileSystem, internalState @*/
- /*@modifies fileSystem, internalState @*/
+ /*@modifies sq, fileSystem, internalState @*/
{
struct rpmsw_s end;
int same_thread = 0;
ret = pthread_mutex_lock(&sq->mutex);
/* Start the child. */
+/*@-bounds@*/
if (sq->pipes[0] >= 0)
xx = close(sq->pipes[0]);
if (sq->pipes[1] >= 0)
xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1;
+/*@=bounds@*/
(void) rpmswNow(&sq->begin);
}
/*@=infloops@*/
+/*@-uniondef@*/
sq->msecs = rpmswDiff(rpmswNow(&end), &sq->begin)/1000;
+/*@=uniondef@*/
sq->script_msecs += sq->msecs;
if (same_thread)
*/
static void
sigchld_cancel (void *arg)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/
{
pid_t child = *(pid_t *) arg;
pid_t result;
/**
* Execute a command, returning its status.
*/
+/*@-bounds@*/
int
rpmsqExecve (const char ** argv)
{
}
DO_UNLOCK ();
- sigemptyset (&newMask);
- sigaddset (&newMask, SIGCHLD);
+ (void) sigemptyset (&newMask);
+ (void) sigaddset (&newMask, SIGCHLD);
if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) {
DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0)
DO_UNLOCK ();
return status;
}
+/*@=bounds@*/
+/*@=unrecog@*/
*
*/
-#include <pthread.h>
-#include <signal.h>
-#include <sys/signal.h>
-#include <search.h> /* XXX insque(3)/remque(3) protos. */
-
#include <rpmsw.h>
+/**
+ */
typedef struct rpmsig_s * rpmsig;
+/**
+ */
typedef struct rpmsqElem * rpmsq;
-typedef void (*rpmsqAction_t) (int signum, siginfo_t *info, void *context)
+/**
+ * Default signal handler prototype.
+ * @param signum signal number
+ * @param info (siginfo_t) signal info
+ * @param context signal context
+ */
+typedef void (*rpmsqAction_t) (int signum, void * info, void * context)
/*@*/;
/*@-redecl@*/
pthread_cond_t cond;
};
+/*@-exportlocal@*/
/*@unchecked@*/
extern rpmsq rpmsqQueue;
+/*@=exportlocal@*/
/*@unchecked@*/
extern sigset_t rpmsqCaught;
#endif
/**
+ * Insert node into from queue.
+ * @param elem node to link
+ * @param prev previous node from queue
+ * @return 0 on success
*/
+/*@-exportlocal@*/
int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
- /*@globals rpmsqQueue @*/
- /*@modifies elem, rpmsqQueue @*/;
+ /*@modifies elem @*/;
+/*@=exportlocal@*/
/**
+ * Remove node from queue.
+ * @param elem node to link
+ * @return 0 on success
*/
+/*@-exportlocal@*/
int rpmsqRemove(/*@null@*/ void * elem)
- /*@modifies elem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies elem, fileSystem, internalState @*/;
+/*@=exportlocal@*/
/**
+ * Default signal handler.
+ * @param signum signal number
+ * @param info (siginfo_t) signal info
+ * @param context signal context
*/
-void rpmsqAction(int signum, siginfo_t * info, void * context)
- /*@globals rpmsqCaught, fileSystem @*/
- /*@modifies rpmsqCaught, fileSystem @*/;
+/*@-exportlocal@*/
+void rpmsqAction(int signum, void * info, void * context)
+ /*@globals rpmsqCaught, errno, fileSystem @*/
+ /*@modifies rpmsqCaught, errno, fileSystem @*/;
+/*@=exportlocal@*/
/**
* Enable or disable a signal handler.
* @return 0 on success
*/
int rpmsqThread(void * (*start) (void * arg), void * arg)
- /*@globals fileSystem, internalState @*/
- /*@modifies fileSystem, internalState @*/;
+ /*@globals internalState @*/
+ /*@modifies internalState @*/;
/**
* Execute a command, returning its status.
*/
int rpmsqExecve (const char ** argv)
- /*@*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
#ifdef __cplusplus
}
#if defined(__LCLINT__)
/*@-exportheader@*/
-extern int nanosleep(const struct timespec *req, /*@out@*/ struct timespec *rem)
- /*@modifies rem @*/;
+extern int nanosleep(const struct timespec *__requested_time,
+ /*@out@*/ /*@null@*/ struct timespec *__remaining)
+ /*@globals errno @*/
+ /*@modifies *__remaining, errno @*/;
/*@=exportheader@*/
#endif
int rc;
int i;
+/*@-uniondef@*/
(void) rpmswNow(&begin);
+/*@=uniondef@*/
req.tv_sec = 0;
req.tv_nsec = 20 * 1000 * 1000;
for (i = 0; i < 100; i++) {
break;
req = rem; /* structure assignment */
}
+/*@-uniondef@*/
ticks = rpmswDiff(rpmswNow(&end), &begin);
+/*@=uniondef@*/
return ticks;
}
/* Start wall clock. */
rpmsw_type = 0;
+/*@-uniondef@*/
(void) rpmswNow(&begin);
+/*@=uniondef@*/
/* Get no. of cycles in 20ms nanosleep */
rpmsw_type = 1;
/* Compute wall clock delta in usecs. */
rpmsw_type = 0;
+/*@-uniondef@*/
usecs = rpmswDiff(rpmswNow(&end), &begin);
+/*@=uniondef@*/
rpmsw_type = 1;
#endif
/* Calculate timing overhead in usecs. */
+/*@-uniondef@*/
(void) rpmswNow(&begin);
usecs = rpmswDiff(rpmswNow(&end), &begin);
+/*@=uniondef@*/
rpmsw_overhead *= i;
rpmsw_overhead += usecs;
int rpmswEnter(rpmop op)
{
op->count++;
+/*@-uniondef@*/
(void) rpmswNow(&op->begin);
+/*@=uniondef@*/
return 0;
}
{
struct rpmsw_s end;
+/*@-uniondef@*/
op->usecs += rpmswDiff(rpmswNow(&end), &op->begin);
+/*@=uniondef@*/
if (rc > 0)
op->bytes += rc;
return 0;
/** Return benchmark time stamp overhead.
* @return overhead in micro-seconds
*/
+/*@-exportlocal@*/
rpmtime_t rpmswInit(void)
/*@globals internalState @*/
/*@modifes internalState @*/;
+/*@=exportlocal@*/
/** \ingroup rpmio
* Enter timed operation.