Splint clean.

CVS patchset: 6729
CVS date: 2003/04/02 21:16:26
This commit is contained in:
jbj 2003-04-02 21:16:26 +00:00
parent 1f366d6a00
commit 95f01d39a5
35 changed files with 414 additions and 166 deletions

View File

@ -63,7 +63,7 @@
extern int extern int
nanosleep (const struct timespec *__requested_time, nanosleep (const struct timespec *__requested_time,
/*@out@*/ /*@null@*/ struct timespec *__remaining) /*@out@*/ /*@null@*/ struct timespec *__remaining)
/*@modifies errno @*/; /*@modifies *__remaining, errno @*/;
extern void extern void
aio_init (const struct aioinit *__init) aio_init (const struct aioinit *__init)

View File

@ -15,7 +15,7 @@
typedef /*@abstract@*/ struct cpioSourceArchive_s { typedef /*@abstract@*/ struct cpioSourceArchive_s {
unsigned int cpioArchiveSize; unsigned int cpioArchiveSize;
FD_t cpioFdIn; FD_t cpioFdIn;
/*@refcounted@*/ /*@refcounted@*/ /*@relnull@*/
rpmfi cpioList; rpmfi cpioList;
/*@only@*/ /*@only@*/
struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */ struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */

View File

@ -202,7 +202,8 @@ uncompressgzipped(const unsigned char *old,
/*@=type@*/ /*@=type@*/
/*@=sizeoftype@*/ /*@=sizeoftype@*/
if (rc != Z_OK) { 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; return 0;
} }
@ -210,7 +211,8 @@ uncompressgzipped(const unsigned char *old,
rc = inflate(&z, Z_SYNC_FLUSH); rc = inflate(&z, Z_SYNC_FLUSH);
/*@=type@*/ /*@=type@*/
if (rc != Z_OK && rc != Z_STREAM_END) { 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; return 0;
} }

View File

@ -19,6 +19,8 @@
-redecl -redecl
-bufferoverflowhigh -bufferoverflowhigh
-nullpass
# --- +partial artifacts # --- +partial artifacts
-declundef -declundef
-exportheadervar -exportheadervar

View File

@ -376,7 +376,9 @@ static int unsatisfiedDepend(rpmts ts, rpmds dep, int adding)
memset(data, 0, sizeof(*data)); memset(data, 0, sizeof(*data));
data->data = datap; data->data = datap;
data->size = datalen; data->size = datalen;
/*@-nullstate@*/ /* FIX: data->data may be NULL */
xx = dbiGet(dbi, dbcursor, key, data, DB_SET); xx = dbiGet(dbi, dbcursor, key, data, DB_SET);
/*@=nullstate@*/
DNEVR = key->data; DNEVR = key->data;
DNEVRlen = key->size; DNEVRlen = key->size;
datap = data->data; datap = data->data;

View File

@ -244,7 +244,10 @@ static size_t xmlstrlen(const char * s)
size_t len = 0; size_t len = 0;
int c; int c;
while ((c = *s++) != '\0') { /*@-boundsread@*/
while ((c = *s++) != '\0')
/*@=boundsread@*/
{
switch (c) { switch (c) {
case '<': case '>': len += 4; /*@switchbreak@*/ break; case '<': case '>': len += 4; /*@switchbreak@*/ break;
case '&': len += 5; /*@switchbreak@*/ break; case '&': len += 5; /*@switchbreak@*/ break;
@ -262,6 +265,7 @@ static char * xmlstrcpy(/*@returned@*/ char * t, const char * s)
char * te = t; char * te = t;
int c; int c;
/*@-bounds@*/
while ((c = *s++) != '\0') { while ((c = *s++) != '\0') {
switch (c) { switch (c) {
case '<': te = stpcpy(te, "&lt;"); /*@switchbreak@*/ break; case '<': te = stpcpy(te, "&lt;"); /*@switchbreak@*/ break;
@ -271,6 +275,7 @@ static char * xmlstrcpy(/*@returned@*/ char * t, const char * s)
} }
} }
*te = '\0'; *te = '\0';
/*@=bounds@*/
return t; return t;
} }
@ -283,6 +288,7 @@ static char * xmlstrcpy(/*@returned@*/ char * t, const char * s)
* @param element (unused) * @param element (unused)
* @return formatted string * @return formatted string
*/ */
/*@-bounds@*/
static /*@only@*/ char * xmlFormat(int_32 type, const void * data, static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
char * formatPrefix, int padding, char * formatPrefix, int padding,
/*@unused@*/ int element) /*@unused@*/ int element)
@ -294,7 +300,9 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
const char * s = NULL; const char * s = NULL;
char * t, * te; char * t, * te;
unsigned long anint = 0; unsigned long anint = 0;
int xx;
/*@-branchstate@*/
switch (type) { switch (type) {
case RPM_I18NSTRING_TYPE: case RPM_I18NSTRING_TYPE:
case RPM_STRING_TYPE: case RPM_STRING_TYPE:
@ -303,9 +311,15 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
break; break;
case RPM_BIN_TYPE: case RPM_BIN_TYPE:
{ int cpl = b64encode_chars_per_line; { int cpl = b64encode_chars_per_line;
/*@-mods@*/
b64encode_chars_per_line = 0; b64encode_chars_per_line = 0;
/*@=mods@*/
/*@-formatconst@*/
s = base64Format(type, data, formatPrefix, padding, element); s = base64Format(type, data, formatPrefix, padding, element);
/*@=formatconst@*/
/*@-mods@*/
b64encode_chars_per_line = cpl; b64encode_chars_per_line = cpl;
/*@=mods@*/
xtag = "base64"; xtag = "base64";
} break; } break;
case RPM_CHAR_TYPE: case RPM_CHAR_TYPE:
@ -324,14 +338,17 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
return xstrdup(_("(invalid xml type)")); return xstrdup(_("(invalid xml type)"));
/*@notreached@*/ break; /*@notreached@*/ break;
} }
/*@=branchstate@*/
/*@-branchstate@*/
if (s == NULL) { if (s == NULL) {
int tlen = 32; int tlen = 32;
t = memset(alloca(tlen+1), 0, tlen+1); t = memset(alloca(tlen+1), 0, tlen+1);
snprintf(t, tlen, "%lu", anint); xx = snprintf(t, tlen, "%lu", anint);
s = t; s = t;
xtag = "integer"; xtag = "integer";
} }
/*@=branchstate@*/
nb = 2 * strlen(xtag) + sizeof("\t<></>") + xmlstrlen(s); nb = 2 * strlen(xtag) + sizeof("\t<></>") + xmlstrlen(s);
te = t = alloca(nb); te = t = alloca(nb);
@ -341,19 +358,24 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
te = stpcpy( stpcpy( stpcpy(te, "</"), xtag), ">"); te = stpcpy( stpcpy( stpcpy(te, "</"), xtag), ">");
/* XXX s was malloc'd */ /* XXX s was malloc'd */
/*@-branchstate@*/
if (!strcmp(xtag, "base64")) if (!strcmp(xtag, "base64"))
s = _free(s); s = _free(s);
/*@=branchstate@*/
nb += padding; nb += padding;
val = xmalloc(nb+1); val = xmalloc(nb+1);
/*@-boundswrite@*/ /*@-boundswrite@*/
strcat(formatPrefix, "s"); strcat(formatPrefix, "s");
/*@=boundswrite@*/ /*@=boundswrite@*/
snprintf(val, nb, formatPrefix, t); /*@-formatconst@*/
xx = snprintf(val, nb, formatPrefix, t);
/*@=formatconst@*/
val[nb] = '\0'; val[nb] = '\0';
return val; return val;
} }
/*@=bounds@*/
/** /**
* Display signature fingerprint and time. * Display signature fingerprint and time.

View File

@ -10,15 +10,18 @@
/*@-usereleased -onlytrans@*/ /*@-usereleased -onlytrans@*/
struct fsinfo { struct fsinfo {
/*@only@*/ const char * mntPoint; /*!< path to mount point. */ /*@only@*/ /*@relnull@*/
dev_t dev; /*!< devno for mount point. */ const char * mntPoint; /*!< path to mount point. */
int rdonly; /*!< is mount point read only? */ dev_t dev; /*!< devno for mount point. */
int rdonly; /*!< is mount point read only? */
}; };
/*@unchecked@*/ /*@unchecked@*/
/*@only@*/ /*@null@*/ static struct fsinfo * filesystems = NULL; /*@only@*/ /*@null@*/
static struct fsinfo * filesystems = NULL;
/*@unchecked@*/ /*@unchecked@*/
/*@only@*/ /*@null@*/ static const char ** fsnames = NULL; /*@only@*/ /*@null@*/
static const char ** fsnames = NULL;
/*@unchecked@*/ /*@unchecked@*/
static int numFilesystems = 0; static int numFilesystems = 0;
@ -236,7 +239,9 @@ static int getFilesystemList(void)
fsnames[numFilesystems] = NULL; fsnames[numFilesystems] = NULL;
/*@=boundswrite@*/ /*@=boundswrite@*/
/*@-nullstate@*/ /* FIX: fsnames[] may be NULL */
return 0; return 0;
/*@=nullstate@*/
} }
#endif /* HAVE_MNTCTL */ #endif /* HAVE_MNTCTL */

125
lib/fsm.c
View File

