Splint fiddles.

CVS patchset: 6724
CVS date: 2003/04/01 22:20:45
This commit is contained in:
jbj 2003-04-01 22:20:45 +00:00
parent 02bb493292
commit cec67caee6
5 changed files with 44 additions and 31 deletions

View File

@ -81,9 +81,10 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#endif #endif
/*@only@*/ /*@only@*/ /*@null@*/
static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen) static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen)
/*@*/; /*@*/;
/*@null@*/
static FTSENT * fts_build(FTS * sp, int type) static FTSENT * fts_build(FTS * sp, int type)
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;
@ -202,6 +203,8 @@ Fts_open(char * const * argv, int options,
} }
p = fts_alloc(sp, *argv, len); p = fts_alloc(sp, *argv, len);
if (p == NULL)
goto mem3;
p->fts_level = FTS_ROOTLEVEL; p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent; p->fts_parent = parent;
p->fts_accpath = p->fts_name; p->fts_accpath = p->fts_name;
@ -223,6 +226,7 @@ Fts_open(char * const * argv, int options,
if (root == NULL) if (root == NULL)
tmp = root = p; tmp = root = p;
else { else {
if (tmp != NULL) /* XXX can't happen */
tmp->fts_link = p; tmp->fts_link = p;
tmp = p; tmp = p;
} }
@ -878,6 +882,7 @@ mem1: saved_errno = errno;
if (len == sp->fts_pathlen || nitems == 0) if (len == sp->fts_pathlen || nitems == 0)
--cp; --cp;
/*@-boundswrite@*/ /*@-boundswrite@*/
if (cp != NULL) /* XXX can't happen */
*cp = '\0'; *cp = '\0';
/*@=boundswrite@*/ /*@=boundswrite@*/
} }
@ -1022,7 +1027,7 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
sp->fts_array = a; sp->fts_array = a;
} }
/*@-boundswrite@*/ /*@-boundswrite@*/
for (ap = sp->fts_array, p = head; p; p = p->fts_link) for (ap = sp->fts_array, p = head; p != NULL; p = p->fts_link)
*ap++ = p; *ap++ = p;
qsort((void *)sp->fts_array, nitems, sizeof(*sp->fts_array), qsort((void *)sp->fts_array, nitems, sizeof(*sp->fts_array),
sp->fts_compar); sp->fts_compar);
@ -1141,7 +1146,7 @@ fts_padjust(FTS * sp, FTSENT * head)
(p)->fts_path = addr; \ (p)->fts_path = addr; \
} while (0) } while (0)
/* Adjust the current set of children. */ /* Adjust the current set of children. */
for (p = sp->fts_child; p; p = p->fts_link) for (p = sp->fts_child; p != NULL; p = p->fts_link)
ADJUST(p); ADJUST(p);
/* Adjust the rest of the tree, including the current level. */ /* Adjust the rest of the tree, including the current level. */

View File

