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
/*@only@*/
/*@only@*/ /*@null@*/
static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen)
/*@*/;
/*@null@*/
static FTSENT * fts_build(FTS * sp, int type)
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
@ -202,6 +203,8 @@ Fts_open(char * const * argv, int options,
}
p = fts_alloc(sp, *argv, len);
if (p == NULL)
goto mem3;
p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent;
p->fts_accpath = p->fts_name;
@ -223,7 +226,8 @@ Fts_open(char * const * argv, int options,
if (root == NULL)
tmp = root = p;
else {
tmp->fts_link = p;
if (tmp != NULL) /* XXX can't happen */
tmp->fts_link = p;
tmp = p;
}
}
@ -878,7 +882,8 @@ mem1: saved_errno = errno;
if (len == sp->fts_pathlen || nitems == 0)
--cp;
/*@-boundswrite@*/
*cp = '\0';
if (cp != NULL) /* XXX can't happen */
*cp = '\0';
/*@=boundswrite@*/
}
@ -1022,7 +1027,7 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
sp->fts_array = a;
}
/*@-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;
qsort((void *)sp->fts_array, nitems, sizeof(*sp->fts_array),
sp->fts_compar);
@ -1141,7 +1146,7 @@ fts_padjust(FTS * sp, FTSENT * head)
(p)->fts_path = addr; \
} while (0)
/* 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 the rest of the tree, including the current level. */

View File

@ -62,14 +62,14 @@
#include <dirent.h>
typedef struct {
/*@owned@*/
/*@owned@*/ /*@relnull@*/
struct _ftsent *fts_cur; /*!< current node */
/*@owned@*/ /*@null@*/
struct _ftsent *fts_child; /*!< linked list of children */
/*@owned@*/ /*@null@*/
struct _ftsent **fts_array; /*!< sort array */
dev_t fts_dev; /*!< starting device # */
/*@owned@*/
/*@owned@*/ /*@relnull@*/
char *fts_path; /*!< path for this descent */
int fts_rfd; /*!< fd for root */
int fts_pathlen; /*!< sizeof(path) */
@ -112,11 +112,12 @@ typedef struct {
typedef struct _ftsent {
/*@dependent@*/
struct _ftsent *fts_cycle; /*!< cycle node */
/*@dependent@*/
/*@dependent@*/ /*@relnull@*/
struct _ftsent *fts_parent; /*!< parent directory */
/*@dependent@*/
/*@dependent@*/ /*@null@*/
struct _ftsent *fts_link; /*!< next file in directory */
long fts_number; /*!< local numeric value */
/*@null@*/
void *fts_pointer; /*!< local address value */
/*@dependent@*/
char *fts_accpath; /*!< access path */
@ -174,7 +175,7 @@ __BEGIN_DECLS
* @param instr
* @return file set member
*/
/*@unused@*/ /*@dependent@*/
/*@dependent@*/ /*@null@*/
FTSENT *Fts_children (FTS * sp, int instr) __THROW
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
@ -184,7 +185,6 @@ FTSENT *Fts_children (FTS * sp, int instr) __THROW
* @param sp file hierarchy state
* @return 0 on sucess, -1 on error
*/
/*@unused@*/
int Fts_close (/*@only@*/ FTS * sp) __THROW
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
@ -196,7 +196,7 @@ int Fts_close (/*@only@*/ FTS * sp) __THROW
* @param compar traversal ordering (or NULL)
* @return file hierarchy state (or NULL on error)
*/
/*@unused@*/ /*@only@*/
/*@only@*/ /*@null@*/
FTS *Fts_open (char * const * argv, int options,
/*@null@*/
int (*compar) (const FTSENT **, const FTSENT **)) __THROW
@ -207,7 +207,7 @@ FTS *Fts_open (char * const * argv, int options,
* @param sp file hierarchy state
* @return file set member
*/
/*@unused@*/ /*@null@*/
/*@null@*/
FTSENT *Fts_read (FTS * sp) __THROW
/*@globals fileSystem, internalState @*/
/*@modifies *sp, fileSystem, internalState @*/;
@ -219,7 +219,6 @@ FTSENT *Fts_read (FTS * sp) __THROW
* @param instr new disposition for file set member
* @return 0 on sucess, -1 on error
*/
/*@unused@*/
int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
/*@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.
* @return address of last char before pr (or NULL)
*/
/*@null@*/
static const char *
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;
/* 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) {
rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"),
(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));
addMacro(mb->mc, aname, NULL, argv[c], mb->depth);
*be++ = ' ';
/*@-nullpass@*/ /* FIX: argv[] can be NULL */
be = stpcpy(be, argv[c]);
/*@=nullpass@*/
}
}
@ -1051,7 +1057,7 @@ doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
*/
static void
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 @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/
{
@ -1059,7 +1065,7 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
int c;
buf[0] = '\0';
if (g) {
if (g != NULL) {
strncpy(buf, g, gn);
buf[gn] = '\0';
(void) expandU(mb, buf, sizeof(buf));
@ -1330,7 +1336,7 @@ expandMacro(MacroBuf mb)
int waserror = 0;
if (STREQ("error", f, fn))
waserror = 1;
if (g < ge)
if (g != NULL && g < ge)
doOutput(mb, waserror, g, gn);
else
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@*/
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)
/*@modifies fd @*/
{
@ -322,9 +323,10 @@ DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi
}
/*@=modfilesys@*/
static inline /*@null@*/ FD_t XfdNew(const char * msg,
const char * file, unsigned line)
/*@*/
static inline /*@null@*/
FD_t XfdNew(const char * msg, const char * file, unsigned line)
/*@globals internalState @*/
/*@modifies internalState @*/
{
FD_t fd = xcalloc(1, sizeof(*fd));
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, ...)
/*@globals fileSystem @*/
/*@modifies u, *str, fileSystem @*/
/*@globals fileSystem, internalState @*/
/*@modifies u, *str, fileSystem, internalState @*/
{
va_list ap;
int len = 0;
@ -2185,9 +2187,10 @@ static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd)
return rc;
}
static /*@null@*/ FD_t gzdOpen(const char * path, const char * fmode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
static /*@null@*/
FD_t gzdOpen(const char * path, const char * fmode)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{
FD_t fd;
gzFile *gzfile;

View File

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