@ -9,7 +9,10 @@
#include <rpmlib.h> #include <rpmlib.h>
#include "cpio.h" #include "cpio.h"
#include "fsm.h" #include "fsm.h"
#define fsmUNSAFE fsmStage
#include "rpmerr.h" #include "rpmerr.h"
#define _RPMFI_INTERNAL #define _RPMFI_INTERNAL
@ -31,8 +34,11 @@
#define _FSM_DEBUG 0 #define _FSM_DEBUG 0
/*@unchecked@*/ /*@unchecked@*/
int _fsm_debug = _FSM_DEBUG; int _fsm_debug = _FSM_DEBUG;
/*@-exportheadervar@*/
/*@unchecked@*/ /*@unchecked@*/
int _fsm_threads = 0; int _fsm_threads = 0;
/*@=exportheadervar@*/
/* XXX Failure to remove is not (yet) cause for failure. */ /* XXX Failure to remove is not (yet) cause for failure. */
/*@-exportlocal -exportheadervar@*/ /*@-exportlocal -exportheadervar@*/
@ -246,7 +252,7 @@ static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/ const void * a)
/** \ingroup payload /** \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); return (dnli ? dnli->fi->dc : 0);
@ -254,7 +260,7 @@ static inline int dnlCount(const DNLI_t dnli)
/** \ingroup payload /** \ingroup payload
*/ */
static inline int dnlIndex(const DNLI_t dnli) static inline int dnlIndex(/*@null@*/ const DNLI_t dnli)
/*@*/ /*@*/
{ {
return (dnli ? dnli->isave : -1); return (dnli ? dnli->isave : -1);
@ -268,7 +274,8 @@ static inline int dnlIndex(const DNLI_t dnli)
*/ */
/*@-boundsread@*/ /*@-boundsread@*/
/*@-usereleased@*/ /*@-usereleased@*/
static /*@only@*/ void * dnlInitIterator(/*@special@*/ const FSM_t fsm, static /*@only@*/ /*@null@*/
void * dnlInitIterator(/*@special@*/ const FSM_t fsm,
int reverse) int reverse)
/*@uses fsm->iter @*/ /*@uses fsm->iter @*/
/*@*/ /*@*/
@ -357,7 +364,8 @@ static /*@only@*/ void * dnlInitIterator(/*@special@*/ const FSM_t fsm,
* @return next directory name * @return next directory name
*/ */
/*@-boundsread@*/ /*@-boundsread@*/
static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli) static /*@observer@*/ /*@null@*/
const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
/*@modifies dnli @*/ /*@modifies dnli @*/
{ {
const char * dn = NULL; const char * dn = NULL;
@ -382,14 +390,18 @@ static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
/*@=boundsread@*/ /*@=boundsread@*/
static void * fsmThread(void * arg) static void * fsmThread(void * arg)
/*@modifies arg @*/ /*@globals fileSystem, internalState @*/
/*@modifies arg, fileSystem, internalState @*/
{ {
FSM_t fsm = arg; FSM_t fsm = arg;
/*@-unqualifiedtrans@*/
return ((void *) fsmStage(fsm, fsm->nstage)); return ((void *) fsmStage(fsm, fsm->nstage));
/*@=unqualifiedtrans@*/
} }
int fsmNext(FSM_t fsm, fileStage nstage) int fsmNext(FSM_t fsm, fileStage nstage)
/*@modifies fsm @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, fileSystem, internalState @*/
{ {
fsm->nstage = nstage; fsm->nstage = nstage;
if (_fsm_threads) if (_fsm_threads)
@ -407,8 +419,8 @@ static int saveHardLink(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@uses fsm->links, fsm->ix, fsm->sb, fsm->goal, fsm->nsuffix @*/ /*@uses fsm->links, fsm->ix, fsm->sb, fsm->goal, fsm->nsuffix @*/
/*@defines fsm->li @*/ /*@defines fsm->li @*/
/*@releases fsm->path @*/ /*@releases fsm->path @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
struct stat * st = &fsm->sb; struct stat * st = &fsm->sb;
int rc = 0; int rc = 0;
@ -583,7 +595,9 @@ int fsmSetup(FSM_t fsm, fileStage goal,
*fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos); *fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos);
/*@=boundswrite@*/ /*@=boundswrite@*/
/*@-nullstate@*/ /* FIX: *fsm->failedFile may be NULL */
return ec; return ec;
/*@=nullstate@*/
} }
int fsmTeardown(FSM_t fsm) int fsmTeardown(FSM_t fsm)
@ -759,10 +773,11 @@ int fsmMapAttrs(FSM_t fsm)
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @return 0 on success
*/ */
/*@-compdef@*/
static int expandRegular(/*@special@*/ FSM_t fsm) static int expandRegular(/*@special@*/ FSM_t fsm)
/*@uses fsm->sb @*/ /*@uses fsm->fmd5sum, fsm->md5sum, fsm->sb, fsm->wfd @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const struct stat * st = &fsm->sb; const struct stat * st = &fsm->sb;
int left = st->st_size; int left = st->st_size;
@ -772,7 +787,7 @@ static int expandRegular(/*@special@*/ FSM_t fsm)
if (rc) if (rc)
goto exit; 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); fdInitDigest(fsm->wfd, PGPHASHALGO_MD5, 0);
while (left) { while (left) {
@ -819,6 +834,7 @@ exit:
(void) fsmNext(fsm, FSM_WCLOSE); (void) fsmNext(fsm, FSM_WCLOSE);
return rc; return rc;
} }
/*@=compdef@*/
/** \ingroup payload /** \ingroup payload
* Write next item to payload stream. * Write next item to payload stream.
@ -826,10 +842,11 @@ exit:
* @param writeData should data be written? * @param writeData should data be written?
* @return 0 on success * @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 @*/ /*@uses fsm->path, fsm->opath, fsm->sb, fsm->osb, fsm->cfd @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const char * path = fsm->path; const char * path = fsm->path;
const char * opath = fsm->opath; const char * opath = fsm->opath;
@ -859,7 +876,6 @@ static int writeFile(/*@special@*/ FSM_t fsm, int writeData)
/*@=branchstate@*/ /*@=branchstate@*/
if (fsm->mapFlags & CPIO_MAP_ABSOLUTE) { if (fsm->mapFlags & CPIO_MAP_ABSOLUTE) {
/*@-compdef@*/ /* FIX: dirName/baseName annotations ? */
/*@-boundswrite@*/ /*@-boundswrite@*/
int nb = strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof("."); int nb = strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof(".");
char * t = alloca(nb); char * t = alloca(nb);
@ -869,7 +885,6 @@ static int writeFile(/*@special@*/ FSM_t fsm, int writeData)
*t++ = '.'; *t++ = '.';
t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName); t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName);
/*@=boundswrite@*/ /*@=boundswrite@*/
/*@=compdef@*/
} else if (fsm->mapFlags & CPIO_MAP_PATH) { } else if (fsm->mapFlags & CPIO_MAP_PATH) {
rpmfi fi = fsmGetFi(fsm); rpmfi fi = fsmGetFi(fsm);
fsm->path = fsm->path =
@ -926,14 +941,18 @@ static int writeFile(/*@special@*/ FSM_t fsm, int writeData)
} }
#if HAVE_MMAP #if HAVE_MMAP
/*@-branchstate@*/
if (mapped != (void *)-1) { if (mapped != (void *)-1) {
xx = msync(mapped, nmapped, MS_ASYNC); xx = msync(mapped, nmapped, MS_ASYNC);
#if defined(MADV_DONTNEED) #if defined(MADV_DONTNEED)
xx = madvise(mapped, nmapped, MADV_DONTNEED); xx = madvise(mapped, nmapped, MADV_DONTNEED);
#endif #endif
/*@-noeffect@*/ xx = munmap(mapped, nmapped) /*@=noeffect@*/; /*@-noeffect@*/
xx = munmap(mapped, nmapped);
/*@=noeffect@*/
fsm->rdbuf = rdbuf; fsm->rdbuf = rdbuf;
} }
/*@=branchstate@*/
#endif #endif
} else if (writeData && S_ISLNK(st->st_mode)) { } else if (writeData && S_ISLNK(st->st_mode)) {
@ -954,22 +973,23 @@ static int writeFile(/*@special@*/ FSM_t fsm, int writeData)
exit: exit:
if (fsm->rfd != NULL) if (fsm->rfd != NULL)
(void) fsmNext(fsm, FSM_RCLOSE); (void) fsmNext(fsm, FSM_RCLOSE);
/*@-dependenttrans@*/ /*@-dependenttrans@*/
fsm->opath = opath; fsm->opath = opath;
fsm->path = path; fsm->path = path;
/*@=dependenttrans@*/ /*@=dependenttrans@*/
return rc; return rc;
} }
/*@=compdef =compmempass@*/
/** \ingroup payload /** \ingroup payload
* Write set of linked files to payload stream. * Write set of linked files to payload stream.
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @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 @*/ /*@uses fsm->path, fsm->nsuffix, fsm->ix, fsm->li, fsm->failedFile @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const char * path = fsm->path; const char * path = fsm->path;
const char * nsuffix = fsm->nsuffix; const char * nsuffix = fsm->nsuffix;
@ -983,12 +1003,15 @@ static int writeLinkedFile(/*@special@*/ FSM_t fsm)
fsm->ix = -1; fsm->ix = -1;
/*@-boundswrite@*/ /*@-boundswrite@*/
/*@-branchstate@*/
for (i = fsm->li->nlink - 1; i >= 0; i--) { for (i = fsm->li->nlink - 1; i >= 0; i--) {
if (fsm->li->filex[i] < 0) continue; if (fsm->li->filex[i] < 0) continue;
fsm->ix = fsm->li->filex[i]; fsm->ix = fsm->li->filex[i];
/*@-compdef@*/
rc = fsmNext(fsm, FSM_MAP); rc = fsmNext(fsm, FSM_MAP);
/*@=compdef@*/
/* Write data after last link. */ /* Write data after last link. */
rc = writeFile(fsm, (i == 0)); rc = writeFile(fsm, (i == 0));
@ -1000,6 +1023,7 @@ static int writeLinkedFile(/*@special@*/ FSM_t fsm)
fsm->path = _free(fsm->path); fsm->path = _free(fsm->path);
fsm->li->filex[i] = -1; fsm->li->filex[i] = -1;
} }
/*@=branchstate@*/
/*@=boundswrite@*/ /*@=boundswrite@*/
fsm->ix = iterIndex; fsm->ix = iterIndex;
@ -1014,10 +1038,11 @@ static int writeLinkedFile(/*@special@*/ FSM_t fsm)
* @return 0 on success * @return 0 on success
*/ */
/*@-boundsread@*/ /*@-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 @*/ /*@uses fsm->path, fsm->opath, fsm->nsuffix, fsm->ix, fsm->li @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const char * path = fsm->path; const char * path = fsm->path;
const char * opath = fsm->opath; const char * opath = fsm->opath;
@ -1071,6 +1096,7 @@ static int fsmMakeLinks(/*@special@*/ FSM_t fsm)
fsm->opath = opath; fsm->opath = opath;
return ec; return ec;
} }
/*@=compdef@*/
/*@=boundsread@*/ /*@=boundsread@*/
/** \ingroup payload /** \ingroup payload
@ -1078,11 +1104,12 @@ static int fsmMakeLinks(/*@special@*/ FSM_t fsm)
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @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, /*@uses fsm->path, fsm->nsuffix, fsm->ix, fsm->sb,
fsm->li, fsm->links @*/ fsm->li, fsm->links @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const char * path = fsm->path; const char * path = fsm->path;
const char * nsuffix = fsm->nsuffix; const char * nsuffix = fsm->nsuffix;
@ -1119,16 +1146,17 @@ static int fsmCommitLinks(/*@special@*/ FSM_t fsm)
fsm->path = path; fsm->path = path;
return rc; return rc;
} }
/*@=compdef@*/
/** /**
* Remove (if created) directories not explicitly included in package. * Remove (if created) directories not explicitly included in package.
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @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 @*/ /*@uses fsm->path, fsm->dnlx, fsm->ldn, fsm->rdbuf, fsm->iter @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
const char * path = fsm->path; const char * path = fsm->path;
void * dnli = dnlInitIterator(fsm, 1); void * dnli = dnlInitIterator(fsm, 1);
@ -1158,7 +1186,9 @@ static int fsmRmdirs(/*@special@*/ FSM_t fsm)
do { do {
if (*te == '/') { if (*te == '/') {
*te = '\0'; *te = '\0';
/*@-compdef@*/
rc = fsmNext(fsm, FSM_RMDIR); rc = fsmNext(fsm, FSM_RMDIR);
/*@=compdef@*/
*te = '/'; *te = '/';
} }
if (rc) if (rc)
@ -1180,12 +1210,12 @@ static int fsmRmdirs(/*@special@*/ FSM_t fsm)
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @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, /*@uses fsm->path, fsm->sb, fsm->osb, fsm->rdbuf, fsm->iter,
fsm->ldn, fsm->ldnlen, fsm->ldnalloc @*/ fsm->ldn, fsm->ldnlen, fsm->ldnalloc @*/
/*@defines fsm->dnlx, fsm->ldn @*/ /*@defines fsm->dnlx, fsm->ldn @*/
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
struct stat * st = &fsm->sb; struct stat * st = &fsm->sb;
struct stat * ost = &fsm->osb; struct stat * ost = &fsm->osb;
@ -1296,11 +1326,10 @@ static int fsmMkdirs(/*@special@*/ FSM_t fsm)
* @param fsm file state machine data * @param fsm file state machine data
* @return 0 on success * @return 0 on success
*/ */
static int fsmStat(FSM_t fsm) static int fsmStat(/*@special@*/ /*@partial@*/ FSM_t fsm)
/*@globals errno, fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/ /*@modifies fsm, fileSystem, internalState @*/
{ {
int saveerrno = errno;
int rc = 0; int rc = 0;
if (fsm->path != NULL) { if (fsm->path != NULL) {
@ -1526,7 +1555,9 @@ int fsmStage(FSM_t fsm, fileStage stage)
/* Detect and create directories not explicitly in package. */ /* Detect and create directories not explicitly in package. */
if (fsm->goal == FSM_PKGINSTALL) { if (fsm->goal == FSM_PKGINSTALL) {
/*@-compdef@*/
rc = fsmNext(fsm, FSM_MKDIRS); rc = fsmNext(fsm, FSM_MKDIRS);
/*@=compdef@*/
if (!rc) fsm->mkdirsdone = 1; if (!rc) fsm->mkdirsdone = 1;
} }
@ -1683,7 +1714,9 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
rc = fsmNext(fsm, FSM_RENAME); rc = fsmNext(fsm, FSM_RENAME);
if (!rc) if (!rc)
rpmMessage(RPMMESS_WARNING, 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->path = _free(fsm->path);
fsm->opath = opath; fsm->opath = opath;
} }
@ -1818,7 +1851,8 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
rc = fsmNext(fsm, FSM_RENAME); rc = fsmNext(fsm, FSM_RENAME);
if (!rc) { if (!rc) {
rpmMessage(RPMMESS_WARNING, _("%s saved as %s\n"), 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 = _free(fsm->path);
fsm->path = path; fsm->path = path;
@ -1887,7 +1921,8 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (!rc && fsm->nsuffix) { if (!rc && fsm->nsuffix) {
const char * opath = fsmFsPath(fsm, st, NULL, NULL); const char * opath = fsmFsPath(fsm, st, NULL, NULL);
rpmMessage(RPMMESS_WARNING, _("%s created as %s\n"), rpmMessage(RPMMESS_WARNING, _("%s created as %s\n"),
(opath ? opath : ""), fsm->path); (opath ? opath : ""),
(fsm->path ? fsm->path : ""));
opath = _free(opath); opath = _free(opath);
} }
fsm->opath = _free(fsm->opath); fsm->opath = _free(fsm->opath);
@ -2057,9 +2092,9 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
fsm->path, (rc < 0 ? strerror(errno) : "")); fsm->path, (rc < 0 ? strerror(errno) : ""));
if (rc < 0) if (rc < 0)
switch (errno) { switch (errno) {
case ENOENT: rc = CPIOERR_ENOENT; break; case ENOENT: rc = CPIOERR_ENOENT; /*@switchbreak@*/ break;
case ENOTEMPTY: rc = CPIOERR_ENOTEMPTY; break; case ENOTEMPTY: rc = CPIOERR_ENOTEMPTY; /*@switchbreak@*/ break;
default: rc = CPIOERR_RMDIR_FAILED; break; default: rc = CPIOERR_RMDIR_FAILED; /*@switchbreak@*/ break;
} }
break; break;
case FSM_CHOWN: case FSM_CHOWN:

View File

@ -93,9 +93,12 @@ typedef enum fileStage_e {
* Keeps track of the set of all hard links to a file in an archive. * Keeps track of the set of all hard links to a file in an archive.
*/ */
struct hardLink_s { struct hardLink_s {
/*@owned@*/ struct hardLink_s * next; /*@owned@*/ /*@relnull@*/
/*@owned@*/ const char ** nsuffix; struct hardLink_s * next;
/*@owned@*/ int * filex; /*@owned@*/
const char ** nsuffix;
/*@owned@*/
int * filex;
struct stat sb; struct stat sb;
int nlink; int nlink;
int linksLeft; int linksLeft;
@ -118,23 +121,25 @@ struct fsmIterator_s {
* File name and stat information. * File name and stat information.
*/ */
struct fsm_s { struct fsm_s {
/*@owned@*/ /*@owned@*/ /*@relnull@*/
const char * path; /*!< Current file name. */ const char * path; /*!< Current file name. */
/*@owned@*/ /*@owned@*/ /*@relnull@*/
const char * opath; /*!< Original file name. */ const char * opath; /*!< Original file name. */
/*@relnull@*/
FD_t cfd; /*!< Payload file handle. */ FD_t cfd; /*!< Payload file handle. */
/*@relnull@*/
FD_t rfd; /*!< read: File handle. */ FD_t rfd; /*!< read: File handle. */
/*@dependent@*/ /*@dependent@*/ /*@relnull@*/
char * rdbuf; /*!< read: Buffer. */ char * rdbuf; /*!< read: Buffer. */
/*@owned@*/ /*@owned@*/ /*@relnull@*/
char * rdb; /*!< read: Buffer allocated. */ char * rdb; /*!< read: Buffer allocated. */
size_t rdsize; /*!< read: Buffer allocated size. */ size_t rdsize; /*!< read: Buffer allocated size. */
size_t rdlen; /*!< read: Number of bytes requested.*/ size_t rdlen; /*!< read: Number of bytes requested.*/
size_t rdnb; /*!< read: Number of bytes returned. */ size_t rdnb; /*!< read: Number of bytes returned. */
FD_t wfd; /*!< write: File handle. */ FD_t wfd; /*!< write: File handle. */
/*@dependent@*/ /*@dependent@*/ /*@relnull@*/
char * wrbuf; /*!< write: Buffer. */ char * wrbuf; /*!< write: Buffer. */
/*@owned@*/ /*@owned@*/ /*@relnull@*/
char * wrb; /*!< write: Buffer allocated. */ char * wrb; /*!< write: Buffer allocated. */
size_t wrsize; /*!< write: Buffer allocated size. */ size_t wrsize; /*!< write: Buffer allocated size. */
size_t wrlen; /*!< write: Number of bytes requested.*/ size_t wrlen; /*!< write: Number of bytes requested.*/
@ -142,23 +147,23 @@ struct fsm_s {
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
FSMI_t iter; /*!< File iterator. */ FSMI_t iter; /*!< File iterator. */
int ix; /*!< Current file iterator index. */ int ix; /*!< Current file iterator index. */
/*@only@*/ /*@only@*/ /*@relnull@*/
struct hardLink_s * links; /*!< Pending hard linked file(s). */ struct hardLink_s * links; /*!< Pending hard linked file(s). */
/*@only@*/ /*@only@*/ /*@relnull@*/
struct hardLink_s * li; /*!< Current hard linked file(s). */ struct hardLink_s * li; /*!< Current hard linked file(s). */
/*@kept@*/ /*@null@*/ /*@kept@*/ /*@null@*/
unsigned int * archiveSize; /*!< Pointer to archive size. */ unsigned int * archiveSize; /*!< Pointer to archive size. */
/*@kept@*/ /*@null@*/ /*@kept@*/ /*@null@*/
const char ** failedFile; /*!< First file name that failed. */ const char ** failedFile; /*!< First file name that failed. */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * subdir; /*!< Current file sub-directory. */ const char * subdir; /*!< Current file sub-directory. */
/*@unused@*/ /*@unused@*/
char subbuf[64]; /* XXX eliminate */ char subbuf[64]; /* XXX eliminate */
/*@observer@*/ /*@observer@*/ /*@relnull@*/
const char * osuffix; /*!< Old, preserved, file suffix. */ const char * osuffix; /*!< Old, preserved, file suffix. */
/*@observer@*/ /*@observer@*/ /*@relnull@*/
const char * nsuffix; /*!< New, created, file suffix. */ const char * nsuffix; /*!< New, created, file suffix. */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * suffix; /*!< Current file suffix. */ const char * suffix; /*!< Current file suffix. */
char sufbuf[64]; /* XXX eliminate */ char sufbuf[64]; /* XXX eliminate */
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
@ -175,13 +180,13 @@ struct fsm_s {
int rc; /*!< External file stage return code. */ int rc; /*!< External file stage return code. */
int commit; /*!< Commit synchronously? */ int commit; /*!< Commit synchronously? */
cpioMapFlags mapFlags; /*!< Bit(s) to control mapping. */ cpioMapFlags mapFlags; /*!< Bit(s) to control mapping. */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * dirName; /*!< File directory name. */ const char * dirName; /*!< File directory name. */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * baseName; /*!< File base name. */ const char * baseName; /*!< File base name. */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * fmd5sum; /*!< Hex MD5 sum (NULL disables). */ const char * fmd5sum; /*!< Hex MD5 sum (NULL disables). */
/*@shared@*/ /*@shared@*/ /*@relnull@*/
const char * md5sum; /*!< Binary MD5 sum (NULL disables). */ const char * md5sum; /*!< Binary MD5 sum (NULL disables). */
unsigned fflags; /*!< File flags. */ unsigned fflags; /*!< File flags. */
@ -215,14 +220,14 @@ extern "C" {
/** /**
* Create file state machine instance. * Create file state machine instance.
* @return file state machine data * @return file state machine
*/ */
/*@only@*/ FSM_t newFSM(void) /*@only@*/ FSM_t newFSM(void)
/*@*/; /*@*/;
/** /**
* Destroy file state machine instance. * Destroy file state machine instance.
* @param fsm file state machine data * @param fsm file state machine
* @return always NULL * @return always NULL
*/ */
/*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm) /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
@ -231,7 +236,7 @@ extern "C" {
/** /**
* Load external data into file state machine. * Load external data into file state machine.
* @param fsm file state machine data * @param fsm file state machine
* @param goal * @param goal
* @param ts transaction set * @param ts transaction set
* @param fi transaction element file info * @param fi transaction element file info
@ -252,7 +257,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
/** /**
* Clean file state machine. * Clean file state machine.
* @param fsm file state machine data * @param fsm file state machine
* @return 0 on success * @return 0 on success
*/ */
int fsmTeardown(FSM_t fsm) int fsmTeardown(FSM_t fsm)
@ -262,7 +267,7 @@ int fsmTeardown(FSM_t fsm)
/*@-exportlocal@*/ /*@-exportlocal@*/
/** /**
* Retrieve transaction set from file state machine iterator. * Retrieve transaction set from file state machine iterator.
* @param fsm file state machine data * @param fsm file state machine
* @return transaction set * @return transaction set
*/ */
rpmts fsmGetTs(const FSM_t fsm) rpmts fsmGetTs(const FSM_t fsm)
@ -270,7 +275,7 @@ rpmts fsmGetTs(const FSM_t fsm)
/** /**
* Retrieve transaction element file info from file state machine iterator. * 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 * @return transaction element file info
*/ */
rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm) rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
@ -278,32 +283,40 @@ rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
/** /**
* Map next file path and action. * Map next file path and action.
* @param fsm file state machine data * @param fsm file state machine
*/ */
int fsmMapPath(FSM_t fsm) int fsmMapPath(FSM_t fsm)
/*@modifies fsm @*/; /*@modifies fsm @*/;
/** /**
* Map file stat(2) info. * Map file stat(2) info.
* @param fsm file state machine data * @param fsm file state machine
*/ */
int fsmMapAttrs(FSM_t fsm) int fsmMapAttrs(FSM_t fsm)
/*@modifies fsm @*/; /*@modifies fsm @*/;
/*@=exportlocal@*/ /*@=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) int fsmNext(FSM_t fsm, fileStage nstage)
/*@modifies fsm @*/; /*@globals errno, fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/;
/** /**
* File state machine driver. * File state machine driver.
* @param fsm file state machine data * @param fsm file state machine
* @param stage next stage * @param stage next stage
* @return 0 on success * @return 0 on success
*/ */
/*@-exportlocal@*/
int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage) int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
/*@globals errno, fileSystem, internalState @*/ /*@globals errno, fileSystem, internalState @*/
/*@modifies fsm, errno, fileSystem, internalState @*/; /*@modifies fsm, errno, fileSystem, internalState @*/;
#define fsmUNSAFE fsmStage /*@=exportlocal@*/
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -84,7 +84,9 @@ char ** splitString(const char * str, int length, char sep)
list[i] = NULL; list[i] = NULL;
/*@-nullret@*/ /* FIX: list[i] is NULL */
return list; return list;
/*@=nullret@*/
} }
/*@=bounds@*/ /*@=bounds@*/
@ -346,11 +348,15 @@ if (_debug)
fprintf(stderr, "*** GLOB maxb %d diskURL %d %*s globURL %p %s\n", (int)maxb, (int)nb, (int)nb, av[j], globURL, globURL); fprintf(stderr, "*** GLOB maxb %d diskURL %d %*s globURL %p %s\n", (int)maxb, (int)nb, (int)nb, av[j], globURL, globURL);
/*@-branchstate@*/ /*@-branchstate@*/
#ifdef DYING
if (argc == 0) if (argc == 0)
argv = xmalloc((gl.gl_pathc+1) * sizeof(*argv)); argv = xmalloc((gl.gl_pathc+1) * sizeof(*argv));
else if (gl.gl_pathc > 0) else if (gl.gl_pathc > 0)
#endif
argv = xrealloc(argv, (argc+gl.gl_pathc+1) * sizeof(*argv)); argv = xrealloc(argv, (argc+gl.gl_pathc+1) * sizeof(*argv));
/*@=branchstate@*/ /*@=branchstate@*/
if (argv != NULL)
for (i = 0; i < gl.gl_pathc; i++) { for (i = 0; i < gl.gl_pathc; i++) {
const char * globFile = &(gl.gl_pathv[i][0]); const char * globFile = &(gl.gl_pathv[i][0]);
if (globRoot > globURL && globRoot[-1] == '/') if (globRoot > globURL && globRoot[-1] == '/')
@ -378,12 +384,16 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
exit: exit:
av = _free(av); av = _free(av);
/*@-branchstate@*/
if (rc || argvPtr == NULL) { if (rc || argvPtr == NULL) {
/*@-dependenttrans -unqualifiedtrans@*/
if (argv != NULL) if (argv != NULL)
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
argv[i] = _free(argv[i]); argv[i] = _free(argv[i]);
argv = _free(argv); argv = _free(argv);
/*@=dependenttrans =unqualifiedtrans@*/
} }
/*@=branchstate@*/
return rc; return rc;
} }

View File

@ -29,6 +29,8 @@ extern int _fps_debug;
/*@unchecked@*/ /*@unchecked@*/
extern int _fsm_debug; extern int _fsm_debug;
/*@unchecked@*/
extern int _fsm_threads; extern int _fsm_threads;
/*@unchecked@*/ /*@unchecked@*/
@ -36,6 +38,8 @@ extern int _hdr_debug;
/*@unchecked@*/ /*@unchecked@*/
extern int _psm_debug; extern int _psm_debug;
/*@unchecked@*/
extern int _psm_threads; extern int _psm_threads;
/*@unchecked@*/ /*@unchecked@*/

View File

@ -58,11 +58,11 @@ int rpmVersionCompare(Header first, Header second)
NULL)) NULL))
epochTwo = NULL; epochTwo = NULL;
if (epochOne && !epochTwo) if (epochOne != NULL && epochTwo == NULL)
return 1; return 1;
else if (!epochOne && epochTwo) else if (epochOne == NULL && epochTwo != NULL)
return -1; return -1;
else if (epochOne && epochTwo) { else if (epochOne != NULL && epochTwo != NULL) {
/*@-boundsread@*/ /*@-boundsread@*/
if (*epochOne < *epochTwo) if (*epochOne < *epochTwo)
return -1; return -1;
@ -285,6 +285,11 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
/*@-onlytrans@*/ /* FIX: te reference */ /*@-onlytrans@*/ /* FIX: te reference */
fi->te = rpmtsElement(ts, 0); fi->te = rpmtsElement(ts, 0);
/*@=onlytrans@*/ /*@=onlytrans@*/
if (fi->te == NULL) { /* XXX can't happen */
rc = RPMRC_FAIL;
goto exit;
}
/*@-nullpass@*/ /* FIX fi->h may be null */ /*@-nullpass@*/ /* FIX fi->h may be null */
fi->te->h = headerLink(fi->h); fi->te->h = headerLink(fi->h);
/*@=nullpass@*/ /*@=nullpass@*/
@ -585,6 +590,7 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln,
} }
maxPrefixLength = 0; maxPrefixLength = 0;
if (prefixes != NULL)
for (i = 0; i < numPrefixes; i++) { for (i = 0; i < numPrefixes; i++) {
len = strlen(prefixes[i]); len = strlen(prefixes[i]);
if (len > maxPrefixLength) maxPrefixLength = len; if (len > maxPrefixLength) maxPrefixLength = len;
@ -597,7 +603,7 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln,
/*@-branchstate@*/ /*@-branchstate@*/
if (makeTempFile((!rpmtsChrootDone(ts) ? rootDir : "/"), &fn, &fd)) { if (makeTempFile((!rpmtsChrootDone(ts) ? rootDir : "/"), &fn, &fd)) {
if (freePrefixes) free(prefixes); if (prefixes != NULL && freePrefixes) free(prefixes);
return RPMRC_FAIL; return RPMRC_FAIL;
} }
/*@=branchstate@*/ /*@=branchstate@*/
@ -694,6 +700,7 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln,
/*@=modobserver@*/ /*@=modobserver@*/
} }
if (prefixes != NULL)
for (i = 0; i < numPrefixes; i++) { for (i = 0; i < numPrefixes; i++) {
sprintf(prefixBuf, "RPM_INSTALL_PREFIX%d=%s", i, prefixes[i]); sprintf(prefixBuf, "RPM_INSTALL_PREFIX%d=%s", i, prefixes[i]);
xx = doputenv(prefixBuf); xx = doputenv(prefixBuf);
@ -725,7 +732,9 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln,
psm->stepName, sln, n, v, r, psm->stepName, sln, n, v, r,
argv[0], (unsigned)getpid()); argv[0], (unsigned)getpid());
unsetenv("MALLOC_CHECK_"); unsetenv("MALLOC_CHECK_");
/*@-nullstate@*/
xx = execv(argv[0], (char *const *)argv); xx = execv(argv[0], (char *const *)argv);
/*@=nullstate@*/
break; break;
default: default:
break; break;
@ -944,7 +953,7 @@ static rpmRC runTriggers(rpmpsm psm)
if (numPackage < 0) if (numPackage < 0)
return RPMRC_NOTFOUND; return RPMRC_NOTFOUND;
if (fi->h != NULL) /* XXX can't happen */ if (fi != NULL && fi->h != NULL) /* XXX can't happen */
{ Header triggeredH; { Header triggeredH;
rpmdbMatchIterator mi; rpmdbMatchIterator mi;
int countCorrection = psm->countCorrection; int countCorrection = psm->countCorrection;
@ -1133,14 +1142,18 @@ rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
} }
static void * rpmpsmThread(void * arg) static void * rpmpsmThread(void * arg)
/*@modifies psm @*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies arg, rpmGlobalMacroContext, fileSystem, internalState @*/
{ {
rpmpsm psm = arg; rpmpsm psm = arg;
/*@-unqualifiedtrans@*/
return ((void *) rpmpsmStage(psm, psm->nstage)); return ((void *) rpmpsmStage(psm, psm->nstage));
/*@=unqualifiedtrans@*/
} }
static int rpmpsmNext(rpmpsm psm, pkgStage nstage) static int rpmpsmNext(rpmpsm psm, pkgStage nstage)
/*@modifies psm @*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/
{ {
psm->nstage = nstage; psm->nstage = nstage;
if (_psm_threads) if (_psm_threads)

View File

@ -68,9 +68,11 @@ struct rpmpsm_s {
rpmts ts; /*!< transaction set */ rpmts ts; /*!< transaction set */
/*@dependent@*/ /*@null@*/ /*@dependent@*/ /*@null@*/
rpmte te; /*!< current transaction element */ rpmte te; /*!< current transaction element */
/*@refcounted@*/ /*@refcounted@*/ /*@relnull@*/
rpmfi fi; /*!< transaction element file info */ rpmfi fi; /*!< transaction element file info */
/*@relnull@*/
FD_t cfd; /*!< Payload file handle. */ FD_t cfd; /*!< Payload file handle. */
/*@relnull@*/
FD_t fd; /*!< Repackage file handle. */ FD_t fd; /*!< Repackage file handle. */
Header oh; /*!< Repackage header. */ Header oh; /*!< Repackage header. */
/*@null@*/ /*@null@*/
@ -136,13 +138,13 @@ rpmpsm XrpmpsmUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmpsm psm,
* @param msg * @param msg
* @return new package state machine reference * @return new package state machine reference
*/ */
/*@unused@*/ /*@newref@*/ /*@unused@*/ /*@newref@*/ /*@null@*/
rpmpsm rpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg) rpmpsm rpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg)
/*@modifies psm @*/; /*@modifies psm @*/;
/** @todo Remove debugging entry from the ABI. */ /** @todo Remove debugging entry from the ABI. */
/*@-exportlocal@*/ /*@-exportlocal@*/
/*@newref@*/ /*@newref@*/ /*@null@*/
rpmpsm XrpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg, rpmpsm XrpmpsmLink (/*@null@*/ rpmpsm psm, /*@null@*/ const char * msg,
const char * fn, unsigned ln) const char * fn, unsigned ln)
/*@modifies psm @*/; /*@modifies psm @*/;
@ -166,6 +168,7 @@ rpmpsm rpmpsmFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmpsm psm)
* @param fi file info set * @param fi file info set
* @return new package state machine * @return new package state machine
*/ */
/*@null@*/
rpmpsm rpmpsmNew(rpmts ts, /*@null@*/ rpmte te, rpmfi fi) rpmpsm rpmpsmNew(rpmts ts, /*@null@*/ rpmte te, rpmfi fi)
/*@modifies ts, fi @*/; /*@modifies ts, fi @*/;

View File

@ -480,7 +480,9 @@ restart:
} }
/* Read list of packages from manifest. */ /* Read list of packages from manifest. */
/*@-nullstate@*/ /* FIX: *av may be NULL */
res = rpmReadPackageManifest(fd, &ac, &av); res = rpmReadPackageManifest(fd, &ac, &av);
/*@=nullstate@*/
if (res != RPMRC_OK) { if (res != RPMRC_OK) {
rpmError(RPMERR_MANIFEST, rpmError(RPMERR_MANIFEST,
_("%s: not an rpm package (or package manifest): %s\n"), _("%s: not an rpm package (or package manifest): %s\n"),

View File

@ -27,8 +27,9 @@ static int _print_pkts = 0;
/** /**
*/ */
/*@-boundsread@*/ /*@-boundsread@*/
static int manageFile(FD_t *fdp, const char **fnp, int flags, static int manageFile(/*@out@*/ FD_t *fdp,
/*@unused@*/ int rc) /*@null@*/ /*@out@*/ const char **fnp,
int flags, /*@unused@*/ int rc)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies *fdp, *fnp, rpmGlobalMacroContext, /*@modifies *fdp, *fnp, rpmGlobalMacroContext,
fileSystem, internalState @*/ fileSystem, internalState @*/
@ -36,9 +37,8 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags,
const char *fn; const char *fn;
FD_t fd; FD_t fd;
if (fdp == NULL) { /* programmer error */ if (fdp == NULL) /* programmer error */
return 1; return 1;
}
/*@-boundswrite@*/ /*@-boundswrite@*/
/* close and reset *fdp to NULL */ /* close and reset *fdp to NULL */
@ -49,7 +49,7 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags,
} }
/* open a file and set *fdp */ /* 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")); fd = Fopen(*fnp, ((flags & O_WRONLY) ? "w.ufdio" : "r.ufdio"));
if (fd == NULL || Ferror(fd)) { if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_OPEN, _("%s: open failed: %s\n"), *fnp, rpmError(RPMERR_OPEN, _("%s: open failed: %s\n"), *fnp,
@ -67,7 +67,7 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags,
rpmError(RPMERR_MAKETEMP, _("makeTempFile failed\n")); rpmError(RPMERR_MAKETEMP, _("makeTempFile failed\n"));
return 1; return 1;
} }
if (fnp) if (fnp != NULL)
*fnp = fn; *fnp = fn;
*fdp = fdLink(fd, "manageFile return"); *fdp = fdLink(fd, "manageFile return");
fd = fdFree(fd, "manageFile return"); fd = fdFree(fd, "manageFile return");
@ -76,9 +76,8 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags,
/*@=boundswrite@*/ /*@=boundswrite@*/
/* no operation */ /* no operation */
if (*fdp && fnp && *fnp) { if (*fdp != NULL && fnp != NULL && *fnp != NULL)
return 0; return 0;
}
/* XXX never reached */ /* XXX never reached */
return 1; return 1;

View File

@ -605,10 +605,13 @@ assert(argv[ac] != NULL);
t = stpcpy(t, argv[ac]) + 1; t = stpcpy(t, argv[ac]) + 1;
} }
av[ac] = NULL; av[ac] = NULL;
/*@-nullret@*/
return av; return av;
/*@=nullret@*/
} }
/*@=bounds@*/ /*@=bounds@*/
/*@null@*/
static rpmds rpmdsDup(const rpmds ods) static rpmds rpmdsDup(const rpmds ods)
/*@modifies ods @*/ /*@modifies ods @*/
{ {
@ -707,6 +710,8 @@ int save;
} }
/*@=branchstate@*/ /*@=branchstate@*/
ds = *dsp; ds = *dsp;
if (ds == NULL)
return -1;
/* /*
* Add new entries. * Add new entries.

View File

@ -85,12 +85,12 @@ rpmds XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds,
* @param msg * @param msg
* @return new dependency set reference * @return new dependency set reference
*/ */
/*@unused@*/ /*@newref@*/ /*@unused@*/ /*@newref@*/ /*@null@*/
rpmds rpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg) rpmds rpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg)
/*@modifies ds @*/; /*@modifies ds @*/;
/** @todo Remove debugging entry from the ABI. */ /** @todo Remove debugging entry from the ABI. */
/*@newref@*/ /*@newref@*/ /*@null@*/
rpmds XrpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg, rpmds XrpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg,
const char * fn, unsigned ln) const char * fn, unsigned ln)
/*@modifies ds @*/; /*@modifies ds @*/;

