diff options
author | jbj <devnull@localhost> | 2003-04-02 21:16:26 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2003-04-02 21:16:26 +0000 |
commit | 95f01d39a57c3c3d8ebf80cfd78e67c550dc32e5 (patch) | |
tree | d8eaa0d6c4bb93c5c12a18a3e066de0d68e3aae2 /rpmio | |
parent | 1f366d6a00d1cf8dc08a40fe789a1b68b4b80a5a (diff) | |
download | librpm-tizen-95f01d39a57c3c3d8ebf80cfd78e67c550dc32e5.tar.gz librpm-tizen-95f01d39a57c3c3d8ebf80cfd78e67c550dc32e5.tar.bz2 librpm-tizen-95f01d39a57c3c3d8ebf80cfd78e67c550dc32e5.zip |
Splint clean.
CVS patchset: 6729
CVS date: 2003/04/02 21:16:26
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/digest.c | 15 | ||||
-rw-r--r-- | rpmio/fts.c | 5 | ||||
-rw-r--r-- | rpmio/fts.h | 4 | ||||
-rw-r--r-- | rpmio/rpmio_internal.h | 2 | ||||
-rw-r--r-- | rpmio/rpmpgp.h | 4 | ||||
-rw-r--r-- | rpmio/rpmsq.c | 87 | ||||
-rw-r--r-- | rpmio/rpmsq.h | 55 | ||||
-rw-r--r-- | rpmio/rpmsw.c | 20 | ||||
-rw-r--r-- | rpmio/rpmsw.h | 2 |
9 files changed, 152 insertions, 42 deletions
diff --git a/rpmio/digest.c b/rpmio/digest.c index b587324a7..1cca844c4 100644 --- a/rpmio/digest.c +++ b/rpmio/digest.c @@ -35,7 +35,8 @@ struct DIGEST_CTX_s { 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; } @@ -98,6 +99,9 @@ DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param)); 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); @@ -119,13 +123,16 @@ static union _dendian { /*@-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); diff --git a/rpmio/fts.c b/rpmio/fts.c index f11c17cb2..85ecbf89e 100644 --- a/rpmio/fts.c +++ b/rpmio/fts.c @@ -299,6 +299,9 @@ Fts_close(FTS * sp) 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 @@ -361,7 +364,7 @@ Fts_read(FTS * sp) 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. */ diff --git a/rpmio/fts.h b/rpmio/fts.h index 487eb7dc8..ff9c613da 100644 --- a/rpmio/fts.h +++ b/rpmio/fts.h @@ -185,7 +185,7 @@ FTSENT *Fts_children (FTS * sp, int instr) __THROW * @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 @*/; @@ -208,7 +208,7 @@ FTS *Fts_open (char * const * argv, int options, * @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 @*/; diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h index 4256021c0..64eebd59f 100644 --- a/rpmio/rpmio_internal.h +++ b/rpmio/rpmio_internal.h @@ -356,6 +356,7 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) /** \ingroup rpmio */ +/*@-uniondef@*/ /*@unused@*/ static inline void fdstat_enter(/*@null@*/ FD_t fd, int opx) /*@globals internalState @*/ @@ -396,6 +397,7 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc) fd->stats->begin = end; /* structure assignment */ /*@=boundswrite@*/ } +/*@=uniondef@*/ /** \ingroup rpmio */ diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h index f4061015c..b3102e09b 100644 --- a/rpmio/rpmpgp.h +++ b/rpmio/rpmpgp.h @@ -1378,7 +1378,7 @@ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags) * @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 @@ -1392,7 +1392,7 @@ int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) * @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 @*/; diff --git a/rpmio/rpmsq.c b/rpmio/rpmsq.c index a27c84b33..fe58d0983 100644 --- a/rpmio/rpmsq.c +++ b/rpmio/rpmsq.c @@ -1,13 +1,32 @@ +/*@-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() \ @@ -36,14 +55,14 @@ #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 */ @@ -57,10 +76,14 @@ int _rpmsq_debug = _RPMSQ_DEBUG; /*@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; @@ -78,17 +101,24 @@ fprintf(stderr, " Insert(%p): %p\n", ME(), sq); 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) { @@ -109,9 +139,11 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq); 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; @@ -128,13 +160,10 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq); 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[] = { @@ -155,7 +184,10 @@ static struct rpmsig_s { /*@=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; @@ -186,7 +218,9 @@ void rpmsqAction(int signum, siginfo_t * info, void * context) /*@innercontinue@*/ continue; sq->reaped = reaped; sq->status = status; +#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__) (void) pthread_cond_signal(&sq->cond); +#endif /*@innerbreak@*/ break; } } @@ -201,6 +235,8 @@ void rpmsqAction(int signum, siginfo_t * info, void * context) /*@=incondefs@*/ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) + /*@globals rpmsigTbl @*/ + /*@modifies rpmsigTbl @*/ { int tblsignum = (signum >= 0 ? signum : -signum); struct sigaction sa; @@ -208,8 +244,10 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) 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; @@ -217,13 +255,15 @@ int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) 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; @@ -265,18 +305,22 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq); 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@*/ @@ -297,10 +341,12 @@ fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child); #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 } @@ -317,7 +363,7 @@ out: */ static int rpmsqWaitUnregister(rpmsq sq) /*@globals fileSystem, internalState @*/ - /*@modifies fileSystem, internalState @*/ + /*@modifies sq, fileSystem, internalState @*/ { struct rpmsw_s end; int same_thread = 0; @@ -330,11 +376,13 @@ static int rpmsqWaitUnregister(rpmsq sq) 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); @@ -347,7 +395,9 @@ static int rpmsqWaitUnregister(rpmsq sq) } /*@=infloops@*/ +/*@-uniondef@*/ sq->msecs = rpmswDiff(rpmswNow(&end), &sq->begin)/1000; +/*@=uniondef@*/ sq->script_msecs += sq->msecs; if (same_thread) @@ -432,6 +482,8 @@ fprintf(stderr, " Thread(%p): %p\n", ME(), pth); */ static void sigchld_cancel (void *arg) + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/ { pid_t child = *(pid_t *) arg; pid_t result; @@ -453,6 +505,7 @@ sigchld_cancel (void *arg) /** * Execute a command, returning its status. */ +/*@-bounds@*/ int rpmsqExecve (const char ** argv) { @@ -476,8 +529,8 @@ 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) @@ -529,3 +582,5 @@ out: DO_UNLOCK (); return status; } +/*@=bounds@*/ +/*@=unrecog@*/ diff --git a/rpmio/rpmsq.h b/rpmio/rpmsq.h index 04fcf5e84..6d80f7853 100644 --- a/rpmio/rpmsq.h +++ b/rpmio/rpmsq.h @@ -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> +/** + */ 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@*/ @@ -44,8 +49,10 @@ struct rpmsqElem { pthread_cond_t cond; }; +/*@-exportlocal@*/ /*@unchecked@*/ extern rpmsq rpmsqQueue; +/*@=exportlocal@*/ /*@unchecked@*/ extern sigset_t rpmsqCaught; @@ -55,21 +62,38 @@ 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. @@ -106,14 +130,15 @@ pid_t rpmsqWait(rpmsq sq) * @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 } diff --git a/rpmio/rpmsw.c b/rpmio/rpmsw.c index 6c6d9af7c..4d521deb2 100644 --- a/rpmio/rpmsw.c +++ b/rpmio/rpmsw.c @@ -8,8 +8,10 @@ #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 @@ -153,7 +155,9 @@ static rpmtime_t rpmswCalibrate(void) 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++) { @@ -166,7 +170,9 @@ static rpmtime_t rpmswCalibrate(void) break; req = rem; /* structure assignment */ } +/*@-uniondef@*/ ticks = rpmswDiff(rpmswNow(&end), &begin); +/*@=uniondef@*/ return ticks; } @@ -199,7 +205,9 @@ rpmtime_t rpmswInit(void) /* Start wall clock. */ rpmsw_type = 0; +/*@-uniondef@*/ (void) rpmswNow(&begin); +/*@=uniondef@*/ /* Get no. of cycles in 20ms nanosleep */ rpmsw_type = 1; @@ -209,7 +217,9 @@ rpmtime_t rpmswInit(void) /* Compute wall clock delta in usecs. */ rpmsw_type = 0; +/*@-uniondef@*/ usecs = rpmswDiff(rpmswNow(&end), &begin); +/*@=uniondef@*/ rpmsw_type = 1; @@ -224,8 +234,10 @@ rpmtime_t rpmswInit(void) #endif /* Calculate timing overhead in usecs. */ +/*@-uniondef@*/ (void) rpmswNow(&begin); usecs = rpmswDiff(rpmswNow(&end), &begin); +/*@=uniondef@*/ rpmsw_overhead *= i; rpmsw_overhead += usecs; @@ -241,7 +253,9 @@ rpmtime_t rpmswInit(void) int rpmswEnter(rpmop op) { op->count++; +/*@-uniondef@*/ (void) rpmswNow(&op->begin); +/*@=uniondef@*/ return 0; } @@ -249,7 +263,9 @@ int rpmswExit(rpmop op, ssize_t rc) { struct rpmsw_s end; +/*@-uniondef@*/ op->usecs += rpmswDiff(rpmswNow(&end), &op->begin); +/*@=uniondef@*/ if (rc > 0) op->bytes += rc; return 0; diff --git a/rpmio/rpmsw.h b/rpmio/rpmsw.h index 91f9d9cb4..48bcf1b20 100644 --- a/rpmio/rpmsw.h +++ b/rpmio/rpmsw.h @@ -61,9 +61,11 @@ rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin) /** 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. |