diff options
author | jbj <devnull@localhost> | 2002-02-25 15:29:22 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-02-25 15:29:22 +0000 |
commit | 5c2e4bdc1e189f2038e315dbd09a6b504a71ec57 (patch) | |
tree | 4571d0a82dd968657d56cedd4b44b2f9a88dfbd1 | |
parent | ec53bfce3db7d7a0802cae1ff5143f9e6beaf040 (diff) | |
download | rpm-5c2e4bdc1e189f2038e315dbd09a6b504a71ec57.tar.gz rpm-5c2e4bdc1e189f2038e315dbd09a6b504a71ec57.tar.bz2 rpm-5c2e4bdc1e189f2038e315dbd09a6b504a71ec57.zip |
Annotation fiddles.
CVS patchset: 5336
CVS date: 2002/02/25 15:29:22
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | rpmdb/rpmdb.c | 6 | ||||
-rw-r--r-- | rpmdb/rpmdb.h | 9 | ||||
-rw-r--r-- | rpmio/fts.h | 46 | ||||
-rw-r--r-- | rpmio/rpmerr.h | 8 | ||||
-rw-r--r-- | rpmio/rpmio.h | 6 | ||||
-rw-r--r-- | rpmio/rpmrpc.c | 125 |
7 files changed, 154 insertions, 47 deletions
diff --git a/configure.in b/configure.in index 715ca0671..e5234f5c9 100644 --- a/configure.in +++ b/configure.in @@ -540,6 +540,7 @@ AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h) AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/param.h sys/vmount.h) AC_CHECK_HEADERS(bzlib.h libio.h zlib.h) AC_CHECK_HEADERS(err.h mcheck.h) +AC_CHECK_HEADERS(pthread.h) dnl popt w float/double needs. AC_CHECK_HEADERS(float.h) diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 56801e292..339804bc3 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -143,7 +143,9 @@ static void dbiTagsInit(void) /*@-redecl@*/ #if USE_DB1 /*@unchecked@*/ +/*@-exportheadervar -declundef @*/ extern struct _dbiVec db1vec; +/*@=exportheadervar =declundef @*/ #define DB1vec &db1vec #else #define DB1vec NULL @@ -151,7 +153,9 @@ extern struct _dbiVec db1vec; #if USE_DB2 /*@unchecked@*/ +/*@-exportheadervar -declundef @*/ extern struct _dbiVec db2vec; +/*@=exportheadervar =declundef @*/ #define DB2vec &db2vec #else #define DB2vec NULL @@ -159,7 +163,9 @@ extern struct _dbiVec db2vec; #if USE_DB3 /*@unchecked@*/ +/*@-exportheadervar -declundef @*/ extern struct _dbiVec db3vec; +/*@=exportheadervar =declundef @*/ #define DB3vec &db3vec #else #define DB3vec NULL diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index dd77a6650..4dc515010 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -352,7 +352,8 @@ extern "C" { * Return new configured index database handle instance. * @param rpmdb rpm database */ -/*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag) +/*@unused@*/ /*@only@*/ /*@null@*/ +dbiIndex db3New(rpmdb rpmdb, int rpmtag) /*@globals rpmGlobalMacroContext @*/ /*@modifies rpmGlobalMacroContext @*/; @@ -361,7 +362,8 @@ extern "C" { * @param dbi index database handle * @return NULL always */ -/*@null@*/ dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi) +/*@null@*/ +dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi) /*@*/; /** \ingroup db3 @@ -371,7 +373,8 @@ extern "C" { * @return formatted flags (static buffer) */ /*@-redecl@*/ -/*@exposed@*/ extern const char *const prDbiOpenFlags(int dbflags, +/*@exposed@*/ +extern const char *const prDbiOpenFlags(int dbflags, int print_dbenv_flags) /*@*/; /*@=redecl@*/ diff --git a/rpmio/fts.h b/rpmio/fts.h index ff97f5443..b3ddfa1cc 100644 --- a/rpmio/fts.h +++ b/rpmio/fts.h @@ -39,6 +39,7 @@ /* The fts interface is incompatible with the LFS interface which transparently uses the 64-bit file access functions. */ + #ifdef __USE_FILE_OFFSET64 # error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64" #endif @@ -57,6 +58,7 @@ typedef struct { int fts_rfd; /*!< fd for root */ int fts_pathlen; /*!< sizeof(path) */ int fts_nitems; /*!< elements in the sort array */ +/*@null@*/ int (*fts_compar) (const void *, const void *) /*@*/; /*!< compare fn */ @@ -149,23 +151,61 @@ typedef struct _ftsent { } FTSENT; __BEGIN_DECLS -/*@dependent@*/ + +/** + * Return list of children of the current node. + * @param sp file hierarchy state + * @return file set member + */ +/*@unused@*/ /*@dependent@*/ FTSENT *Fts_children (FTS * sp, int instr) __THROW /*@globals fileSystem, internalState @*/ /*@modifies *sp, fileSystem, internalState @*/; + +/** + * Destroy a file hierarchy traversal handle. + * @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 @*/; -/*@only@*/ + +/** + * Create a handle for file hierarchy traversal. + * @param argv paths that compose a logical file hierarchy + * @param options traversal options + * @param compar traversal ordering (or NULL) + * @return file hierarchy state (or NULL on error) + */ +/*@unused@*/ /*@only@*/ FTS *Fts_open (char * const * argv, int options, + /*@null@*/ int (*compar) (const FTSENT **, const FTSENT **)) __THROW /*@*/; -/*@null@*/ + +/** + * Return next node in the file hierarchy traversal. + * @param sp file hierarchy state + * @return file set member + */ +/*@unused@*/ /*@null@*/ FTSENT *Fts_read (FTS * sp) __THROW /*@globals fileSystem, internalState @*/ /*@modifies *sp, fileSystem, internalState @*/; + +/** + * Modify the traversal for a file set member. + * @param sp file hierarchy state + * @param p file set member + * @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 @*/; + __END_DECLS #endif /* fts.h */ diff --git a/rpmio/rpmerr.h b/rpmio/rpmerr.h index 93f9034e3..b3ca40685 100644 --- a/rpmio/rpmerr.h +++ b/rpmio/rpmerr.h @@ -57,8 +57,8 @@ typedef enum rpmerrCode_e { RPMERR_RPMRC = _em(24), /*!< bad line in rpmrc */ RPMERR_NOSPEC = _em(25), /*!< .spec file is missing */ RPMERR_NOTSRPM = _em(26), /*!< a source rpm was expected */ - RPMERR_FLOCK = _em(27), /*!< locking the database failed */ /*@-enummemuse@*/ + RPMERR_FLOCK = _em(27), /*!< locking the database failed */ RPMERR_OLDPACKAGE = _em(28), /*!< trying upgrading to old version */ /* RPMERR_BADARCH = _em(29), bad architecture or arch mismatch */ /*@=enummemuse@*/ @@ -105,11 +105,11 @@ typedef enum rpmerrCode_e { RPMERR_QUERY = _em(124), /*!< */ RPMERR_QFMT = _em(125), /*!< */ RPMERR_DBCONFIG = _em(126), /*!< */ - RPMERR_DBERR = _em(127), /*!< */ /*@-enummemuse@*/ + RPMERR_DBERR = _em(127), /*!< */ RPMERR_BADPACKAGE = _em(128), /*!< getNextHeader: %s */ -/*@=enummemuse@*/ RPMERR_FREELIST = _em(129), /*!< free list corrupt (%u)- please ... */ +/*@=enummemuse@*/ RPMERR_DATATYPE = _em(130), /*!< Data type %d not supported */ RPMERR_BUILDROOT = _em(131), /*!< */ RPMERR_MAKETEMP = _em(132), /*!< makeTempFile failed */ @@ -130,7 +130,9 @@ typedef enum rpmerrCode_e { RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */ RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */ +/*@-enummemuse@*/ RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */ +/*@=enummemuse@*/ } rpmerrCode; /*@=typeuse @*/ diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index af5b8c601..3726fb69a 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -298,6 +298,7 @@ int Fileno(FD_t fd) /** * fcntl(2) clone. */ +/*@unused@*/ int Fcntl(FD_t fd, int op, void *lip) /*@globals fileSystem @*/ /*@modifies fd, *lip, fileSystem @*/; @@ -408,14 +409,15 @@ DIR * Opendir(const char * path) /** * readdir(3) clone. */ -/*@null@*/ struct dirent * Readdir(DIR * dir) +/*@null@*/ +struct dirent * Readdir(DIR * dir) /*@globals fileSystem @*/ /*@modifies *dir, fileSystem @*/; /** * closedir(3) clone. */ -int Closedir(/*@only@*/ DIR * dir) +int Closedir(/*@only@*/ DIR * dir) /*@globals fileSystem @*/ /*@modifies *dir, fileSystem @*/; diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c index 17483b50b..f1f2bc30d 100644 --- a/rpmio/rpmrpc.c +++ b/rpmio/rpmrpc.c @@ -4,7 +4,11 @@ */ #include "system.h" + +#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__) #include <pthread.h> +#endif + #include <rpmio_internal.h> #include <popt.h> #include "ugid.h" @@ -1006,34 +1010,40 @@ exit: } /*@=mods@*/ -static const char * statstr(struct stat * st) +static const char * statstr(const struct stat * st, + /*@returned@*/ /*@out@*/ char * buf) + /*@modifies *buf @*/ { - static char buf[1024]; -sprintf(buf, "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n", -(unsigned)st->st_dev, -(unsigned)st->st_ino, -st->st_mode, -st->st_nlink, -st->st_uid, -st->st_gid, -(unsigned)st->st_rdev, -(unsigned)st->st_size); + sprintf(buf, + "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n", + (unsigned)st->st_dev, + (unsigned)st->st_ino, + st->st_mode, + st->st_nlink, + st->st_uid, + st->st_gid, + (unsigned)st->st_rdev, + (unsigned)st->st_size); return buf; } -static int ftp_st_ino = 0x1000; +/*@unchecked@*/ +static int ftp_st_ino = 0xdead0000; static int ftpStat(const char * path, /*@out@*/ struct stat *st) /*@globals fileSystem @*/ /*@modifies *st, fileSystem @*/ { + char buf[1024]; int rc; rc = ftpNLST(path, DO_FTP_STAT, st, NULL, 0); -if (_ftp_debug) -fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st)); /* XXX fts(3) needs/uses st_ino, make something up for now. */ + /*@-mods@*/ if (st->st_ino == 0) st->st_ino = ftp_st_ino++; + /*@=mods@*/ +if (_ftp_debug) +fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf)); return rc; } @@ -1041,14 +1051,16 @@ static int ftpLstat(const char * path, /*@out@*/ struct stat *st) /*@globals fileSystem @*/ /*@modifies *st, fileSystem @*/ { + char buf[1024]; int rc; rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0); -if (_ftp_debug) -fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st)); -st->st_ino = ftp_st_ino++; /* XXX fts(3) needs/uses st_ino, make something up for now. */ + /*@-mods@*/ if (st->st_ino == 0) st->st_ino = ftp_st_ino++; + /*@=mods@*/ +if (_ftp_debug) +fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf)); return rc; } @@ -1070,13 +1082,19 @@ struct __dirstream { size_t size; /* Total valid data in the block. */ size_t offset; /* Current offset into the block. */ off_t filepos; /* Position of next entry to read. */ +#if defined(HAVE_PTHREAD_H) && !defined(__LCLINT__) pthread_mutex_t lock; /* Mutex lock for this structure. */ +#endif }; +/*@unchecked@*/ static int ftpmagicdir = 0x8440291; #define ISFTPMAGIC(_dir) (!memcmp((_dir), &ftpmagicdir, sizeof(ftpmagicdir))) +/*@null@*/ static DIR * ftpOpendir(const char * path) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/ { DIR * dir; struct dirent * dp; @@ -1108,11 +1126,11 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); switch (c) { case '/': sb = se; - break; + /*@switchbreak@*/ break; case '\r': if (sb == NULL) { for (sb = se; sb > s && sb[-1] != ' '; sb--) - ; + {}; } ac++; nb += (se - sb); @@ -1120,18 +1138,20 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); if (*se == '\n') se++; sb = NULL; s = se; - break; + /*@switchbreak@*/ break; default: - break; + /*@switchbreak@*/ break; } } nb += sizeof(*dir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1); dir = xcalloc(1, nb); + /*@-abstract@*/ dp = (struct dirent *) (dir + 1); av = (const char **) (dp + 1); dt = (char *) (av + (ac + 1)); t = (char *) (dt + ac + 1); + /*@=abstract@*/ dir->fd = ftpmagicdir; dir->data = (char *) dp; @@ -1141,8 +1161,10 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); dir->filepos = 0; ac = 0; + /*@-dependenttrans -unrecog@*/ dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, "."); t++; dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++; + /*@=dependenttrans =unrecog@*/ sb = NULL; s = se = ftpBuf; while ((c = *se) != '\0') { @@ -1150,22 +1172,42 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); switch (c) { case '/': sb = se; - break; + /*@switchbreak@*/ break; case '\r': + /*@-dependenttrans@*/ av[ac] = t; + /*@=dependenttrans@*/ if (sb == NULL) { + /*@-unrecog@*/ switch(*s) { - case 'p': dt[ac] = DT_FIFO; break; - case 'c': dt[ac] = DT_CHR; break; - case 'd': dt[ac] = DT_DIR; break; - case 'b': dt[ac] = DT_BLK; break; - case '-': dt[ac] = DT_REG; break; - case 'l': dt[ac] = DT_LNK; break; - case 's': dt[ac] = DT_SOCK; break; - default: dt[ac] = DT_UNKNOWN; break; + case 'p': + dt[ac] = DT_FIFO; + /*@innerbreak@*/ break; + case 'c': + dt[ac] = DT_CHR; + /*@innerbreak@*/ break; + case 'd': + dt[ac] = DT_DIR; + /*@innerbreak@*/ break; + case 'b': + dt[ac] = DT_BLK; + /*@innerbreak@*/ break; + case '-': + dt[ac] = DT_REG; + /*@innerbreak@*/ break; + case 'l': + dt[ac] = DT_LNK; + /*@innerbreak@*/ break; + case 's': + dt[ac] = DT_SOCK; + /*@innerbreak@*/ break; + default: + dt[ac] = DT_UNKNOWN; + /*@innerbreak@*/ break; } + /*@=unrecog@*/ for (sb = se; sb > s && sb[-1] != ' '; sb--) - ; + {}; } ac++; t = stpncpy(t, sb, (se - sb)); @@ -1173,9 +1215,9 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); if (*se == '\n') se++; sb = NULL; s = se; - break; + /*@switchbreak@*/ break; default: - break; + /*@switchbreak@*/ break; } } av[ac] = NULL; @@ -1183,7 +1225,10 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); return dir; } +/*@null@*/ static struct dirent * ftpReaddir(DIR * dir) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/ { struct dirent * dp; const char ** av; @@ -1191,10 +1236,12 @@ static struct dirent * ftpReaddir(DIR * dir) int ac; int i; + /*@+voidabstract@*/ if (dir == NULL || !ISFTPMAGIC(dir) || dir->data == NULL) { /* XXX TODO: EBADF errno. */ return NULL; } + /*@=voidabstract@*/ dp = (struct dirent *) dir->data; av = (const char **) (dp + 1); @@ -1214,21 +1261,27 @@ static struct dirent * ftpReaddir(DIR * dir) dp->d_type = dt[i]; strncpy(dp->d_name, av[i], sizeof(dp->d_name)); +/*@+voidabstract@*/ if (_ftp_debug) -fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", dir, dp, dp->d_name); +fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", (void *)dir, dp, dp->d_name); +/*@=voidabstract@*/ return dp; } -static int ftpClosedir(DIR * dir) +static int ftpClosedir(/*@only@*/ DIR * dir) + /*@globals fileSystem @*/ + /*@modifies dir, fileSystem @*/ { + /*@+voidabstract@*/ if (_ftp_debug) -fprintf(stderr, "*** ftpClosedir(%p)\n", dir); +fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)dir); if (dir == NULL || !ISFTPMAGIC(dir)) { /* XXX TODO: EBADF errno. */ return -1; } free((void *)dir); + /*@=voidabstract@*/ dir = NULL; return 0; } |