View File

@ -734,6 +734,9 @@ assert(p != NULL);
fn = xrealloc(fn, fileAlloced); fn = xrealloc(fn, fileAlloced);
} }
/*@=branchstate@*/ /*@=branchstate@*/
if (fn == NULL) /* XXX can't happen */
continue;
*fn = '\0'; *fn = '\0';
fnlen = stpcpy( stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn; fnlen = stpcpy( stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn;
@ -766,7 +769,9 @@ assert(p != NULL);
} }
if (j < 0) continue; if (j < 0) continue;
/*@-nullderef@*/ /* FIX: fModes may be NULL */
ft = whatis(fModes[i]); ft = whatis(fModes[i]);
/*@=nullderef@*/
/* On install, a relocate to NULL means skip the path. */ /* On install, a relocate to NULL means skip the path. */
if (relocations[j].newPath == NULL) { if (relocations[j].newPath == NULL) {
@ -928,7 +933,9 @@ assert(p != NULL);
baseNames = hfd(baseNames, RPM_STRING_ARRAY_TYPE); baseNames = hfd(baseNames, RPM_STRING_ARRAY_TYPE);
dirNames = hfd(dirNames, RPM_STRING_ARRAY_TYPE); dirNames = hfd(dirNames, RPM_STRING_ARRAY_TYPE);
/*@-dependenttrans@*/
fn = _free(fn); fn = _free(fn);
/*@=dependenttrans@*/
return h; return h;
} }

