#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 @*/;
}
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;
if (root == NULL)
tmp = root = p;
else {
- tmp->fts_link = p;
+ if (tmp != NULL) /* XXX can't happen */
+ tmp->fts_link = p;
tmp = p;
}
}
if (len == sp->fts_pathlen || nitems == 0)
--cp;
/*@-boundswrite@*/
- *cp = '\0';
+ if (cp != NULL) /* XXX can't happen */
+ *cp = '\0';
/*@=boundswrite@*/
}
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);
(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. */
#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) */
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 */
* @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 @*/;
* @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 @*/;
* @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
* @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 @*/;
* @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 @*/;
* @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)
/*@*/
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);
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@*/
}
}
*/
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 @*/
{
int c;
buf[0] = '\0';
- if (g) {
+ if (g != NULL) {
strncpy(buf, g, gn);
buf[gn] = '\0';
(void) expandU(mb, buf, sizeof(buf));
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);
/*@=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 @*/
{
}
/*@=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 */
}
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;
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;
*/
/*@-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))
/**
*/
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))
/**