@ -62,14 +62,14 @@
#include <dirent.h> #include <dirent.h>
typedef struct { typedef struct {
/*@owned@*/ /*@owned@*/ /*@relnull@*/
struct _ftsent *fts_cur; /*!< current node */ struct _ftsent *fts_cur; /*!< current node */
/*@owned@*/ /*@null@*/ /*@owned@*/ /*@null@*/
struct _ftsent *fts_child; /*!< linked list of children */ struct _ftsent *fts_child; /*!< linked list of children */
/*@owned@*/ /*@null@*/ /*@owned@*/ /*@null@*/
struct _ftsent **fts_array; /*!< sort array */ struct _ftsent **fts_array; /*!< sort array */
dev_t fts_dev; /*!< starting device # */ dev_t fts_dev; /*!< starting device # */
/*@owned@*/ /*@owned@*/ /*@relnull@*/
char *fts_path; /*!< path for this descent */ char *fts_path; /*!< path for this descent */
int fts_rfd; /*!< fd for root */ int fts_rfd; /*!< fd for root */
int fts_pathlen; /*!< sizeof(path) */ int fts_pathlen; /*!< sizeof(path) */
@ -112,11 +112,12 @@ typedef struct {
typedef struct _ftsent { typedef struct _ftsent {
/*@dependent@*/ /*@dependent@*/
struct _ftsent *fts_cycle; /*!< cycle node */ struct _ftsent *fts_cycle; /*!< cycle node */
/*@dependent@*/ /*@dependent@*/ /*@relnull@*/
struct _ftsent *fts_parent; /*!< parent directory */ struct _ftsent *fts_parent; /*!< parent directory */
/*@dependent@*/ /*@dependent@*/ /*@null@*/
struct _ftsent *fts_link; /*!< next file in directory */ struct _ftsent *fts_link; /*!< next file in directory */
long fts_number; /*!< local numeric value */ long fts_number; /*!< local numeric value */
/*@null@*/
void *fts_pointer; /*!< local address value */ void *fts_pointer; /*!< local address value */
/*@dependent@*/ /*@dependent@*/
char *fts_accpath; /*!< access path */ char *fts_accpath; /*!< access path */
@ -174,7 +175,7 @@ __BEGIN_DECLS
* @param instr * @param instr
* @return file set member * @return file set member
*/ */
/*@unused@*/ /*@dependent@*/ /*@dependent@*/ /*@null@*/
FTSENT *Fts_children (FTS * sp, int instr) __THROW FTSENT *Fts_children (FTS * sp, int instr) __THROW
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;
@ -184,7 +185,6 @@ 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
*/ */
/*@unused@*/
int Fts_close (/*@only@*/ FTS * sp) __THROW int Fts_close (/*@only@*/ FTS * sp) __THROW
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;
@ -196,7 +196,7 @@ int Fts_close (/*@only@*/ FTS * sp) __THROW
* @param compar traversal ordering (or NULL) * @param compar traversal ordering (or NULL)
* @return file hierarchy state (or NULL on error) * @return file hierarchy state (or NULL on error)
*/ */
/*@unused@*/ /*@only@*/ /*@only@*/ /*@null@*/
FTS *Fts_open (char * const * argv, int options, FTS *Fts_open (char * const * argv, int options,
/*@null@*/ /*@null@*/
int (*compar) (const FTSENT **, const FTSENT **)) __THROW int (*compar) (const FTSENT **, const FTSENT **)) __THROW
@ -207,7 +207,7 @@ FTS *Fts_open (char * const * argv, int options,
* @param sp file hierarchy state * @param sp file hierarchy state
* @return file set member * @return file set member
*/ */
/*@unused@*/ /*@null@*/ /*@null@*/
FTSENT *Fts_read (FTS * sp) __THROW FTSENT *Fts_read (FTS * sp) __THROW
/*@globals fileSystem, internalState @*/ /*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/; /*@modifies *sp, fileSystem, internalState @*/;
@ -219,7 +219,6 @@ FTSENT *Fts_read (FTS * sp) __THROW
* @param instr new disposition for file set member * @param instr new disposition for file set member
* @return 0 on sucess, -1 on error * @return 0 on sucess, -1 on error
*/ */
/*@unused@*/
int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
/*@modifies *p @*/; /*@modifies *p @*/;

View File

@ -334,6 +334,7 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd, int escapes)
* @param pr right char, i.e. ']', ')', '}', etc. * @param pr right char, i.e. ']', ')', '}', etc.
* @return address of last char before pr (or NULL) * @return address of last char before pr (or NULL)
*/ */
/*@null@*/
static const char * static const char *
matchchar(const char * p, char pl, char pr) matchchar(const char * p, char pl, char pr)
/*@*/ /*@*/
@ -973,7 +974,10 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se, char
opts = me->opts; opts = me->opts;
/* Define option macros. */ /* Define option macros. */
while((c = getopt(argc, (char **)argv, opts)) != -1) { /*@-nullstate@*/ /* FIX: argv[] can be NULL */
while((c = getopt(argc, (char **)argv, opts)) != -1)
/*@=nullstate@*/
{
if (c == '?' || (o = strchr(opts, c)) == NULL) { if (c == '?' || (o = strchr(opts, c)) == NULL) {
rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"), rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"),
(char)c, me->name, opts); (char)c, me->name, opts);
@ -1006,7 +1010,9 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se, char
sprintf(aname, "%d", (c - optind + 1)); sprintf(aname, "%d", (c - optind + 1));
addMacro(mb->mc, aname, NULL, argv[c], mb->depth); addMacro(mb->mc, aname, NULL, argv[c], mb->depth);
*be++ = ' '; *be++ = ' ';
/*@-nullpass@*/ /* FIX: argv[] can be NULL */
be = stpcpy(be, argv[c]); be = stpcpy(be, argv[c]);
/*@=nullpass@*/
} }
} }
@ -1051,7 +1057,7 @@ doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
*/ */
static void static void
doFoo(MacroBuf mb, int negate, const char * f, size_t fn, doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
const char * g, size_t gn) /*@null@*/ const char * g, size_t gn)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/
{ {
@ -1059,7 +1065,7 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
int c; int c;
buf[0] = '\0'; buf[0] = '\0';
if (g) { if (g != NULL) {
strncpy(buf, g, gn); strncpy(buf, g, gn);
buf[gn] = '\0'; buf[gn] = '\0';
(void) expandU(mb, buf, sizeof(buf)); (void) expandU(mb, buf, sizeof(buf));
@ -1330,7 +1336,7 @@ expandMacro(MacroBuf mb)
int waserror = 0; int waserror = 0;
if (STREQ("error", f, fn)) if (STREQ("error", f, fn))
waserror = 1; waserror = 1;
if (g < ge) if (g != NULL && g < ge)
doOutput(mb, waserror, g, gn); doOutput(mb, waserror, g, gn);
else else
doOutput(mb, waserror, f, fn); doOutput(mb, waserror, f, fn);

View File

@ -294,7 +294,8 @@ DBGREFS(fd, (stderr, "--> fd %p ++ %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi
/*@=modfilesys@*/ /*@=modfilesys@*/
/*@-modfilesys@*/ /*@-modfilesys@*/
static inline /*@null@*/ FD_t XfdFree( /*@killref@*/ FD_t fd, const char *msg, static inline /*@null@*/
FD_t XfdFree( /*@killref@*/ FD_t fd, const char *msg,
const char *file, unsigned line) const char *file, unsigned line)
/*@modifies fd @*/ /*@modifies fd @*/
{ {
@ -322,9 +323,10 @@ DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi
} }
/*@=modfilesys@*/ /*@=modfilesys@*/
static inline /*@null@*/ FD_t XfdNew(const char * msg, static inline /*@null@*/
const char * file, unsigned line) FD_t XfdNew(const char * msg, const char * file, unsigned line)
/*@*/ /*@globals internalState @*/
/*@modifies internalState @*/
{ {
FD_t fd = xcalloc(1, sizeof(*fd)); FD_t fd = xcalloc(1, sizeof(*fd));
if (fd == NULL) /* XXX xmalloc never returns NULL */ if (fd == NULL) /* XXX xmalloc never returns NULL */
@ -1026,8 +1028,8 @@ static int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str)
} }
static int ftpCommand(urlinfo u, char ** str, ...) static int ftpCommand(urlinfo u, char ** str, ...)
/*@globals fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies u, *str, fileSystem @*/ /*@modifies u, *str, fileSystem, internalState @*/
{ {
va_list ap; va_list ap;
int len = 0; int len = 0;
@ -2185,9 +2187,10 @@ static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd)
return rc; return rc;
} }
static /*@null@*/ FD_t gzdOpen(const char * path, const char * fmode) static /*@null@*/
/*@globals fileSystem @*/ FD_t gzdOpen(const char * path, const char * fmode)
/*@modifies fileSystem @*/ /*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
FD_t fd; FD_t fd;
gzFile *gzfile; gzFile *gzfile;

View File

@ -482,8 +482,8 @@ off_t fdSize(FD_t fd)
*/ */
/*@-incondefs@*/ /*@-incondefs@*/
ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count) ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count)
/*@globals errno, fileSystem @*/ /*@globals errno, fileSystem, internalState @*/
/*@modifies *cookie, *buf, errno, fileSystem @*/ /*@modifies *cookie, *buf, errno, fileSystem, internalState @*/
/*@requires maxSet(buf) >= (count - 1) @*/ /*@requires maxSet(buf) >= (count - 1) @*/
/*@ensures maxRead(buf) == result @*/ ; /*@ensures maxRead(buf) == result @*/ ;
#define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count)) #define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count))
@ -492,8 +492,8 @@ ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count)
/** /**
*/ */
ssize_t fdWrite(void * cookie, const char * buf, size_t count) ssize_t fdWrite(void * cookie, const char * buf, size_t count)
/*@globals errno, fileSystem @*/ /*@globals errno, fileSystem, internalState @*/
/*@modifies *cookie, errno, fileSystem @*/; /*@modifies *cookie, errno, fileSystem, internalState @*/;
#define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (_count)) #define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (_count))
/** /**