View File

@ -44,9 +44,9 @@ struct rpmfi_s {
/*@only@*/ /*?null?*/ /*@only@*/ /*?null?*/
const char ** dnl; /*!< Directory name(s) (from header) */ const char ** dnl; /*!< Directory name(s) (from header) */
/*@only@*/ /*?null?*/ /*@only@*/ /*@relnull@*/
const char ** fmd5s; /*!< File MD5 sum(s) (from header) */ const char ** fmd5s; /*!< File MD5 sum(s) (from header) */
/*@only@*/ /*?null?*/ /*@only@*/ /*@relnull@*/
const char ** flinks; /*!< File link(s) (from header) */ const char ** flinks; /*!< File link(s) (from header) */
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
const char ** flangs; /*!< File lang(s) (from header) */ const char ** flangs; /*!< File lang(s) (from header) */
@ -102,7 +102,7 @@ struct rpmfi_s {
int_32 fc; /*!< No. of files. */ int_32 fc; /*!< No. of files. */
/*=============================*/ /*=============================*/
/*@dependent@*/ /*@dependent@*/ /*@relnull@*/
rpmte te; rpmte te;
HGE_t hge; /*!< Vector to headerGetEntry() */ HGE_t hge; /*!< Vector to headerGetEntry() */
@ -115,7 +115,7 @@ struct rpmfi_s {
gid_t gid; /*!< File gid (default). */ gid_t gid; /*!< File gid (default). */
uint_32 flags; /*!< File flags (default). */ uint_32 flags; /*!< File flags (default). */
fileAction action; /*!< File disposition (default). */ fileAction action; /*!< File disposition (default). */
/*@owned@*/ /*@owned@*/ /*@relnull@*/
fileAction * actions; /*!< File disposition(s). */ fileAction * actions; /*!< File disposition(s). */
/*@owned@*/ /*@owned@*/
struct fingerPrint_s * fps; /*!< File fingerprint(s). */ struct fingerPrint_s * fps; /*!< File fingerprint(s). */
@ -126,7 +126,7 @@ struct rpmfi_s {
/*@unused@*/ /*@unused@*/
int_32 * odil; /*!< Original dirindex(s) (from header) */ int_32 * odil; /*!< Original dirindex(s) (from header) */
/*@only@*/ /*@only@*/ /*@relnull@*/
unsigned char * md5s; /*!< File md5 sums in binary. */ unsigned char * md5s; /*!< File md5 sums in binary. */
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
@ -197,7 +197,7 @@ rpmfi XrpmfiUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmfi fi,
* @param msg * @param msg
* @return new file info set reference * @return new file info set reference
*/ */
/*@unused@*/ /*@unused@*/ /*@null@*/
rpmfi rpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg) rpmfi rpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg)
/*@modifies fi @*/; /*@modifies fi @*/;
@ -208,6 +208,7 @@ rpmfi rpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg)
* @param ln * @param ln
* @return NULL always * @return NULL always
*/ */
/*@null@*/
rpmfi XrpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg, rpmfi XrpmfiLink (/*@null@*/ rpmfi fi, /*@null@*/ const char * msg,
const char * fn, unsigned ln) const char * fn, unsigned ln)
/*@modifies fi @*/; /*@modifies fi @*/;

View File

@ -601,7 +601,9 @@ maybe_manifest:
} }
/* Read list of packages from manifest. */ /* Read list of packages from manifest. */
/*@-nullstate@*/ /* FIX: *eiu->argv can be NULL */
rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv); rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
/*@=nullstate@*/
if (rc != RPMRC_OK) if (rc != RPMRC_OK)
rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"), rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"),
*eiu->fnp, Fstrerror(eiu->fd)); *eiu->fnp, Fstrerror(eiu->fd));
@ -1024,7 +1026,7 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
tidp = NULL; tidp = NULL;
/*@-branchstate@*/ /*@-branchstate@*/
if (hge(h, tag, &type, (void **) &tidp, &count) && tidp) { if (hge(h, tag, &type, (void **) &tidp, &count) && tidp != NULL) {
idtx = IDTXgrow(idtx, 1); idtx = IDTXgrow(idtx, 1);
if (idtx == NULL || idtx->idt == NULL) if (idtx == NULL || idtx->idt == NULL)

View File

@ -28,7 +28,7 @@ const char * macrofiles = MACROFILES;
/*@observer@*/ /*@unchecked@*/ /*@observer@*/ /*@unchecked@*/
static const char * platform = "/etc/rpm/platform"; static const char * platform = "/etc/rpm/platform";
/*@only@*/ /*@relnul@*/ /*@unchecked@*/ /*@only@*/ /*@relnull@*/ /*@unchecked@*/
static const char ** platpat = NULL; static const char ** platpat = NULL;
/*@unchecked@*/ /*@unchecked@*/
static int nplatpat = 0; static int nplatpat = 0;

View File

@ -574,7 +574,7 @@ fprintf(stderr, "*** tsi %p ++ %s:%d\n", tsi, fn, ln);
* @param tsi transaction element iterator * @param tsi transaction element iterator
* @return transaction element, NULL on termination * @return transaction element, NULL on termination
*/ */
static /*@dependent@*/ /*@null@*/ static /*@null@*/ /*@dependent@*/
rpmte rpmtsiNextElement(rpmtsi tsi) rpmte rpmtsiNextElement(rpmtsi tsi)
/*@modifies tsi @*/ /*@modifies tsi @*/
{ {

View File

@ -59,7 +59,7 @@ struct tsortInfo_s {
struct rpmte_s { struct rpmte_s {
rpmElementType type; /*!< Package disposition (installed/removed). */ rpmElementType type; /*!< Package disposition (installed/removed). */
/*@refcounted@*/ /*@null@*/ /*@refcounted@*/ /*@relnull@*/
Header h; /*!< Package header. */ Header h; /*!< Package header. */
/*@only@*/ /*@only@*/
const char * NEVR; /*!< Package name-version-release. */ const char * NEVR; /*!< Package name-version-release. */
@ -324,6 +324,7 @@ rpmte rpmteParent(rpmte te)
* @param pte new parent transaction element * @param pte new parent transaction element
* @return previous parent transaction element * @return previous parent transaction element
*/ */
/*@null@*/
rpmte rpmteSetParent(rpmte te, rpmte pte) rpmte rpmteSetParent(rpmte te, rpmte pte)
/*@modifies te @*/; /*@modifies te @*/;

View File

@ -115,6 +115,7 @@ struct rpmts_s {
/*@null@*/ /*@null@*/
int (*solve) (rpmts ts, rpmds key, const void * data) int (*solve) (rpmts ts, rpmds key, const void * data)
/*@modifies ts @*/; /*!< Search for NEVRA key. */ /*@modifies ts @*/; /*!< Search for NEVRA key. */
/*@relnull@*/
const void * solveData; /*!< Solve callback data */ const void * solveData; /*!< Solve callback data */
int nsuggests; /*!< No. of depCheck suggestions. */ int nsuggests; /*!< No. of depCheck suggestions. */
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
@ -722,8 +723,9 @@ int rpmtsNElements(rpmts ts)
* Return (ordered) transaction set element. * Return (ordered) transaction set element.
* @param ts transaction set * @param ts transaction set
* @param ix transaction element index * @param ix transaction element index
* @return transaction element * @return transaction element (or NULL)
*/ */
/*@null@*/ /*@dependent@*/
rpmte rpmtsElement(rpmts ts, int ix) rpmte rpmtsElement(rpmts ts, int ix)
/*@*/; /*@*/;
@ -829,8 +831,8 @@ int rpmtsSetNotifyCallback(rpmts ts,
*/ */
/*@newref@*/ /*@newref@*/
rpmts rpmtsCreate(void) rpmts rpmtsCreate(void)
/*@globals rpmGlobalMacroContext @*/ /*@globals rpmGlobalMacroContext, internalState @*/
/*@modifies rpmGlobalMacroContext @*/; /*@modifies rpmGlobalMacroContext, internalState @*/;
/** \ingroup rpmts /** \ingroup rpmts
* Add package to be installed to transaction set. * Add package to be installed to transaction set.

View File

@ -864,7 +864,7 @@ static void skipFiles(const rpmts ts, rpmfi fi)
/* /*
* Skip i18n language specific files. * 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; const char **lang, *l, *le;
for (lang = languages; *lang != NULL; lang++) { for (lang = languages; *lang != NULL; lang++) {
if (!strcmp(*lang, "all")) if (!strcmp(*lang, "all"))
@ -957,11 +957,13 @@ static void skipFiles(const rpmts ts, rpmfi fi)
} }
} }
/*@-dependenttrans@*/
if (netsharedPaths) freeSplitString(netsharedPaths); if (netsharedPaths) freeSplitString(netsharedPaths);
#ifdef DYING /* XXX freeFi will deal with this later. */ #ifdef DYING /* XXX freeFi will deal with this later. */
fi->flangs = _free(fi->flangs); fi->flangs = _free(fi->flangs);
#endif #endif
if (languages) freeSplitString((char **)languages); if (languages) freeSplitString((char **)languages);
/*@=dependenttrans@*/
} }
/*@=bounds@*/ /*@=bounds@*/
/*@=mustmod@*/ /*@=mustmod@*/
@ -1464,6 +1466,7 @@ ts->ms_repackage += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
continue; /* XXX can't happen */ continue; /* XXX can't happen */
psm = rpmpsmNew(ts, p, fi); psm = rpmpsmNew(ts, p, fi);
assert(psm != NULL);
psm->unorderedSuccessor = psm->unorderedSuccessor =
(rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0); (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
@ -1524,7 +1527,9 @@ ts->ms_repackage += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
fi->fstates = NULL; fi->fstates = NULL;
fi->actions = NULL; fi->actions = NULL;
/*@-nullstate@*/ /* FIX: fi->actions is NULL */
fi = rpmfiFree(fi); fi = rpmfiFree(fi);
/*@=nullstate@*/
savep = rpmtsSetRelocateElement(ts, p); savep = rpmtsSetRelocateElement(ts, p);
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1); fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);

View File

@ -224,6 +224,9 @@ static int rpmVerifyScript(/*@unused@*/ QVA_t qva, rpmts ts,
rpmpsm psm = rpmpsmNew(ts, NULL, fi); rpmpsm psm = rpmpsmNew(ts, NULL, fi);
int rc = 0; int rc = 0;
if (psm == NULL) /* XXX can't happen */
return rc;
if (scriptFd != NULL) if (scriptFd != NULL)
rpmtsSetScriptFd(psm->ts, scriptFd); rpmtsSetScriptFd(psm->ts, scriptFd);

View File

@ -35,7 +35,8 @@ struct DIGEST_CTX_s {
DIGEST_CTX DIGEST_CTX
rpmDigestDup(DIGEST_CTX octx) 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); nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
return nctx; return nctx;
} }
@ -98,6 +99,9 @@ DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param));
int int
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) 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))); DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data)));
/*@-boundsread@*/ /*@-boundsread@*/
return (*ctx->Update) (ctx->param, data, len); return (*ctx->Update) (ctx->param, data, len);
@ -119,13 +123,16 @@ static union _dendian {
/*@-boundswrite@*/ /*@-boundswrite@*/
int int
rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap, rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
/*@out@*/ size_t *lenp, int asAscii)
{ {
uint32 * digest = xmalloc(ctx->digestlen); uint32 * digest;
char * t; char * t;
int i; 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)); 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);

View File

@ -299,6 +299,9 @@ Fts_close(FTS * sp)
register FTSENT *freep, *p; register FTSENT *freep, *p;
int saved_errno; int saved_errno;
if (sp == NULL)
return 0;
/* /*
* This still works if we haven't read anything -- the dummy structure * 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 * points to the root list, so we step through to the end of the root
@ -361,7 +364,7 @@ Fts_read(FTS * sp)
int saved_errno; int saved_errno;
/* If finished or unrecoverable error, return NULL. */ /* 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); return (NULL);
/* Set current node pointer. */ /* Set current node pointer. */

View File

@ -185,7 +185,7 @@ FTSENT *Fts_children (FTS * sp, int instr) __THROW
* @param sp file hierarchy state * @param sp file hierarchy state
* @return 0 on sucess, -1 on error * @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 @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;
@ -208,7 +208,7 @@ FTS *Fts_open (char * const * argv, int options,
* @return file set member * @return file set member
*/ */
/*@null@*/ /*@null@*/
FTSENT *Fts_read (FTS * sp) __THROW FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;

View File

@ -356,6 +356,7 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@-uniondef@*/
/*@unused@*/ static inline /*@unused@*/ static inline
void fdstat_enter(/*@null@*/ FD_t fd, int opx) void fdstat_enter(/*@null@*/ FD_t fd, int opx)
/*@globals internalState @*/ /*@globals internalState @*/
@ -396,6 +397,7 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
fd->stats->begin = end; /* structure assignment */ fd->stats->begin = end; /* structure assignment */
/*@=boundswrite@*/ /*@=boundswrite@*/
} }
/*@=uniondef@*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */

View File

@ -1378,7 +1378,7 @@ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
* @param len no. bytes of data * @param len no. bytes of data
* @return 0 on success * @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 @*/; /*@modifies ctx @*/;
/** \ingroup rpmio /** \ingroup rpmio
@ -1392,7 +1392,7 @@ int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
* @param asAscii return digest as ascii string? * @param asAscii return digest as ascii string?
* @return 0 on success * @return 0 on success
*/ */
int rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx,
/*@null@*/ /*@out@*/ void ** datap, /*@null@*/ /*@out@*/ void ** datap,
/*@null@*/ /*@out@*/ size_t * lenp, int asAscii) /*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
/*@modifies *datap, *lenp @*/; /*@modifies *datap, *lenp @*/;

View File

@ -1,13 +1,32 @@
/*@-unrecog@*/
/** \ingroup rpmio /** \ingroup rpmio
* \file rpmio/rpmsq.c * \file rpmio/rpmsq.c
*/ */
#include "system.h" #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__) #if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__)
#include <pthread.h> #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_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() \
@ -36,14 +55,14 @@
#define DO_LOCK() #define DO_LOCK()
#define DO_UNLOCK() #define DO_UNLOCK()
#define INIT_LOCK() #define INIT_LOCK()
#define ADD_REF(__tbl) #define ADD_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
#define SUB_REF(__tbl) #define SUB_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) #define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
#define CLEANUP_RESET(__execute, __oldtype) #define CLEANUP_RESET(__execute, __oldtype)
#define SAME_THREAD(_a, _b) (42) #define SAME_THREAD(_a, _b) (42)
#define ME() (((void *))getpid()) #define ME() (((void *)getpid()))
#endif /* HAVE_PTHREAD_H */ #endif /* HAVE_PTHREAD_H */
@ -57,10 +76,14 @@ int _rpmsq_debug = _RPMSQ_DEBUG;
/*@unchecked@*/ /*@unchecked@*/
static struct rpmsqElem rpmsqRock; static struct rpmsqElem rpmsqRock;
/*@-compmempass@*/
/*@unchecked@*/ /*@unchecked@*/
rpmsq rpmsqQueue = &rpmsqRock; rpmsq rpmsqQueue = &rpmsqRock;
/*@=compmempass@*/
int rpmsqInsert(void * elem, void * prev) /*@-mustmod@*/
int rpmsqInsert(void * elem, /*@unused@*/ void * prev)
{ {
rpmsq sq = (rpmsq) elem; rpmsq sq = (rpmsq) elem;
int ret = -1; int ret = -1;
@ -78,17 +101,24 @@ fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
sq->reaped = 0; sq->reaped = 0;
sq->status = 0; sq->status = 0;
sq->reaper = 1; sq->reaper = 1;
/*@-bounds@*/
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=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 ? 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)
{ {
@ -109,9 +139,11 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
ret = pthread_cond_destroy(&sq->cond); ret = pthread_cond_destroy(&sq->cond);
ret = pthread_mutex_destroy(&sq->mutex); ret = pthread_mutex_destroy(&sq->mutex);
sq->id = NULL; sq->id = NULL;
if (sq->pipes[1]) close(sq->pipes[1]); /*@-bounds@*/
if (sq->pipes[0]) close(sq->pipes[0]); 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; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
#ifdef NOTYET /* rpmpsmWait debugging message needs */ #ifdef NOTYET /* rpmpsmWait debugging message needs */
sq->reaper = 1; sq->reaper = 1;
sq->status = 0; sq->status = 0;
@ -127,14 +159,11 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
/*@unchecked@*/ /*@unchecked@*/
sigset_t rpmsqCaught; sigset_t rpmsqCaught;
/*@unchecked@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/*@unchecked@*/ /*@unchecked@*/
/*@-fullinitblock@*/ /*@-fullinitblock@*/
static struct rpmsig_s { static struct rpmsig_s {
int signum; int signum;
void (*handler) (int signum, siginfo_t * info, void * context); void (*handler) (int signum, void * info, void * context);
int active; int active;
struct sigaction oact; struct sigaction oact;
} rpmsigTbl[] = { } rpmsigTbl[] = {
@ -155,7 +184,10 @@ static struct rpmsig_s {
/*@=fullinitblock@*/ /*@=fullinitblock@*/
/*@-incondefs@*/ /*@-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; int save = errno;
rpmsig tbl; rpmsig tbl;
@ -186,7 +218,9 @@ void rpmsqAction(int signum, siginfo_t * info, void * context)
/*@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;
} }
} }
@ -201,6 +235,8 @@ void rpmsqAction(int signum, siginfo_t * info, void * context)
/*@=incondefs@*/ /*@=incondefs@*/
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
/*@globals rpmsigTbl @*/
/*@modifies rpmsigTbl @*/
{ {
int tblsignum = (signum >= 0 ? signum : -signum); int tblsignum = (signum >= 0 ? signum : -signum);
struct sigaction sa; struct sigaction sa;
@ -208,8 +244,10 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
int ret = -1; int ret = -1;
DO_LOCK (); 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;
@ -217,13 +255,15 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
if (signum >= 0) { /* Enable. */ if (signum >= 0) { /* Enable. */
if (ADD_REF(tbl) <= 0) { if (ADD_REF(tbl) <= 0) {
(void) sigdelset(&rpmsqCaught, tbl->signum); (void) sigdelset(&rpmsqCaught, tbl->signum);
sigemptyset (&sa.sa_mask); (void) sigemptyset (&sa.sa_mask);
/*@-compdef -type @*/
sa.sa_flags = SA_SIGINFO; sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = (handler != NULL ? handler : tbl->handler); sa.sa_sigaction = (handler != NULL ? handler : tbl->handler);
if (sigaction(tbl->signum, &sa, &tbl->oact) < 0) { if (sigaction(tbl->signum, &sa, &tbl->oact) < 0) {
SUB_REF(tbl); SUB_REF(tbl);
break; break;
} }
/*@=compdef =type @*/
tbl->active = 1; /* XXX just in case */ tbl->active = 1; /* XXX just in case */
if (handler != NULL) if (handler != NULL)
tbl->handler = handler; tbl->handler = handler;
@ -265,18 +305,22 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
pid = fork(); pid = fork();
if (pid < (pid_t) 0) { /* fork failed. */ if (pid < (pid_t) 0) { /* fork failed. */
/*@-bounds@*/
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
goto out; goto out;
} else if (pid == (pid_t) 0) { /* Child. */ } else if (pid == (pid_t) 0) { /* Child. */
int yy; int yy;
/* Block to permit parent to wait. */ /* Block to permit parent to wait. */
/*@-bounds@*/
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
xx = read(sq->pipes[0], &yy, sizeof(yy)); xx = read(sq->pipes[0], &yy, sizeof(yy));
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
/*@-modfilesys@*/ /*@-modfilesys@*/
@ -297,10 +341,12 @@ fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child);
#endif #endif
#ifdef DYING #ifdef DYING
/*@-bounds@*/
/* Unblock child. */ /* Unblock child. */
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
#endif #endif
} }
@ -317,7 +363,7 @@ out:
*/ */
static int rpmsqWaitUnregister(rpmsq sq) static int rpmsqWaitUnregister(rpmsq sq)
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/ /*@modifies sq, fileSystem, internalState @*/
{ {
struct rpmsw_s end; struct rpmsw_s end;
int same_thread = 0; int same_thread = 0;
@ -330,11 +376,13 @@ static int rpmsqWaitUnregister(rpmsq sq)
ret = pthread_mutex_lock(&sq->mutex); ret = pthread_mutex_lock(&sq->mutex);
/* Start the child. */ /* Start the child. */
/*@-bounds@*/
if (sq->pipes[0] >= 0) if (sq->pipes[0] >= 0)
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
if (sq->pipes[1] >= 0) if (sq->pipes[1] >= 0)
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
(void) rpmswNow(&sq->begin); (void) rpmswNow(&sq->begin);
@ -347,7 +395,9 @@ static int rpmsqWaitUnregister(rpmsq sq)
} }
/*@=infloops@*/ /*@=infloops@*/
/*@-uniondef@*/
sq->msecs = rpmswDiff(rpmswNow(&end), &sq->begin)/1000; sq->msecs = rpmswDiff(rpmswNow(&end), &sq->begin)/1000;
/*@=uniondef@*/
sq->script_msecs += sq->msecs; sq->script_msecs += sq->msecs;
if (same_thread) if (same_thread)
@ -432,6 +482,8 @@ fprintf(stderr, " Thread(%p): %p\n", ME(), pth);
*/ */
static void static void
sigchld_cancel (void *arg) sigchld_cancel (void *arg)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
pid_t child = *(pid_t *) arg; pid_t child = *(pid_t *) arg;
pid_t result; pid_t result;
@ -453,6 +505,7 @@ sigchld_cancel (void *arg)
/** /**
* Execute a command, returning its status. * Execute a command, returning its status.
*/ */
/*@-bounds@*/
int int
rpmsqExecve (const char ** argv) rpmsqExecve (const char ** argv)
{ {
@ -476,8 +529,8 @@ rpmsqExecve (const char ** argv)
} }
DO_UNLOCK (); DO_UNLOCK ();
sigemptyset (&newMask); (void) sigemptyset (&newMask);
sigaddset (&newMask, SIGCHLD); (void) sigaddset (&newMask, SIGCHLD);
if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) { if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) {
DO_LOCK (); DO_LOCK ();
if (SUB_REF (rpmsigTbl_sigchld) == 0) if (SUB_REF (rpmsigTbl_sigchld) == 0)
@ -529,3 +582,5 @@ out:
DO_UNLOCK (); DO_UNLOCK ();
return status; return status;
} }
/*@=bounds@*/
/*@=unrecog@*/

View File

@ -6,18 +6,23 @@
* *
*/ */
#include <pthread.h>
#include <signal.h>
#include <sys/signal.h>
#include <search.h> /* XXX insque(3)/remque(3) protos. */
#include <rpmsw.h> #include <rpmsw.h>
/**
*/
typedef struct rpmsig_s * rpmsig; typedef struct rpmsig_s * rpmsig;
/**
*/
typedef struct rpmsqElem * rpmsq; 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@*/ /*@-redecl@*/
@ -44,8 +49,10 @@ struct rpmsqElem {
pthread_cond_t cond; pthread_cond_t cond;
}; };
/*@-exportlocal@*/
/*@unchecked@*/ /*@unchecked@*/
extern rpmsq rpmsqQueue; extern rpmsq rpmsqQueue;
/*@=exportlocal@*/
/*@unchecked@*/ /*@unchecked@*/
extern sigset_t rpmsqCaught; extern sigset_t rpmsqCaught;
@ -55,21 +62,38 @@ extern sigset_t rpmsqCaught;
#endif #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) int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
/*@globals rpmsqQueue @*/
/*@modifies elem, rpmsqQueue @*/;
/**
*/
int rpmsqRemove(/*@null@*/ void * elem)
/*@modifies elem @*/; /*@modifies elem @*/;
/*@=exportlocal@*/
/** /**
* Remove node from queue.
* @param elem node to link
* @return 0 on success
*/ */
void rpmsqAction(int signum, siginfo_t * info, void * context) /*@-exportlocal@*/
/*@globals rpmsqCaught, fileSystem @*/ int rpmsqRemove(/*@null@*/ void * elem)
/*@modifies rpmsqCaught, fileSystem @*/; /*@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
*/
/*@-exportlocal@*/
void rpmsqAction(int signum, void * info, void * context)
/*@globals rpmsqCaught, errno, fileSystem @*/
/*@modifies rpmsqCaught, errno, fileSystem @*/;
/*@=exportlocal@*/
/** /**
* Enable or disable a signal handler. * Enable or disable a signal handler.
@ -106,14 +130,15 @@ pid_t rpmsqWait(rpmsq sq)
* @return 0 on success * @return 0 on success
*/ */
int rpmsqThread(void * (*start) (void * arg), void * arg) int rpmsqThread(void * (*start) (void * arg), void * arg)
/*@globals fileSystem, internalState @*/ /*@globals internalState @*/
/*@modifies fileSystem, internalState @*/; /*@modifies internalState @*/;
/** /**
* Execute a command, returning its status. * Execute a command, returning its status.
*/ */
int rpmsqExecve (const char ** argv) int rpmsqExecve (const char ** argv)
/*@*/; /*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -8,8 +8,10 @@
#if defined(__LCLINT__) #if defined(__LCLINT__)
/*@-exportheader@*/ /*@-exportheader@*/
extern int nanosleep(const struct timespec *req, /*@out@*/ struct timespec *rem) extern int nanosleep(const struct timespec *__requested_time,
/*@modifies rem @*/; /*@out@*/ /*@null@*/ struct timespec *__remaining)
/*@globals errno @*/
/*@modifies *__remaining, errno @*/;
/*@=exportheader@*/ /*@=exportheader@*/
#endif #endif
@ -153,7 +155,9 @@ static rpmtime_t rpmswCalibrate(void)
int rc; int rc;
int i; int i;
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
/*@=uniondef@*/
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++) {
@ -166,7 +170,9 @@ static rpmtime_t rpmswCalibrate(void)
break; break;
req = rem; /* structure assignment */ req = rem; /* structure assignment */
} }
/*@-uniondef@*/
ticks = rpmswDiff(rpmswNow(&end), &begin); ticks = rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
return ticks; return ticks;
} }
@ -199,7 +205,9 @@ rpmtime_t rpmswInit(void)
/* Start wall clock. */ /* Start wall clock. */
rpmsw_type = 0; rpmsw_type = 0;
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
/*@=uniondef@*/
/* Get no. of cycles in 20ms nanosleep */ /* Get no. of cycles in 20ms nanosleep */
rpmsw_type = 1; rpmsw_type = 1;
@ -209,7 +217,9 @@ rpmtime_t rpmswInit(void)
/* Compute wall clock delta in usecs. */ /* Compute wall clock delta in usecs. */
rpmsw_type = 0; rpmsw_type = 0;
/*@-uniondef@*/
usecs = rpmswDiff(rpmswNow(&end), &begin); usecs = rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
rpmsw_type = 1; rpmsw_type = 1;
@ -224,8 +234,10 @@ rpmtime_t rpmswInit(void)
#endif #endif
/* Calculate timing overhead in usecs. */ /* Calculate timing overhead in usecs. */
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
usecs = rpmswDiff(rpmswNow(&end), &begin); usecs = rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
rpmsw_overhead *= i; rpmsw_overhead *= i;
rpmsw_overhead += usecs; rpmsw_overhead += usecs;
@ -241,7 +253,9 @@ rpmtime_t rpmswInit(void)
int rpmswEnter(rpmop op) int rpmswEnter(rpmop op)
{ {
op->count++; op->count++;
/*@-uniondef@*/
(void) rpmswNow(&op->begin); (void) rpmswNow(&op->begin);
/*@=uniondef@*/
return 0; return 0;
} }
@ -249,7 +263,9 @@ int rpmswExit(rpmop op, ssize_t rc)
{ {
struct rpmsw_s end; struct rpmsw_s end;
/*@-uniondef@*/
op->usecs += rpmswDiff(rpmswNow(&end), &op->begin); op->usecs += rpmswDiff(rpmswNow(&end), &op->begin);
/*@=uniondef@*/
if (rc > 0) if (rc > 0)
op->bytes += rc; op->bytes += rc;
return 0; return 0;

View File

@ -61,9 +61,11 @@ rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
/** Return benchmark time stamp overhead. /** Return benchmark time stamp overhead.
* @return overhead in micro-seconds * @return overhead in micro-seconds
*/ */
/*@-exportlocal@*/
rpmtime_t rpmswInit(void) rpmtime_t rpmswInit(void)
/*@globals internalState @*/ /*@globals internalState @*/
/*@modifes internalState @*/; /*@modifes internalState @*/;
/*@=exportlocal@*/
/** \ingroup rpmio /** \ingroup rpmio
* Enter timed operation. * Enter timed operation.