Remove splint tags.

This commit is contained in:
Ralf Corsépius 2007-09-11 16:48:54 +02:00
parent 1a01bdd6c6
commit f982bbaa79
42 changed files with 820 additions and 2768 deletions

View File

@ -8,15 +8,13 @@
#include "debug.h" #include "debug.h"
/*@-bounds@*/
/** /**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free * @param p memory to free
* @return NULL always * @return NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ static inline
void * _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) void * _free(const void * p)
/*@modifies p @*/
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
@ -47,15 +45,13 @@ ARGI_t argiFree(ARGI_t argi)
return NULL; return NULL;
} }
ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv) ARGV_t argvFree(ARGV_t argv)
{ {
ARGV_t av; ARGV_t av;
/*@-branchstate@*/
if (argv) if (argv)
for (av = argv; *av; av++) for (av = argv; *av; av++)
*av = _free(*av); *av = _free(*av);
/*@=branchstate@*/
argv = _free(argv); argv = _free(argv);
return NULL; return NULL;
} }
@ -87,17 +83,13 @@ int argvCount(const ARGV_t argv)
ARGV_t argvData(const ARGV_t argv) ARGV_t argvData(const ARGV_t argv)
{ {
/*@-retalias -temptrans @*/
return argv; return argv;
/*@=retalias =temptrans @*/
} }
int argvCmp(const void * a, const void * b) int argvCmp(const void * a, const void * b)
{ {
/*@-boundsread@*/
ARGstr_t astr = *(ARGV_t)a; ARGstr_t astr = *(ARGV_t)a;
ARGstr_t bstr = *(ARGV_t)b; ARGstr_t bstr = *(ARGV_t)b;
/*@=boundsread@*/
return strcmp(astr, bstr); return strcmp(astr, bstr);
} }
@ -119,7 +111,7 @@ ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
return bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar); return bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar);
} }
int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val) int argiAdd(ARGI_t * argip, int ix, int val)
{ {
ARGI_t argi; ARGI_t argi;
@ -140,7 +132,7 @@ int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
return 0; return 0;
} }
int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val) int argvAdd(ARGV_t * argvp, ARGstr_t val)
{ {
ARGV_t argv; ARGV_t argv;
int argc; int argc;
@ -148,16 +140,14 @@ int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
if (argvp == NULL) if (argvp == NULL)
return -1; return -1;
argc = argvCount(*argvp); argc = argvCount(*argvp);
/*@-unqualifiedtrans@*/
*argvp = xrealloc(*argvp, (argc + 1 + 1) * sizeof(**argvp)); *argvp = xrealloc(*argvp, (argc + 1 + 1) * sizeof(**argvp));
/*@=unqualifiedtrans@*/
argv = *argvp; argv = *argvp;
argv[argc++] = xstrdup(val); argv[argc++] = xstrdup(val);
argv[argc ] = NULL; argv[argc ] = NULL;
return 0; return 0;
} }
int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av) int argvAppend(ARGV_t * argvp, const ARGV_t av)
{ {
ARGV_t argv = *argvp; ARGV_t argv = *argvp;
int argc = argvCount(argv); int argc = argvCount(argv);
@ -200,8 +190,5 @@ int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
} }
argv[c] = NULL; argv[c] = NULL;
*argvp = argv; *argvp = argv;
/*@-nullstate@*/
return 0; return 0;
/*@=nullstate@*/
} }
/*@=bounds@*/

View File

@ -25,61 +25,49 @@ extern "C" {
* @param argv argv array * @param argv argv array
* @param fp output file handle (NULL uses stderr) * @param fp output file handle (NULL uses stderr)
*/ */
void argvPrint(const char * msg, ARGV_t argv, FILE * fp) void argvPrint(const char * msg, ARGV_t argv, FILE * fp);
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** /**
* Destroy an argi array. * Destroy an argi array.
* @param argi argi array * @param argi argi array
* @return NULL always * @return NULL always
*/ */
/*@null@*/ ARGI_t argiFree(ARGI_t argi);
ARGI_t argiFree(/*@only@*/ /*@null@*/ ARGI_t argi)
/*@modifies argi @*/;
/** /**
* Destroy an argv array. * Destroy an argv array.
* @param argv argv array * @param argv argv array
* @return NULL always * @return NULL always
*/ */
/*@null@*/ ARGV_t argvFree(ARGV_t argv);
ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv)
/*@modifies argv @*/;
/** /**
* Return no. of elements in argi array. * Return no. of elements in argi array.
* @param argi argi array * @param argi argi array
* @return no. of elements * @return no. of elements
*/ */
int argiCount(/*@null@*/ const ARGI_t argi) int argiCount(const ARGI_t argi);
/*@*/;
/** /**
* Return data from argi array. * Return data from argi array.
* @param argi argi array * @param argi argi array
* @return argi array data address * @return argi array data address
*/ */
/*@null@*/ ARGint_t argiData(const ARGI_t argi);
ARGint_t argiData(/*@null@*/ const ARGI_t argi)
/*@*/;
/** /**
* Return no. of elements in argv array. * Return no. of elements in argv array.
* @param argv argv array * @param argv argv array
* @return no. of elements * @return no. of elements
*/ */
int argvCount(/*@null@*/ const ARGV_t argv) int argvCount(const ARGV_t argv);
/*@*/;
/** /**
* Return data from argv array. * Return data from argv array.
* @param argv argv array * @param argv argv array
* @return argv array data address * @return argv array data address
*/ */
/*@null@*/ ARGV_t argvData(const ARGV_t argv);
ARGV_t argvData(/*@null@*/ const ARGV_t argv)
/*@*/;
/** /**
* Compare argv arrays (qsort/bsearch). * Compare argv arrays (qsort/bsearch).
@ -87,10 +75,7 @@ ARGV_t argvData(/*@null@*/ const ARGV_t argv)
* @param b 2nd instance address * @param b 2nd instance address
* @return result of comparison * @return result of comparison
*/ */
/*@-exportlocal@*/ int argvCmp(const void * a, const void * b);
int argvCmp(const void * a, const void * b)
/*@*/;
/*@=exportlocal@*/
/** /**
* Sort an argv array. * Sort an argv array.
@ -98,8 +83,7 @@ int argvCmp(const void * a, const void * b)
* @param compar strcmp-like comparison function, or NULL for argvCmp() * @param compar strcmp-like comparison function, or NULL for argvCmp()
* @return 0 always * @return 0 always
*/ */
int argvSort(ARGV_t argv, int (*compar)(const void *, const void *)) int argvSort(ARGV_t argv, int (*compar)(const void *, const void *));
/*@modifies *argv @*/;
/** /**
* Find an element in an argv array. * Find an element in an argv array.
@ -108,10 +92,8 @@ int argvSort(ARGV_t argv, int (*compar)(const void *, const void *))
* @param compar strcmp-like comparison function, or NULL for argvCmp() * @param compar strcmp-like comparison function, or NULL for argvCmp()
* @return found string (NULL on failure) * @return found string (NULL on failure)
*/ */
/*@dependent@*/ /*@null@*/
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
int (*compar)(const void *, const void *)) int (*compar)(const void *, const void *));
/*@*/;
/** /**
* Add an int to an argi array. * Add an int to an argi array.
@ -120,8 +102,7 @@ ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
* @param val int arg to add * @param val int arg to add
* @return 0 always * @return 0 always
*/ */
int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val) int argiAdd(ARGI_t * argip, int ix, int val);
/*@modifies *argip @*/;
/** /**
* Add a string to an argv array. * Add a string to an argv array.
@ -129,8 +110,7 @@ int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
* @param val string arg to append * @param val string arg to append
* @return 0 always * @return 0 always
*/ */
int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val) int argvAdd(ARGV_t * argvp, ARGstr_t val);
/*@modifies *argvp @*/;
/** /**
* Append one argv array to another. * Append one argv array to another.
@ -138,8 +118,7 @@ int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
* @param av argv array to append * @param av argv array to append
* @return 0 always * @return 0 always
*/ */
int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av) int argvAppend(ARGV_t * argvp, const ARGV_t av);
/*@modifies *argvp @*/;
/** /**
* Split a string into an argv array. * Split a string into an argv array.
@ -148,8 +127,7 @@ int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av)
* @param seps seperator characters * @param seps seperator characters
* @return 0 always * @return 0 always
*/ */
int argvSplit(ARGV_t * argvp, const char * str, const char * seps) int argvSplit(ARGV_t * argvp, const char * str, const char * seps);
/*@modifies *argvp @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -12,7 +12,6 @@
#define DPRINTF(_a) #define DPRINTF(_a)
#endif #endif
/*@access DIGEST_CTX@*/
/** /**
* MD5/SHA1 digest private data. * MD5/SHA1 digest private data.
@ -27,11 +26,10 @@ struct DIGEST_CTX_s {
/*@modifies param @*/; /*!< Digest initialize. */ /*@modifies param @*/; /*!< Digest initialize. */
int (*Update) (void * param, const byte * data, size_t size) int (*Update) (void * param, const byte * data, size_t size)
/*@modifies param @*/; /*!< Digest transform. */ /*@modifies param @*/; /*!< Digest transform. */
int (*Digest) (void * param, /*@out@*/ byte * digest) int (*Digest) (void * param, byte * digest)
/*@modifies param, digest @*/; /*!< Digest finish. */ /*@modifies param, digest @*/; /*!< Digest finish. */
}; };
/*@-boundsread@*/
DIGEST_CTX DIGEST_CTX
rpmDigestDup(DIGEST_CTX octx) rpmDigestDup(DIGEST_CTX octx)
{ {
@ -40,7 +38,6 @@ rpmDigestDup(DIGEST_CTX octx)
nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen); nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
return nctx; return nctx;
} }
/*@=boundsread@*/
DIGEST_CTX DIGEST_CTX
rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags) rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
@ -54,68 +51,58 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
case PGPHASHALGO_MD5: case PGPHASHALGO_MD5:
ctx->digestlen = 16; ctx->digestlen = 16;
ctx->datalen = 64; ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(md5Param); ctx->paramlen = sizeof(md5Param);
/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /* FIX: cast? */
ctx->Reset = (void *) md5Reset; ctx->Reset = (void *) md5Reset;
ctx->Update = (void *) md5Update; ctx->Update = (void *) md5Update;
ctx->Digest = (void *) md5Digest; ctx->Digest = (void *) md5Digest;
/*@=type@*/
break; break;
case PGPHASHALGO_SHA1: case PGPHASHALGO_SHA1:
ctx->digestlen = 20; ctx->digestlen = 20;
ctx->datalen = 64; ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha1Param); ctx->paramlen = sizeof(sha1Param);
/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /* FIX: cast? */
ctx->Reset = (void *) sha1Reset; ctx->Reset = (void *) sha1Reset;
ctx->Update = (void *) sha1Update; ctx->Update = (void *) sha1Update;
ctx->Digest = (void *) sha1Digest; ctx->Digest = (void *) sha1Digest;
/*@=type@*/
break; break;
#if HAVE_BEECRYPT_API_H #if HAVE_BEECRYPT_API_H
case PGPHASHALGO_SHA256: case PGPHASHALGO_SHA256:
ctx->digestlen = 32; ctx->digestlen = 32;
ctx->datalen = 64; ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha256Param); ctx->paramlen = sizeof(sha256Param);
/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /* FIX: cast? */
ctx->Reset = (void *) sha256Reset; ctx->Reset = (void *) sha256Reset;
ctx->Update = (void *) sha256Update; ctx->Update = (void *) sha256Update;
ctx->Digest = (void *) sha256Digest; ctx->Digest = (void *) sha256Digest;
/*@=type@*/
break; break;
case PGPHASHALGO_SHA384: case PGPHASHALGO_SHA384:
ctx->digestlen = 48; ctx->digestlen = 48;
ctx->datalen = 128; ctx->datalen = 128;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha384Param); ctx->paramlen = sizeof(sha384Param);
/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /* FIX: cast? */
ctx->Reset = (void *) sha384Reset; ctx->Reset = (void *) sha384Reset;
ctx->Update = (void *) sha384Update; ctx->Update = (void *) sha384Update;
ctx->Digest = (void *) sha384Digest; ctx->Digest = (void *) sha384Digest;
/*@=type@*/
break; break;
case PGPHASHALGO_SHA512: case PGPHASHALGO_SHA512:
ctx->digestlen = 64; ctx->digestlen = 64;
ctx->datalen = 128; ctx->datalen = 128;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */ /* FIX: union, not void pointer */
ctx->paramlen = sizeof(sha512Param); ctx->paramlen = sizeof(sha512Param);
/*@=sizeoftype@*/
ctx->param = xcalloc(1, ctx->paramlen); ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */ /* FIX: cast? */
ctx->Reset = (void *) sha512Reset; ctx->Reset = (void *) sha512Reset;
ctx->Update = (void *) sha512Update; ctx->Update = (void *) sha512Update;
ctx->Digest = (void *) sha512Digest; ctx->Digest = (void *) sha512Digest;
/*@=type@*/
break; break;
#endif #endif
case PGPHASHALGO_RIPEMD160: case PGPHASHALGO_RIPEMD160:
@ -125,18 +112,16 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
default: default:
free(ctx); free(ctx);
return NULL; return NULL;
/*@notreached@*/ break; break;
} }
/*@-boundsread@*/
xx = (*ctx->Reset) (ctx->param); xx = (*ctx->Reset) (ctx->param);
/*@=boundsread@*/
DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param)); DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param));
return ctx; return ctx;
} }
/*@-mustmod@*/ /* LCL: ctx->param may be modified, but ctx is abstract @*/ /* LCL: ctx->param may be modified, but ctx is abstract @*/
int int
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
{ {
@ -144,13 +129,9 @@ rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
return -1; return -1;
DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data))); 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); return (*ctx->Update) (ctx->param, data, len);
/*@=boundsread@*/
} }
/*@=mustmod@*/
/*@-boundswrite@*/
int int
rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii) rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
{ {
@ -163,12 +144,10 @@ rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
digest = xmalloc(ctx->digestlen); digest = xmalloc(ctx->digestlen);
DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest)); DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest));
/*@-noeffectuncon@*/ /* FIX: check rc */ /* FIX: check rc */
(void) (*ctx->Digest) (ctx->param, digest); (void) (*ctx->Digest) (ctx->param, digest);
/*@=noeffectuncon@*/
/* Return final digest. */ /* Return final digest. */
/*@-branchstate@*/
if (!asAscii) { if (!asAscii) {
if (lenp) *lenp = ctx->digestlen; if (lenp) *lenp = ctx->digestlen;
if (datap) { if (datap) {
@ -189,7 +168,6 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp
*t = '\0'; *t = '\0';
} }
} }
/*@=branchstate@*/
if (digest) { if (digest) {
memset(digest, 0, ctx->digestlen); /* In case it's sensitive */ memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
free(digest); free(digest);
@ -200,4 +178,3 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp
free(ctx); free(ctx);
return 0; return 0;
} }
/*@=boundswrite@*/

View File

@ -1,6 +1,3 @@
/*@-boundsread@*/
/*@-sysunrecog -noeffectuncon -nullpass -sizeoftype -unrecog -usereleased @*/
/*@-compdef -compmempass -dependenttrans -retalias @*/
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -87,31 +84,17 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#endif #endif
/*@only@*/ /*@null@*/ static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen);
static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen) static FTSENT * fts_build(FTS * sp, int type);
/*@*/; static void fts_lfree(FTSENT * head);
/*@null@*/ static void fts_load(FTS * sp, FTSENT * p);
static FTSENT * fts_build(FTS * sp, int type) static size_t fts_maxarglen(char * const * argv);
/*@globals fileSystem, internalState @*/ static void fts_padjust(FTS * sp, FTSENT * head);
/*@modifies *sp, fileSystem, internalState @*/; static int fts_palloc(FTS * sp, size_t more);
static void fts_lfree(/*@only@*/ FTSENT * head) static FTSENT * fts_sort(FTS * sp, FTSENT * head, int nitems);
/*@modifies head @*/; static u_short fts_stat(FTS * sp, FTSENT * p, int follow);
static void fts_load(FTS * sp, FTSENT * p)
/*@modifies *sp, *p @*/;
static size_t fts_maxarglen(char * const * argv)
/*@*/;
static void fts_padjust(FTS * sp, FTSENT * head)
/*@modifies *sp, *head @*/;
static int fts_palloc(FTS * sp, size_t more)
/*@modifies *sp @*/;
static FTSENT * fts_sort(FTS * sp, /*@returned@*/ FTSENT * head, int nitems)
/*@modifies *sp @*/;
static u_short fts_stat(FTS * sp, FTSENT * p, int follow)
/*@modifies *p @*/;
static int fts_safe_changedir(FTS * sp, FTSENT * p, int fd, static int fts_safe_changedir(FTS * sp, FTSENT * p, int fd,
const char * path) const char * path);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
#ifndef MAX #ifndef MAX
#define MAX(a, b) ({ __typeof__ (a) _a = (a); \ #define MAX(a, b) ({ __typeof__ (a) _a = (a); \
@ -144,9 +127,7 @@ Fts_open(char * const * argv, int options,
/* Options check. */ /* Options check. */
if (options & ~FTS_OPTIONMASK) { if (options & ~FTS_OPTIONMASK) {
/*@-boundswrite@*/
__set_errno (EINVAL); __set_errno (EINVAL);
/*@=boundswrite@*/
return (NULL); return (NULL);
} }
@ -185,9 +166,7 @@ Fts_open(char * const * argv, int options,
for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
/* Don't allow zero-length paths. */ /* Don't allow zero-length paths. */
if ((len = strlen(*argv)) == 0) { if ((len = strlen(*argv)) == 0) {
/*@-boundswrite@*/
__set_errno (ENOENT); __set_errno (ENOENT);
/*@=boundswrite@*/
goto mem3; goto mem3;
} }
@ -195,19 +174,17 @@ Fts_open(char * const * argv, int options,
switch (urlIsURL(*argv)) { switch (urlIsURL(*argv)) {
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
/*@-boundswrite@*/
__set_errno (ENOENT); __set_errno (ENOENT);
/*@=boundswrite@*/
goto mem3; goto mem3;
/*@notreached@*/ /*@switchbreak@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
case URL_IS_FTP: case URL_IS_FTP:
SET(FTS_NOCHDIR); SET(FTS_NOCHDIR);
/*@switchbreak@*/ break; break;
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
case URL_IS_PATH: case URL_IS_PATH:
/*@switchbreak@*/ break; break;
} }
p = fts_alloc(sp, *argv, len); p = fts_alloc(sp, *argv, len);
@ -240,10 +217,8 @@ Fts_open(char * const * argv, int options,
} }
} }
} }
/*@-branchstate@*/
if (compar && nitems > 1) if (compar && nitems > 1)
root = fts_sort(sp, root, nitems); root = fts_sort(sp, root, nitems);
/*@=branchstate@*/
/* /*
* Allocate a dummy pointer and make fts_read think that we've just * Allocate a dummy pointer and make fts_read think that we've just
@ -289,7 +264,6 @@ fts_load(FTS * sp, FTSENT * p)
* known that the path will fit. * known that the path will fit.
*/ */
len = p->fts_pathlen = p->fts_namelen; len = p->fts_pathlen = p->fts_namelen;
/*@-boundswrite@*/
memmove(sp->fts_path, p->fts_name, len + 1); memmove(sp->fts_path, p->fts_name, len + 1);
if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
len = strlen(++cp); len = strlen(++cp);
@ -298,7 +272,6 @@ fts_load(FTS * sp, FTSENT * p)
} }
p->fts_accpath = p->fts_path = sp->fts_path; p->fts_accpath = p->fts_path = sp->fts_path;
sp->fts_dev = p->fts_dev; sp->fts_dev = p->fts_dev;
/*@=boundswrite@*/
} }
int int
@ -315,7 +288,6 @@ Fts_close(FTS * sp)
* points to the root list, so we step through to the end of the root * points to the root list, so we step through to the end of the root
* list which has a valid parent pointer. * list which has a valid parent pointer.
*/ */
/*@-branchstate@*/
if (sp->fts_cur) { if (sp->fts_cur) {
for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
freep = p; freep = p;
@ -324,7 +296,6 @@ Fts_close(FTS * sp)
} }
free(p); free(p);
} }
/*@=branchstate@*/
/* Free up child linked list, sort array, path buffer. */ /* Free up child linked list, sort array, path buffer. */
if (sp->fts_child) if (sp->fts_child)
@ -342,9 +313,7 @@ Fts_close(FTS * sp)
if (saved_errno != 0) { if (saved_errno != 0) {
/* Free up the stream pointer. */ /* Free up the stream pointer. */
free(sp); free(sp);
/*@-boundswrite@*/
__set_errno (saved_errno); __set_errno (saved_errno);
/*@=boundswrite@*/
return (-1); return (-1);
} }
} }
@ -461,7 +430,6 @@ Fts_read(FTS * sp)
} }
/* Move to the next node on this level. */ /* Move to the next node on this level. */
/*@-boundswrite@*/
next: tmp = p; next: tmp = p;
if ((p = p->fts_link) != NULL) { if ((p = p->fts_link) != NULL) {
free(tmp); free(tmp);
@ -486,7 +454,6 @@ next: tmp = p;
*/ */
if (p->fts_instr == FTS_SKIP) if (p->fts_instr == FTS_SKIP)
goto next; goto next;
/*@-branchstate@*/
if (p->fts_instr == FTS_FOLLOW) { if (p->fts_instr == FTS_FOLLOW) {
p->fts_info = fts_stat(sp, p, 1); p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
@ -499,7 +466,6 @@ next: tmp = p;
} }
p->fts_instr = FTS_NOINSTR; p->fts_instr = FTS_NOINSTR;
} }
/*@=branchstate@*/
name: t = sp->fts_path + NAPPEND(p->fts_parent); name: t = sp->fts_path + NAPPEND(p->fts_parent);
*t++ = '/'; *t++ = '/';
@ -523,7 +489,6 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
/* NUL terminate the pathname. */ /* NUL terminate the pathname. */
sp->fts_path[p->fts_pathlen] = '\0'; sp->fts_path[p->fts_pathlen] = '\0';
/*@=boundswrite@*/
/* /*
* Return to the parent directory. If at a root node or came through * Return to the parent directory. If at a root node or came through
@ -539,9 +504,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
if (FCHDIR(sp, p->fts_symfd)) { if (FCHDIR(sp, p->fts_symfd)) {
saved_errno = errno; saved_errno = errno;
(void)__close(p->fts_symfd); (void)__close(p->fts_symfd);
/*@-boundswrite@*/
__set_errno (saved_errno); __set_errno (saved_errno);
/*@=boundswrite@*/
SET(FTS_STOP); SET(FTS_STOP);
return (NULL); return (NULL);
} }
@ -562,13 +525,11 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
* reasons. * reasons.
*/ */
int int
Fts_set(/*@unused@*/ FTS * sp, FTSENT * p, int instr) Fts_set(FTS * sp, FTSENT * p, int instr)
{ {
if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
instr != FTS_NOINSTR && instr != FTS_SKIP) { instr != FTS_NOINSTR && instr != FTS_SKIP) {
/*@-boundswrite@*/
__set_errno (EINVAL); __set_errno (EINVAL);
/*@=boundswrite@*/
return (1); return (1);
} }
p->fts_instr = instr; p->fts_instr = instr;
@ -582,9 +543,7 @@ Fts_children(FTS * sp, int instr)
int fd; int fd;
if (instr != 0 && instr != FTS_NAMEONLY) { if (instr != 0 && instr != FTS_NAMEONLY) {
/*@-boundswrite@*/
__set_errno (EINVAL); __set_errno (EINVAL);
/*@=boundswrite@*/
return (NULL); return (NULL);
} }
@ -595,9 +554,7 @@ Fts_children(FTS * sp, int instr)
* Errno set to 0 so user can distinguish empty directory from * Errno set to 0 so user can distinguish empty directory from
* an error. * an error.
*/ */
/*@-boundswrite@*/
__set_errno (0); __set_errno (0);
/*@=boundswrite@*/
/* Fatal errors stop here. */ /* Fatal errors stop here. */
if (ISSET(FTS_STOP)) if (ISSET(FTS_STOP))
@ -760,9 +717,7 @@ fts_build(FTS * sp, int type)
len = NAPPEND(cur); len = NAPPEND(cur);
if (ISSET(FTS_NOCHDIR)) { if (ISSET(FTS_NOCHDIR)) {
cp = sp->fts_path + len; cp = sp->fts_path + len;
/*@-boundswrite@*/
*cp++ = '/'; *cp++ = '/';
/*@=boundswrite@*/
} else { } else {
/* GCC, you're too verbose. */ /* GCC, you're too verbose. */
cp = NULL; cp = NULL;
@ -892,10 +847,8 @@ mem1: saved_errno = errno;
if (ISSET(FTS_NOCHDIR)) { if (ISSET(FTS_NOCHDIR)) {
if (len == sp->fts_pathlen || nitems == 0) if (len == sp->fts_pathlen || nitems == 0)
--cp; --cp;
/*@-boundswrite@*/
if (cp != NULL) /* XXX can't happen */ if (cp != NULL) /* XXX can't happen */
*cp = '\0'; *cp = '\0';
/*@=boundswrite@*/
} }
/* /*
@ -959,9 +912,7 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
if ((*sp->fts_stat) (p->fts_accpath, sbp)) { if ((*sp->fts_stat) (p->fts_accpath, sbp)) {
saved_errno = errno; saved_errno = errno;
if (!(*sp->fts_lstat) (p->fts_accpath, sbp)) { if (!(*sp->fts_lstat) (p->fts_accpath, sbp)) {
/*@-boundswrite@*/
__set_errno (0); __set_errno (0);
/*@=boundswrite@*/
return (FTS_SLNONE); return (FTS_SLNONE);
} }
p->fts_errno = saved_errno; p->fts_errno = saved_errno;
@ -969,9 +920,7 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
} }
} else if ((*sp->fts_lstat) (p->fts_accpath, sbp)) { } else if ((*sp->fts_lstat) (p->fts_accpath, sbp)) {
p->fts_errno = errno; p->fts_errno = errno;
/*@-boundswrite@*/
err: memset(sbp, 0, sizeof(*sbp)); err: memset(sbp, 0, sizeof(*sbp));
/*@=boundswrite@*/
return (FTS_NS); return (FTS_NS);
} }
@ -1037,7 +986,6 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
} }
sp->fts_array = a; sp->fts_array = a;
} }
/*@-boundswrite@*/
for (ap = sp->fts_array, p = head; p != NULL; 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),
@ -1045,7 +993,6 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
for (head = *(ap = sp->fts_array); --nitems; ++ap) for (head = *(ap = sp->fts_array); --nitems; ++ap)
ap[0]->fts_link = ap[1]; ap[0]->fts_link = ap[1];
ap[0]->fts_link = NULL; ap[0]->fts_link = NULL;
/*@=boundswrite@*/
return (head); return (head);
} }
@ -1070,10 +1017,8 @@ fts_alloc(FTS * sp, const char * name, int namelen)
return (NULL); return (NULL);
/* Copy the name and guarantee NUL termination. */ /* Copy the name and guarantee NUL termination. */
/*@-boundswrite@*/
memmove(p->fts_name, name, namelen); memmove(p->fts_name, name, namelen);
p->fts_name[namelen] = '\0'; p->fts_name[namelen] = '\0';
/*@=boundswrite@*/
if (!ISSET(FTS_NOSTAT)) if (!ISSET(FTS_NOSTAT))
p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
@ -1093,12 +1038,10 @@ fts_lfree(FTSENT * head)
register FTSENT *p; register FTSENT *p;
/* Free a linked list of structures. */ /* Free a linked list of structures. */
/*@-branchstate@*/
while ((p = head)) { while ((p = head)) {
head = head->fts_link; head = head->fts_link;
free(p); free(p);
} }
/*@=branchstate@*/
} }
/* /*
@ -1124,9 +1067,7 @@ fts_palloc(FTS * sp, size_t more)
sp->fts_path = NULL; sp->fts_path = NULL;
} }
sp->fts_path = NULL; sp->fts_path = NULL;
/*@-boundswrite@*/
__set_errno (ENAMETOOLONG); __set_errno (ENAMETOOLONG);
/*@=boundswrite@*/
return (1); return (1);
} }
p = realloc(sp->fts_path, sp->fts_pathlen); p = realloc(sp->fts_path, sp->fts_pathlen);
@ -1199,9 +1140,7 @@ fts_safe_changedir(FTS * sp, FTSENT * p, int fd, const char * path)
goto bail; goto bail;
} }
if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
/*@-boundswrite@*/
__set_errno (ENOENT); /* disinformation */ __set_errno (ENOENT); /* disinformation */
/*@=boundswrite@*/
ret = -1; ret = -1;
goto bail; goto bail;
} }
@ -1210,11 +1149,6 @@ bail:
oerrno = errno; oerrno = errno;
if (fd < 0) if (fd < 0)
(void)__close(newfd); (void)__close(newfd);
/*@-boundswrite@*/
__set_errno (oerrno); __set_errno (oerrno);
/*@=boundswrite@*/
return (ret); return (ret);
} }
/*@=compdef =compmempass =dependenttrans =retalias @*/
/*@=sysunrecog =noeffectuncon =nullpass =sizeoftype =unrecog =usereleased @*/
/*@=boundsread@*/

View File

@ -66,37 +66,21 @@
#include <dirent.h> #include <dirent.h>
typedef struct { typedef struct {
/*@owned@*/ /*@relnull@*/
struct _ftsent *fts_cur; /*!< current node */ struct _ftsent *fts_cur; /*!< current node */
/*@owned@*/ /*@null@*/
struct _ftsent *fts_child; /*!< linked list of children */ struct _ftsent *fts_child; /*!< linked list of children */
/*@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@*/ /*@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) */
int fts_nitems; /*!< elements in the sort array */ int fts_nitems; /*!< elements in the sort array */
/*@null@*/ int (*fts_compar) (const void *, const void *); /*!< compare fn */
int (*fts_compar) (const void *, const void *)
/*@*/; /*!< compare fn */
DIR * (*fts_opendir) (const char * path) DIR * (*fts_opendir) (const char * path);
/*@globals fileSystem @*/ struct dirent * (*fts_readdir) (DIR * dir);
/*@modifies fileSystem @*/; int (*fts_closedir) (DIR * dir);
struct dirent * (*fts_readdir) (DIR * dir) int (*fts_stat) (const char * path, struct stat * st);
/*@globals fileSystem @*/ int (*fts_lstat) (const char * path, struct stat * st);
/*@modifies *dir, fileSystem @*/;
int (*fts_closedir) (/*@only@*/ DIR * dir)
/*@globals fileSystem @*/
/*@modifies *dir, fileSystem @*/;
int (*fts_stat) (const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
#define FTS_LOGICAL 0x0002 /* logical walk */ #define FTS_LOGICAL 0x0002 /* logical walk */
@ -114,18 +98,12 @@ typedef struct {
} FTS; } FTS;
typedef struct _ftsent { typedef struct _ftsent {
/*@dependent@*/
struct _ftsent *fts_cycle; /*!< cycle node */ struct _ftsent *fts_cycle; /*!< cycle node */
/*@dependent@*/ /*@relnull@*/
struct _ftsent *fts_parent; /*!< parent directory */ struct _ftsent *fts_parent; /*!< parent directory */
/*@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@*/
char *fts_accpath; /*!< access path */ char *fts_accpath; /*!< access path */
/*@dependent@*/
char *fts_path; /*!< root path */ char *fts_path; /*!< root path */
int fts_errno; /*!< errno for this node */ int fts_errno; /*!< errno for this node */
int fts_symfd; /*!< fd for symlink */ int fts_symfd; /*!< fd for symlink */
@ -166,7 +144,6 @@ typedef struct _ftsent {
#define FTS_SKIP 4 /* discard node */ #define FTS_SKIP 4 /* discard node */
u_short fts_instr; /*!< fts_set() instructions */ u_short fts_instr; /*!< fts_set() instructions */
/*@dependent@*/
struct stat *fts_statp; /*!< stat(2) information */ struct stat *fts_statp; /*!< stat(2) information */
char fts_name[1]; /*!< file name */ char fts_name[1]; /*!< file name */
} FTSENT; } FTSENT;
@ -179,19 +156,16 @@ __BEGIN_DECLS
* @param instr * @param instr
* @return file set member * @return file set member
*/ */
/*@dependent@*/ /*@null@*/
FTSENT *Fts_children (FTS * sp, int instr) __THROW FTSENT *Fts_children (FTS * sp, int instr) __THROW
/*@globals fileSystem, internalState @*/ ;
/*@modifies *sp, fileSystem, internalState @*/;
/** /**
* Destroy a file hierarchy traversal handle. * Destroy a file hierarchy traversal handle.
* @param sp file hierarchy state * @param sp file hierarchy state
* @return 0 on sucess, -1 on error * @return 0 on sucess, -1 on error
*/ */
int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW int Fts_close (FTS * sp) __THROW
/*@globals fileSystem, internalState @*/ ;
/*@modifies *sp, fileSystem, internalState @*/;
/** /**
* Create a handle for file hierarchy traversal. * Create a handle for file hierarchy traversal.
@ -200,21 +174,17 @@ int Fts_close (/*@only@*/ /*@null@*/ 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)
*/ */
/*@only@*/ /*@null@*/
FTS *Fts_open (char * const * argv, int options, FTS *Fts_open (char * const * argv, int options,
/*@null@*/
int (*compar) (const FTSENT **, const FTSENT **)) __THROW int (*compar) (const FTSENT **, const FTSENT **)) __THROW
/*@*/; ;
/** /**
* Return next node in the file hierarchy traversal. * Return next node in the file hierarchy traversal.
* @param sp file hierarchy state * @param sp file hierarchy state
* @return file set member * @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 @*/;
/** /**
* Modify the traversal for a file set member. * Modify the traversal for a file set member.
@ -224,7 +194,7 @@ FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
* @return 0 on sucess, -1 on error * @return 0 on sucess, -1 on error
*/ */
int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
/*@modifies *p @*/; ;
__END_DECLS __END_DECLS

View File

@ -1,4 +1,3 @@
/*@-boundsread@*/
/** \ingroup rpmrc rpmio /** \ingroup rpmrc rpmio
* \file rpmio/macro.c * \file rpmio/macro.c
*/ */
@ -55,54 +54,38 @@ typedef FILE * FD_t;
#include "debug.h" #include "debug.h"
/*@access FD_t@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */
/*@access MacroContext@*/
/*@access MacroEntry@*/
/*@access rpmlua @*/
static struct MacroContext_s rpmGlobalMacroContext_s; static struct MacroContext_s rpmGlobalMacroContext_s;
/*@-compmempass@*/
MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s; MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s;
/*@=compmempass@*/
static struct MacroContext_s rpmCLIMacroContext_s; static struct MacroContext_s rpmCLIMacroContext_s;
/*@-compmempass@*/
MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s; MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s;
/*@=compmempass@*/
/** /**
* Macro expansion state. * Macro expansion state.
*/ */
typedef /*@abstract@*/ struct MacroBuf_s { typedef struct MacroBuf_s {
/*@kept@*/ /*@exposed@*/
const char * s; /*!< Text to expand. */ const char * s; /*!< Text to expand. */
/*@shared@*/
char * t; /*!< Expansion buffer. */ char * t; /*!< Expansion buffer. */
size_t nb; /*!< No. bytes remaining in expansion buffer. */ size_t nb; /*!< No. bytes remaining in expansion buffer. */
int depth; /*!< Current expansion depth. */ int depth; /*!< Current expansion depth. */
int macro_trace; /*!< Pre-print macro to expand? */ int macro_trace; /*!< Pre-print macro to expand? */
int expand_trace; /*!< Post-print macro expansion? */ int expand_trace; /*!< Post-print macro expansion? */
/*@kept@*/ /*@exposed@*/ /*@null@*/
void * spec; /*!< (future) %file expansion info?. */ void * spec; /*!< (future) %file expansion info?. */
/*@kept@*/ /*@exposed@*/
MacroContext mc; MacroContext mc;
} * MacroBuf; } * MacroBuf;
#define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; } #define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
/*@-exportlocal -exportheadervar@*/
#define _MAX_MACRO_DEPTH 16 #define _MAX_MACRO_DEPTH 16
/*@unchecked@*/
int max_macro_depth = _MAX_MACRO_DEPTH; int max_macro_depth = _MAX_MACRO_DEPTH;
#define _PRINT_MACRO_TRACE 0 #define _PRINT_MACRO_TRACE 0
/*@unchecked@*/
int print_macro_trace = _PRINT_MACRO_TRACE; int print_macro_trace = _PRINT_MACRO_TRACE;
#define _PRINT_EXPAND_TRACE 0 #define _PRINT_EXPAND_TRACE 0
/*@unchecked@*/
int print_expand_trace = _PRINT_EXPAND_TRACE; int print_expand_trace = _PRINT_EXPAND_TRACE;
/*@=exportlocal =exportheadervar@*/
#define MACRO_CHUNK_SIZE 16 #define MACRO_CHUNK_SIZE 16
@ -118,9 +101,8 @@ static int expandMacro(MacroBuf mb)
* @param p memory to free * @param p memory to free
* @retval NULL always * @retval NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ const void * p) _free(const void * p)
/*@modifies p@*/
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
@ -136,7 +118,6 @@ _free(/*@only@*/ /*@null@*/ const void * p)
*/ */
static int static int
compareMacroName(const void * ap, const void * bp) compareMacroName(const void * ap, const void * bp)
/*@*/
{ {
MacroEntry ame = *((MacroEntry *)ap); MacroEntry ame = *((MacroEntry *)ap);
MacroEntry bme = *((MacroEntry *)bp); MacroEntry bme = *((MacroEntry *)bp);
@ -154,10 +135,8 @@ compareMacroName(const void * ap, const void * bp)
* Enlarge macro table. * Enlarge macro table.
* @param mc macro context * @param mc macro context
*/ */
/*@-boundswrite@*/
static void static void
expandMacroTable(MacroContext mc) expandMacroTable(MacroContext mc)
/*@modifies mc @*/
{ {
if (mc->macroTable == NULL) { if (mc->macroTable == NULL) {
mc->macrosAllocated = MACRO_CHUNK_SIZE; mc->macrosAllocated = MACRO_CHUNK_SIZE;
@ -172,7 +151,6 @@ expandMacroTable(MacroContext mc)
} }
memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable))); memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable)));
} }
/*@=boundswrite@*/
/** /**
* Sort entries in macro table. * Sort entries in macro table.
@ -180,7 +158,6 @@ expandMacroTable(MacroContext mc)
*/ */
static void static void
sortMacroTable(MacroContext mc) sortMacroTable(MacroContext mc)
/*@modifies mc @*/
{ {
int i; int i;
@ -239,23 +216,17 @@ rpmDumpMacroTable(MacroContext mc, FILE * fp)
* @param namelen no. of bytes * @param namelen no. of bytes
* @return address of slot in macro table with name (or NULL) * @return address of slot in macro table with name (or NULL)
*/ */
/*@-boundswrite@*/
/*@dependent@*/ /*@null@*/
static MacroEntry * static MacroEntry *
findEntry(MacroContext mc, const char * name, size_t namelen) findEntry(MacroContext mc, const char * name, size_t namelen)
/*@*/
{ {
MacroEntry key, *ret; MacroEntry key, *ret;
struct MacroEntry_s keybuf; struct MacroEntry_s keybuf;
char *namebuf = NULL; char *namebuf = NULL;
/*@-globs@*/
if (mc == NULL) mc = rpmGlobalMacroContext; if (mc == NULL) mc = rpmGlobalMacroContext;
/*@=globs@*/
if (mc->macroTable == NULL || mc->firstFree == 0) if (mc->macroTable == NULL || mc->firstFree == 0)
return NULL; return NULL;
/*@-branchstate@*/
if (namelen > 0) { if (namelen > 0) {
namebuf = alloca(namelen + 1); namebuf = alloca(namelen + 1);
memset(namebuf, 0, (namelen + 1)); memset(namebuf, 0, (namelen + 1));
@ -263,19 +234,15 @@ findEntry(MacroContext mc, const char * name, size_t namelen)
namebuf[namelen] = '\0'; namebuf[namelen] = '\0';
name = namebuf; name = namebuf;
} }
/*@=branchstate@*/
key = &keybuf; key = &keybuf;
memset(key, 0, sizeof(*key)); memset(key, 0, sizeof(*key));
/*@-temptrans -assignexpose@*/
key->name = (char *)name; key->name = (char *)name;
/*@=temptrans =assignexpose@*/
ret = (MacroEntry *) bsearch(&key, mc->macroTable, mc->firstFree, ret = (MacroEntry *) bsearch(&key, mc->macroTable, mc->firstFree,
sizeof(*(mc->macroTable)), compareMacroName); sizeof(*(mc->macroTable)), compareMacroName);
/* XXX TODO: find 1st empty slot and return that */ /* XXX TODO: find 1st empty slot and return that */
return ret; return ret;
} }
/*@=boundswrite@*/
/* =============================================================== */ /* =============================================================== */
@ -286,12 +253,8 @@ findEntry(MacroContext mc, const char * name, size_t namelen)
* @param fd file handle * @param fd file handle
* @return buffer, or NULL on end-of-file * @return buffer, or NULL on end-of-file
*/ */
/*@-boundswrite@*/
/*@null@*/
static char * static char *
rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd) rdcl(char * buf, size_t size, FD_t fd)
/*@globals fileSystem @*/
/*@modifies buf, fileSystem @*/
{ {
char *q = buf - 1; /* initialize just before buffer. */ char *q = buf - 1; /* initialize just before buffer. */
size_t nb = 0; size_t nb = 0;
@ -313,21 +276,21 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
switch (*p) { switch (*p) {
case '\\': case '\\':
switch (*(p+1)) { switch (*(p+1)) {
case '\0': /*@switchbreak@*/ break; case '\0': break;
default: p++; /*@switchbreak@*/ break; default: p++; break;
} }
/*@switchbreak@*/ break; break;
case '%': case '%':
switch (*(p+1)) { switch (*(p+1)) {
case '{': p++, bc++; /*@switchbreak@*/ break; case '{': p++, bc++; break;
case '(': p++, pc++; /*@switchbreak@*/ break; case '(': p++, pc++; break;
case '%': p++; /*@switchbreak@*/ break; case '%': p++; break;
} }
/*@switchbreak@*/ break; break;
case '{': if (bc > 0) bc++; /*@switchbreak@*/ break; case '{': if (bc > 0) bc++; break;
case '}': if (bc > 0) bc--; /*@switchbreak@*/ break; case '}': if (bc > 0) bc--; break;
case '(': if (pc > 0) pc++; /*@switchbreak@*/ break; case '(': if (pc > 0) pc++; break;
case ')': if (pc > 0) pc--; /*@switchbreak@*/ break; case ')': if (pc > 0) pc--; break;
} }
} }
if (nb == 0 || (*q != '\\' && !bc && !pc) || *(q+1) == '\0') { if (nb == 0 || (*q != '\\' && !bc && !pc) || *(q+1) == '\0') {
@ -341,7 +304,6 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
} while (size > 0); } while (size > 0);
return (nread > 0 ? buf : NULL); return (nread > 0 ? buf : NULL);
} }
/*@=boundswrite@*/
/** /**
* Return text between pl and matching pr characters. * Return text between pl and matching pr characters.
@ -350,10 +312,8 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
* @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)
/*@*/
{ {
int lvl = 0; int lvl = 0;
char c; char c;
@ -379,8 +339,6 @@ matchchar(const char * p, char pl, char pr)
*/ */
static void static void
printMacro(MacroBuf mb, const char * s, const char * se) printMacro(MacroBuf mb, const char * s, const char * se)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
const char *senl; const char *senl;
const char *ellipsis; const char *ellipsis;
@ -423,8 +381,6 @@ printMacro(MacroBuf mb, const char * s, const char * se)
*/ */
static void static void
printExpansion(MacroBuf mb, const char * t, const char * te) printExpansion(MacroBuf mb, const char * t, const char * te)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
const char *ellipsis; const char *ellipsis;
int choplen; int choplen;
@ -463,13 +419,11 @@ printExpansion(MacroBuf mb, const char * t, const char * te)
/*@-globs@*/ /* FIX: __ctype_b */ \ /*@-globs@*/ /* FIX: __ctype_b */ \
while (((_c) = *(_s)) && isblank(_c)) \ while (((_c) = *(_s)) && isblank(_c)) \
(_s)++; \ (_s)++; \
/*@=globs@*/
#define SKIPNONBLANK(_s, _c) \ #define SKIPNONBLANK(_s, _c) \
/*@-globs@*/ /* FIX: __ctype_b */ \ /*@-globs@*/ /* FIX: __ctype_b */ \
while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \ while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \
(_s)++; \ (_s)++; \
/*@=globs@*/
#define COPYNAME(_ne, _s, _c) \ #define COPYNAME(_ne, _s, _c) \
{ SKIPBLANK(_s,_c); \ { SKIPBLANK(_s,_c); \
@ -497,8 +451,6 @@ printExpansion(MacroBuf mb, const char * t, const char * te)
*/ */
static int static int
expandT(MacroBuf mb, const char * f, size_t flen) expandT(MacroBuf mb, const char * f, size_t flen)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem@*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
{ {
char *sbuf; char *sbuf;
const char *s = mb->s; const char *s = mb->s;
@ -525,8 +477,6 @@ expandT(MacroBuf mb, const char * f, size_t flen)
*/ */
static int static int
expandS(MacroBuf mb, char * tbuf, size_t tbuflen) expandS(MacroBuf mb, char * tbuf, size_t tbuflen)
/*@globals rpmGlobalMacroContext, fileSystem@*/
/*@modifies mb, *tbuf, rpmGlobalMacroContext, fileSystem @*/
{ {
const char *t = mb->t; const char *t = mb->t;
size_t nb = mb->nb; size_t nb = mb->nb;
@ -548,11 +498,8 @@ expandS(MacroBuf mb, char * tbuf, size_t tbuflen)
* @param ulen no. bytes in u buffer * @param ulen no. bytes in u buffer
* @return result of expansion * @return result of expansion
*/ */
/*@-boundswrite@*/
static int static int
expandU(MacroBuf mb, char * u, size_t ulen) expandU(MacroBuf mb, char * u, size_t ulen)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem@*/
/*@modifies mb, *u, rpmGlobalMacroContext, fileSystem @*/
{ {
const char *s = mb->s; const char *s = mb->s;
char *t = mb->t; char *t = mb->t;
@ -578,7 +525,6 @@ expandU(MacroBuf mb, char * u, size_t ulen)
return rc; return rc;
} }
/*@=boundswrite@*/
/** /**
* Expand output of shell command into target buffer. * Expand output of shell command into target buffer.
@ -587,11 +533,8 @@ expandU(MacroBuf mb, char * u, size_t ulen)
* @param clen no. bytes in shell command * @param clen no. bytes in shell command
* @return result of expansion * @return result of expansion
*/ */
/*@-boundswrite@*/
static int static int
doShellEscape(MacroBuf mb, const char * cmd, size_t clen) doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
{ {
char pcmd[BUFSIZ]; char pcmd[BUFSIZ];
FILE *shf; FILE *shf;
@ -622,7 +565,6 @@ doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
} }
return 0; return 0;
} }
/*@=boundswrite@*/
/** /**
* Parse (and execute) new macro definition. * Parse (and execute) new macro definition.
@ -632,10 +574,8 @@ doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
* @param expandbody should body be expanded? * @param expandbody should body be expanded?
* @return address to continue parsing * @return address to continue parsing
*/ */
/*@dependent@*/ static const char * static const char *
doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody) doDefine(MacroBuf mb, const char * se, int level, int expandbody)
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies mb, rpmGlobalMacroContext @*/
{ {
const char *s = se; const char *s = se;
char buf[BUFSIZ], *n = buf, *ne = n; char buf[BUFSIZ], *n = buf, *ne = n;
@ -667,35 +607,32 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
return se; return se;
} }
s++; /* XXX skip { */ s++; /* XXX skip { */
/*@-boundswrite@*/
strncpy(b, s, (se - s)); strncpy(b, s, (se - s));
b[se - s] = '\0'; b[se - s] = '\0';
/*@=boundswrite@*/
be += strlen(b); be += strlen(b);
se++; /* XXX skip } */ se++; /* XXX skip } */
s = se; /* move scan forward */ s = se; /* move scan forward */
} else { /* otherwise free-field */ } else { /* otherwise free-field */
/*@-boundswrite@*/
int bc = 0, pc = 0; int bc = 0, pc = 0;
while (*s && (bc || pc || !iseol(*s))) { while (*s && (bc || pc || !iseol(*s))) {
switch (*s) { switch (*s) {
case '\\': case '\\':
switch (*(s+1)) { switch (*(s+1)) {
case '\0': /*@switchbreak@*/ break; case '\0': break;
default: s++; /*@switchbreak@*/ break; default: s++; break;
} }
/*@switchbreak@*/ break; break;
case '%': case '%':
switch (*(s+1)) { switch (*(s+1)) {
case '{': *be++ = *s++; bc++; /*@switchbreak@*/ break; case '{': *be++ = *s++; bc++; break;
case '(': *be++ = *s++; pc++; /*@switchbreak@*/ break; case '(': *be++ = *s++; pc++; break;
case '%': *be++ = *s++; /*@switchbreak@*/ break; case '%': *be++ = *s++; break;
} }
/*@switchbreak@*/ break; break;
case '{': if (bc > 0) bc++; /*@switchbreak@*/ break; case '{': if (bc > 0) bc++; break;
case '}': if (bc > 0) bc--; /*@switchbreak@*/ break; case '}': if (bc > 0) bc--; break;
case '(': if (pc > 0) pc++; /*@switchbreak@*/ break; case '(': if (pc > 0) pc++; break;
case ')': if (pc > 0) pc--; /*@switchbreak@*/ break; case ')': if (pc > 0) pc--; break;
} }
*be++ = *s++; *be++ = *s++;
} }
@ -709,12 +646,9 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
} }
/* Trim trailing blanks/newlines */ /* Trim trailing blanks/newlines */
/*@-globs@*/
while (--be >= b && (c = *be) && (isblank(c) || iseol(c))) while (--be >= b && (c = *be) && (isblank(c) || iseol(c)))
{}; {};
/*@=globs@*/
*(++be) = '\0'; /* one too far */ *(++be) = '\0'; /* one too far */
/*@=boundswrite@*/
} }
/* Move scan over body */ /* Move scan over body */
@ -740,12 +674,10 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
return se; return se;
} }
/*@-modfilesys@*/
if (expandbody && expandU(mb, b, (&buf[sizeof(buf)] - b))) { if (expandbody && expandU(mb, b, (&buf[sizeof(buf)] - b))) {
rpmError(RPMERR_BADSPEC, _("Macro %%%s failed to expand\n"), n); rpmError(RPMERR_BADSPEC, _("Macro %%%s failed to expand\n"), n);
return se; return se;
} }
/*@=modfilesys@*/
addMacro(mb->mc, n, o, b, (level - 1)); addMacro(mb->mc, n, o, b, (level - 1));
@ -758,10 +690,8 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
* @param se macro name to undefine * @param se macro name to undefine
* @return address to continue parsing * @return address to continue parsing
*/ */
/*@dependent@*/ static const char * static const char *
doUndefine(MacroContext mc, /*@returned@*/ const char * se) doUndefine(MacroContext mc, const char * se)
/*@globals rpmGlobalMacroContext @*/
/*@modifies mc, rpmGlobalMacroContext @*/
{ {
const char *s = se; const char *s = se;
char buf[BUFSIZ], *n = buf, *ne = n; char buf[BUFSIZ], *n = buf, *ne = n;
@ -789,8 +719,6 @@ doUndefine(MacroContext mc, /*@returned@*/ const char * se)
#ifdef DYING #ifdef DYING
static void static void
dumpME(const char * msg, MacroEntry me) dumpME(const char * msg, MacroEntry me)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (msg) if (msg)
fprintf(stderr, "%s", msg); fprintf(stderr, "%s", msg);
@ -811,30 +739,23 @@ dumpME(const char * msg, MacroEntry me)
* @param level macro recursion level * @param level macro recursion level
*/ */
static void static void
pushMacro(/*@out@*/ MacroEntry * mep, pushMacro(MacroEntry * mep,
const char * n, /*@null@*/ const char * o, const char * n, const char * o,
/*@null@*/ const char * b, int level) const char * b, int level)
/*@modifies *mep @*/
{ {
MacroEntry prev = (mep && *mep ? *mep : NULL); MacroEntry prev = (mep && *mep ? *mep : NULL);
MacroEntry me = (MacroEntry) xmalloc(sizeof(*me)); MacroEntry me = (MacroEntry) xmalloc(sizeof(*me));
/*@-assignexpose@*/
me->prev = prev; me->prev = prev;
/*@=assignexpose@*/
me->name = (prev ? prev->name : xstrdup(n)); me->name = (prev ? prev->name : xstrdup(n));
me->opts = (o ? xstrdup(o) : NULL); me->opts = (o ? xstrdup(o) : NULL);
me->body = xstrdup(b ? b : ""); me->body = xstrdup(b ? b : "");
me->used = 0; me->used = 0;
me->level = level; me->level = level;
/*@-boundswrite@*/
/*@-branchstate@*/
if (mep) if (mep)
*mep = me; *mep = me;
else else
me = _free(me); me = _free(me);
/*@=branchstate@*/
/*@=boundswrite@*/
} }
/** /**
@ -843,24 +764,17 @@ pushMacro(/*@out@*/ MacroEntry * mep,
*/ */
static void static void
popMacro(MacroEntry * mep) popMacro(MacroEntry * mep)
/*@modifies *mep @*/
{ {
MacroEntry me = (*mep ? *mep : NULL); MacroEntry me = (*mep ? *mep : NULL);
/*@-branchstate@*/
if (me) { if (me) {
/* XXX cast to workaround const */ /* XXX cast to workaround const */
/*@-onlytrans@*/
/*@-boundswrite@*/
if ((*mep = me->prev) == NULL) if ((*mep = me->prev) == NULL)
me->name = _free(me->name); me->name = _free(me->name);
/*@=boundswrite@*/
me->opts = _free(me->opts); me->opts = _free(me->opts);
me->body = _free(me->body); me->body = _free(me->body);
me = _free(me); me = _free(me);
/*@=onlytrans@*/
} }
/*@=branchstate@*/
} }
/** /**
@ -869,7 +783,6 @@ popMacro(MacroEntry * mep)
*/ */
static void static void
freeArgs(MacroBuf mb) freeArgs(MacroBuf mb)
/*@modifies mb @*/
{ {
MacroContext mc = mb->mc; MacroContext mc = mb->mc;
int ndeleted = 0; int ndeleted = 0;
@ -918,12 +831,9 @@ freeArgs(MacroBuf mb)
* @param lastc stop parsing at lastc * @param lastc stop parsing at lastc
* @return address to continue parsing * @return address to continue parsing
*/ */
/*@-bounds@*/ static const char *
/*@dependent@*/ static const char * grabArgs(MacroBuf mb, const MacroEntry me, const char * se,
grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
const char * lastc) const char * lastc)
/*@globals rpmGlobalMacroContext @*/
/*@modifies mb, rpmGlobalMacroContext @*/
{ {
char buf[BUFSIZ], *b, *be; char buf[BUFSIZ], *b, *be;
char aname[16]; char aname[16];
@ -943,12 +853,10 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
/* Copy args into buf until lastc */ /* Copy args into buf until lastc */
*be++ = ' '; *be++ = ' ';
while ((c = *se++) != '\0' && (se-1) != lastc) { while ((c = *se++) != '\0' && (se-1) != lastc) {
/*@-globs@*/
if (!isblank(c)) { if (!isblank(c)) {
*be++ = c; *be++ = c;
continue; continue;
} }
/*@=globs@*/
/* c is blank */ /* c is blank */
if (be[-1] == ' ') if (be[-1] == ' ')
continue; continue;
@ -1007,9 +915,7 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
/* 1003.2 says this must be 1 before any call. */ /* 1003.2 says this must be 1 before any call. */
#ifdef __GLIBC__ #ifdef __GLIBC__
/*@-mods@*/
optind = 0; /* XXX but posix != glibc */ optind = 0; /* XXX but posix != glibc */
/*@=mods@*/
#else #else
optind = 1; optind = 1;
#endif #endif
@ -1017,9 +923,8 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
opts = me->opts; opts = me->opts;
/* Define option macros. */ /* Define option macros. */
/*@-nullstate@*/ /* FIX: argv[] can be NULL */ /* FIX: argv[] can be NULL */
while((c = getopt(argc, (char **)argv, opts)) != -1) 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"),
@ -1053,9 +958,8 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
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);
if (be != b) *be++ = ' '; /* Add space between args */ if (be != b) *be++ = ' '; /* Add space between args */
/*@-nullpass@*/ /* FIX: argv[] can be NULL */ /* FIX: argv[] can be NULL */
be = stpcpy(be, argv[c]); be = stpcpy(be, argv[c]);
/*@=nullpass@*/
} }
} }
@ -1064,7 +968,6 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
return se; return se;
} }
/*@=bounds@*/
/** /**
* Perform macro message output * Perform macro message output
@ -1075,8 +978,6 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
*/ */
static void static void
doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen) doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -1104,9 +1005,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,
/*@null@*/ const char * g, size_t gn) const char * g, size_t gn)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/
{ {
char buf[BUFSIZ], *b = NULL, *be; char buf[BUFSIZ], *b = NULL, *be;
int c; int c;
@ -1145,17 +1044,13 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
b = (rpmIsVerbose() ? buf : NULL); b = (rpmIsVerbose() ? buf : NULL);
} else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) { } else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) {
(void)urlPath(buf, (const char **)&b); (void)urlPath(buf, (const char **)&b);
/*@-branchstate@*/
if (*b == '\0') b = "/"; if (*b == '\0') b = "/";
/*@=branchstate@*/
} else if (STREQ("uncompress", f, fn)) { } else if (STREQ("uncompress", f, fn)) {
rpmCompressedMagic compressed = COMPRESSED_OTHER; rpmCompressedMagic compressed = COMPRESSED_OTHER;
/*@-globs@*/
for (b = buf; (c = *b) && isblank(c);) for (b = buf; (c = *b) && isblank(c);)
b++; b++;
for (be = b; (c = *be) && !isblank(c);) for (be = b; (c = *be) && !isblank(c);)
be++; be++;
/*@=globs@*/
*be++ = '\0'; *be++ = '\0';
#ifndef DEBUG_MACROS #ifndef DEBUG_MACROS
(void) isCompressed(b, &compressed); (void) isCompressed(b, &compressed);
@ -1237,7 +1132,6 @@ expandMacro(MacroBuf mb)
return 1; return 1;
} }
/*@-branchstate@*/
while (rc == 0 && mb->nb > 0 && (c = *s) != '\0') { while (rc == 0 && mb->nb > 0 && (c = *s) != '\0') {
s++; s++;
/* Copy text until next macro */ /* Copy text until next macro */
@ -1245,14 +1139,13 @@ expandMacro(MacroBuf mb)
case '%': case '%':
if (*s) { /* Ensure not end-of-string. */ if (*s) { /* Ensure not end-of-string. */
if (*s != '%') if (*s != '%')
/*@switchbreak@*/ break; break;
s++; /* skip first % in %% */ s++; /* skip first % in %% */
} }
/*@fallthrough@*/
default: default:
SAVECHAR(mb, c); SAVECHAR(mb, c);
continue; continue;
/*@notreached@*/ /*@switchbreak@*/ break; break;
} }
/* Expand next macro */ /* Expand next macro */
@ -1269,10 +1162,10 @@ expandMacro(MacroBuf mb)
switch(*s++) { switch(*s++) {
case '!': case '!':
negate = ((negate + 1) % 2); negate = ((negate + 1) % 2);
/*@switchbreak@*/ break; break;
case '?': case '?':
chkexist++; chkexist++;
/*@switchbreak@*/ break; break;
} }
} }
f = se = s; f = se = s;
@ -1285,21 +1178,19 @@ expandMacro(MacroBuf mb)
case '*': case '*':
se++; se++;
if (*se == '*') se++; if (*se == '*') se++;
/*@innerbreak@*/ break; break;
case '#': case '#':
se++; se++;
/*@innerbreak@*/ break; break;
default: default:
/*@innerbreak@*/ break; break;
} }
fe = se; fe = se;
/* For "%name " macros ... */ /* For "%name " macros ... */
/*@-globs@*/
if ((c = *fe) && isblank(c)) if ((c = *fe) && isblank(c))
if ((lastc = strchr(fe,'\n')) == NULL) if ((lastc = strchr(fe,'\n')) == NULL)
lastc = strchr(fe, '\0'); lastc = strchr(fe, '\0');
/*@=globs@*/ break;
/*@switchbreak@*/ break;
case '(': /* %(...) shell escape */ case '(': /* %(...) shell escape */
if ((se = matchchar(s, c, ')')) == NULL) { if ((se = matchchar(s, c, ')')) == NULL) {
rpmError(RPMERR_BADSPEC, rpmError(RPMERR_BADSPEC,
@ -1316,7 +1207,7 @@ expandMacro(MacroBuf mb)
s = se; s = se;
continue; continue;
/*@notreached@*/ /*@switchbreak@*/ break; break;
case '{': /* %{...}/%{...:...} substitution */ case '{': /* %{...}/%{...:...} substitution */
if ((se = matchchar(s, c, '}')) == NULL) { if ((se = matchchar(s, c, '}')) == NULL) {
rpmError(RPMERR_BADSPEC, rpmError(RPMERR_BADSPEC,
@ -1330,10 +1221,10 @@ expandMacro(MacroBuf mb)
switch(*f++) { switch(*f++) {
case '!': case '!':
negate = ((negate + 1) % 2); negate = ((negate + 1) % 2);
/*@switchbreak@*/ break; break;
case '?': case '?':
chkexist++; chkexist++;
/*@switchbreak@*/ break; break;
} }
} }
for (fe = f; (c = *fe) && !strchr(" :}", c);) for (fe = f; (c = *fe) && !strchr(" :}", c);)
@ -1342,14 +1233,14 @@ expandMacro(MacroBuf mb)
case ':': case ':':
g = fe + 1; g = fe + 1;
ge = se - 1; ge = se - 1;
/*@innerbreak@*/ break; break;
case ' ': case ' ':
lastc = se-1; lastc = se-1;
/*@innerbreak@*/ break; break;
default: default:
/*@innerbreak@*/ break; break;
} }
/*@switchbreak@*/ break; break;
} }
/* XXX Everything below expects fe > f */ /* XXX Everything below expects fe > f */
@ -1456,9 +1347,8 @@ expandMacro(MacroBuf mb)
STREQ("S", f, fn) || STREQ("S", f, fn) ||
STREQ("P", f, fn) || STREQ("P", f, fn) ||
STREQ("F", f, fn)) { STREQ("F", f, fn)) {
/*@-internalglobs@*/ /* FIX: verbose may be set */ /* FIX: verbose may be set */
doFoo(mb, negate, f, fn, g, gn); doFoo(mb, negate, f, fn, g, gn);
/*@=internalglobs@*/
s = se; s = se;
continue; continue;
} }
@ -1550,7 +1440,6 @@ expandMacro(MacroBuf mb)
s = se; s = se;
} }
/*@=branchstate@*/
*mb->t = '\0'; *mb->t = '\0';
mb->s = s; mb->s = s;
@ -1569,10 +1458,8 @@ expandMacro(MacroBuf mb)
#define POPT_ARGV_ARRAY_GROW_DELTA 5 #define POPT_ARGV_ARRAY_GROW_DELTA 5
/*@-boundswrite@*/
static int XpoptDupArgv(int argc, const char **argv, static int XpoptDupArgv(int argc, const char **argv,
int * argcPtr, const char *** argvPtr) int * argcPtr, const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/
{ {
size_t nb = (argc + 1) * sizeof(*argv); size_t nb = (argc + 1) * sizeof(*argv);
const char ** argv2; const char ** argv2;
@ -1593,12 +1480,10 @@ static int XpoptDupArgv(int argc, const char **argv,
argv2 = (void *) dst; argv2 = (void *) dst;
dst += (argc + 1) * sizeof(*argv); dst += (argc + 1) * sizeof(*argv);
/*@-branchstate@*/
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
argv2[i] = dst; argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1; dst += strlen(strcpy(dst, argv[i])) + 1;
} }
/*@=branchstate@*/
argv2[argc] = NULL; argv2[argc] = NULL;
if (argvPtr) { if (argvPtr) {
@ -1611,11 +1496,8 @@ static int XpoptDupArgv(int argc, const char **argv,
*argcPtr = argc; *argcPtr = argc;
return 0; return 0;
} }
/*@=boundswrite@*/
/*@-bounds@*/
static int XpoptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) static int XpoptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/
{ {
const char * src; const char * src;
char quote = '\0'; char quote = '\0';
@ -1656,17 +1538,16 @@ static int XpoptParseArgvString(const char * s, int * argcPtr, const char *** ar
case '"': case '"':
case '\'': case '\'':
quote = *src; quote = *src;
/*@switchbreak@*/ break; break;
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
rc = POPT_ERROR_BADQUOTE; rc = POPT_ERROR_BADQUOTE;
goto exit; goto exit;
} }
/*@fallthrough@*/
default: default:
*buf++ = *src; *buf++ = *src;
/*@switchbreak@*/ break; break;
} }
} }
@ -1680,9 +1561,7 @@ exit:
if (argv) free(argv); if (argv) free(argv);
return rc; return rc;
} }
/*@=bounds@*/
/* =============================================================== */ /* =============================================================== */
/*@unchecked@*/
static int _debug = 0; static int _debug = 0;
int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr) int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr)
@ -1705,14 +1584,12 @@ int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr)
if (rc) if (rc)
return rc; return rc;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
/*@-branchstate@*/
t = setlocale(LC_COLLATE, NULL); t = setlocale(LC_COLLATE, NULL);
if (t) if (t)
old_collate = xstrdup(t); old_collate = xstrdup(t);
t = setlocale(LC_CTYPE, NULL); t = setlocale(LC_CTYPE, NULL);
if (t) if (t)
old_ctype = xstrdup(t); old_ctype = xstrdup(t);
/*@=branchstate@*/
(void) setlocale(LC_COLLATE, "C"); (void) setlocale(LC_COLLATE, "C");
(void) setlocale(LC_CTYPE, "C"); (void) setlocale(LC_CTYPE, "C");
#endif #endif
@ -1755,14 +1632,14 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, argv[argc]);
case URL_IS_PATH: case URL_IS_PATH:
case URL_IS_DASH: case URL_IS_DASH:
strncpy(globRoot, av[j], nb); strncpy(globRoot, av[j], nb);
/*@switchbreak@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
case URL_IS_FTP: case URL_IS_FTP:
case URL_IS_HKP: case URL_IS_HKP:
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
default: default:
/*@switchbreak@*/ break; break;
} }
globRoot += nb; globRoot += nb;
*globRoot = '\0'; *globRoot = '\0';
@ -1781,9 +1658,7 @@ if (_debug)
fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL); fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
argv[argc++] = xstrdup(globURL); argv[argc++] = xstrdup(globURL);
} }
/*@-immediatetrans@*/
Globfree(&gl); Globfree(&gl);
/*@=immediatetrans@*/
globURL = _free(globURL); globURL = _free(globURL);
} }
@ -1800,7 +1675,6 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
exit: exit:
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
/*@-branchstate@*/
if (old_collate) { if (old_collate) {
(void) setlocale(LC_COLLATE, old_collate); (void) setlocale(LC_COLLATE, old_collate);
old_collate = _free(old_collate); old_collate = _free(old_collate);
@ -1809,19 +1683,14 @@ exit:
(void) setlocale(LC_CTYPE, old_ctype); (void) setlocale(LC_CTYPE, old_ctype);
old_ctype = _free(old_ctype); old_ctype = _free(old_ctype);
} }
/*@=branchstate@*/
#endif #endif
av = _free(av); av = _free(av);
/*@-branchstate@*/
if (rc || argvPtr == NULL) { if (rc || argvPtr == NULL) {
/*@-dependenttrans -unqualifiedtrans@*/
if (argv != NULL) if (argv != NULL)
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
argv[i] = _free(argv[i]); argv[i] = _free(argv[i]);
argv = _free(argv); argv = _free(argv);
/*@=dependenttrans =unqualifiedtrans@*/
} }
/*@=branchstate@*/
return rc; return rc;
} }
@ -1903,7 +1772,7 @@ delMacro(MacroContext mc, const char * n)
} }
} }
/*@-mustmod@*/ /* LCL: mc is modified through mb->mc, mb is abstract */ /* LCL: mc is modified through mb->mc, mb is abstract */
int int
rpmDefineMacro(MacroContext mc, const char * macro, int level) rpmDefineMacro(MacroContext mc, const char * macro, int level)
{ {
@ -1915,7 +1784,6 @@ rpmDefineMacro(MacroContext mc, const char * macro, int level)
(void) doDefine(mb, macro, level, 0); (void) doDefine(mb, macro, level, 0);
return 0; return 0;
} }
/*@=mustmod@*/
void void
rpmLoadMacros(MacroContext mc, int level) rpmLoadMacros(MacroContext mc, int level)
@ -1951,9 +1819,7 @@ rpmLoadMacroFile(MacroContext mc, const char * fn)
} }
/* XXX Assume new fangled macro expansion */ /* XXX Assume new fangled macro expansion */
/*@-mods@*/
max_macro_depth = 16; max_macro_depth = 16;
/*@=mods@*/
buf[0] = '\0'; buf[0] = '\0';
while(rdcl(buf, sizeof(buf), fd) != NULL) { while(rdcl(buf, sizeof(buf), fd) != NULL) {
@ -1991,7 +1857,7 @@ rpmInitMacros(MacroContext mc, const char * macrofiles)
for (me = m; (me = strchr(me, ':')) != NULL; me++) { for (me = m; (me = strchr(me, ':')) != NULL; me++) {
/* Skip over URI's. */ /* Skip over URI's. */
if (!(me[1] == '/' && me[2] == '/')) if (!(me[1] == '/' && me[2] == '/'))
/*@innerbreak@*/ break; break;
} }
if (me && *me == ':') if (me && *me == ':')
@ -2021,12 +1887,9 @@ rpmInitMacros(MacroContext mc, const char * macrofiles)
mfiles = _free(mfiles); mfiles = _free(mfiles);
/* Reload cmdline macros */ /* Reload cmdline macros */
/*@-mods@*/
rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE); rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE);
/*@=mods@*/
} }
/*@-globstate@*/
void void
rpmFreeMacros(MacroContext mc) rpmFreeMacros(MacroContext mc)
{ {
@ -2039,10 +1902,8 @@ rpmFreeMacros(MacroContext mc)
MacroEntry me; MacroEntry me;
while ((me = mc->macroTable[i]) != NULL) { while ((me = mc->macroTable[i]) != NULL) {
/* XXX cast to workaround const */ /* XXX cast to workaround const */
/*@-onlytrans@*/
if ((mc->macroTable[i] = me->prev) == NULL) if ((mc->macroTable[i] = me->prev) == NULL)
me->name = _free(me->name); me->name = _free(me->name);
/*@=onlytrans@*/
me->opts = _free(me->opts); me->opts = _free(me->opts);
me->body = _free(me->body); me->body = _free(me->body);
me = _free(me); me = _free(me);
@ -2052,7 +1913,6 @@ rpmFreeMacros(MacroContext mc)
} }
memset(mc, 0, sizeof(*mc)); memset(mc, 0, sizeof(*mc));
} }
/*@=globstate@*/
/* =============================================================== */ /* =============================================================== */
int isCompressed(const char * file, rpmCompressedMagic * compressed) int isCompressed(const char * file, rpmCompressedMagic * compressed)
@ -2105,7 +1965,6 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed)
/* =============================================================== */ /* =============================================================== */
/*@-modfilesys@*/
char * char *
rpmExpand(const char *arg, ...) rpmExpand(const char *arg, ...)
{ {
@ -2127,7 +1986,6 @@ rpmExpand(const char *arg, ...)
(void) expandMacros(NULL, NULL, buf, sizeof(buf)); (void) expandMacros(NULL, NULL, buf, sizeof(buf));
return xstrdup(buf); return xstrdup(buf);
} }
/*@=modfilesys@*/
int int
rpmExpandNumeric(const char *arg) rpmExpandNumeric(const char *arg)
@ -2175,10 +2033,10 @@ char *rpmCleanPath(char * path)
if (s[1] == '/' && s[2] == '/') { if (s[1] == '/' && s[2] == '/') {
*t++ = *s++; *t++ = *s++;
*t++ = *s++; *t++ = *s++;
/*@switchbreak@*/ break; break;
} }
begin=1; begin=1;
/*@switchbreak@*/ break; break;
case '/': case '/':
/* Move parent dir forward */ /* Move parent dir forward */
for (se = te + 1; se < t && *se != '/'; se++) for (se = te + 1; se < t && *se != '/'; se++)
@ -2191,7 +2049,7 @@ char *rpmCleanPath(char * path)
s++; s++;
while (t > path && t[-1] == '/') while (t > path && t[-1] == '/')
t--; t--;
/*@switchbreak@*/ break; break;
case '.': case '.':
/* Leading .. is special */ /* Leading .. is special */
/* Check that it is ../, so that we don't interpret */ /* Check that it is ../, so that we don't interpret */
@ -2202,11 +2060,11 @@ char *rpmCleanPath(char * path)
if (begin && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) { if (begin && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
/*fprintf(stderr, " leading \"..\"\n"); */ /*fprintf(stderr, " leading \"..\"\n"); */
*t++ = *s++; *t++ = *s++;
/*@switchbreak@*/ break; break;
} }
/* Single . is special */ /* Single . is special */
if (begin && s[1] == '\0') { if (begin && s[1] == '\0') {
/*@switchbreak@*/ break; break;
} }
/* Trim embedded ./ , trailing /. */ /* Trim embedded ./ , trailing /. */
if ((t[-1] == '/' && s[1] == '\0') || (t > path && t[-1] == '/' && s[1] == '/')) { if ((t[-1] == '/' && s[1] == '\0') || (t > path && t[-1] == '/' && s[1] == '/')) {
@ -2225,10 +2083,10 @@ char *rpmCleanPath(char * path)
s++; s++;
continue; continue;
} }
/*@switchbreak@*/ break; break;
default: default:
begin = 0; begin = 0;
/*@switchbreak@*/ break; break;
} }
*t++ = *s++; *t++ = *s++;
} }
@ -2266,9 +2124,7 @@ rpmGetPath(const char *path, ...)
*te = '\0'; *te = '\0';
} }
va_end(ap); va_end(ap);
/*@-modfilesys@*/
(void) expandMacros(NULL, NULL, buf, sizeof(buf)); (void) expandMacros(NULL, NULL, buf, sizeof(buf));
/*@=modfilesys@*/
(void) rpmCleanPath(buf); (void) rpmCleanPath(buf);
return xstrdup(buf); /* XXX xstrdup has side effects. */ return xstrdup(buf); /* XXX xstrdup has side effects. */
@ -2279,12 +2135,12 @@ rpmGetPath(const char *path, ...)
const char * rpmGenPath(const char * urlroot, const char * urlmdir, const char * rpmGenPath(const char * urlroot, const char * urlmdir,
const char *urlfile) const char *urlfile)
{ {
/*@owned@*/ const char * xroot = rpmGetPath(urlroot, NULL); const char * xroot = rpmGetPath(urlroot, NULL);
/*@dependent@*/ const char * root = xroot; const char * root = xroot;
/*@owned@*/ const char * xmdir = rpmGetPath(urlmdir, NULL); const char * xmdir = rpmGetPath(urlmdir, NULL);
/*@dependent@*/ const char * mdir = xmdir; const char * mdir = xmdir;
/*@owned@*/ const char * xfile = rpmGetPath(urlfile, NULL); const char * xfile = rpmGetPath(urlfile, NULL);
/*@dependent@*/ const char * file = xfile; const char * file = xfile;
const char * result; const char * result;
const char * url = NULL; const char * url = NULL;
int nurl = 0; int nurl = 0;
@ -2322,14 +2178,12 @@ if (_debug) fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl);
#endif #endif
} }
/*@-branchstate@*/
if (url && nurl > 0) { if (url && nurl > 0) {
char *t = strncpy(alloca(nurl+1), url, nurl); char *t = strncpy(alloca(nurl+1), url, nurl);
t[nurl] = '\0'; t[nurl] = '\0';
url = t; url = t;
} else } else
url = ""; url = "";
/*@=branchstate@*/
result = rpmGetPath(url, root, "/", mdir, "/", file, NULL); result = rpmGetPath(url, root, "/", mdir, "/", file, NULL);
@ -2423,4 +2277,3 @@ main(int argc, char *argv[])
} }
#endif /* EVAL_MACROS */ #endif /* EVAL_MACROS */
#endif /* DEBUG_MACROS */ #endif /* DEBUG_MACROS */
/*@=boundsread@*/

View File

@ -1,4 +1,3 @@
/*@-modfilesys@*/
/** \ingroup rpmio /** \ingroup rpmio
* \file rpmio/rpmdav.c * \file rpmio/rpmdav.c
*/ */
@ -37,9 +36,6 @@
#include "ugid.h" #include "ugid.h"
#include "debug.h" #include "debug.h"
/*@access DIR @*/
/*@access FD_t @*/
/*@access urlinfo @*/
#if 0 /* HACK: reasonable value needed. */ #if 0 /* HACK: reasonable value needed. */
#define TIMEOUT_SECS 60 #define TIMEOUT_SECS 60
@ -48,7 +44,6 @@
#endif #endif
#ifdef WITH_NEON #ifdef WITH_NEON
/*@unchecked@*/
static int httpTimeoutSecs = TIMEOUT_SECS; static int httpTimeoutSecs = TIMEOUT_SECS;
#endif #endif
@ -57,9 +52,8 @@ static int httpTimeoutSecs = TIMEOUT_SECS;
* @param p memory to free * @param p memory to free
* @retval NULL always * @retval NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) _free(const void * p)
/*@modifies p@*/
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
@ -69,8 +63,6 @@ _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
/* =============================================================== */ /* =============================================================== */
static int davFree(urlinfo u) static int davFree(urlinfo u)
/*@globals internalState @*/
/*@modifies u, internalState @*/
{ {
if (u != NULL && u->sess != NULL) { if (u != NULL && u->sess != NULL) {
u->capabilities = _free(u->capabilities); u->capabilities = _free(u->capabilities);
@ -84,7 +76,6 @@ static int davFree(urlinfo u)
} }
static void davProgress(void * userdata, off_t current, off_t total) static void davProgress(void * userdata, off_t current, off_t total)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
@ -103,11 +94,9 @@ fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, (unsig
static void davNotify(void * userdata, static void davNotify(void * userdata,
ne_conn_status connstatus, const char * info) ne_conn_status connstatus, const char * info)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
/*@observer@*/
static const char * connstates[] = { static const char * connstates[] = {
"namelookup", "namelookup",
"connecting", "connecting",
@ -132,16 +121,13 @@ typedef enum {
u->connstatus = connstatus; u->connstatus = connstatus;
/*@-boundsread@*/
if (_dav_debug < 0) if (_dav_debug < 0)
fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]); fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
/*@=boundsread@*/
} }
static void davCreateRequest(ne_request * req, void * userdata, static void davCreateRequest(ne_request * req, void * userdata,
const char * method, const char * uri) const char * method, const char * uri)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
@ -187,7 +173,6 @@ fprintf(stderr, "-> %s\n", buf->data);
} }
static int davPostSend(ne_request * req, void * userdata, const ne_status * status) static int davPostSend(ne_request * req, void * userdata, const ne_status * status)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
@ -203,15 +188,12 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
fd = ne_get_request_private(req, id); fd = ne_get_request_private(req, id);
/*@-evalorder@*/
if (_dav_debug < 0) if (_dav_debug < 0)
fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess)); fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess));
/*@=evalorder@*/
return NE_OK; return NE_OK;
} }
static void davDestroyRequest(ne_request * req, void * userdata) static void davDestroyRequest(ne_request * req, void * userdata)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
@ -232,7 +214,6 @@ fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, s
} }
static void davDestroySession(void * userdata) static void davDestroySession(void * userdata)
/*@*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
ne_session * sess; ne_session * sess;
@ -254,7 +235,6 @@ fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id,
static int static int
davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert) davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
/*@*/
{ {
const char *hostname = userdata; const char *hostname = userdata;
@ -265,8 +245,6 @@ fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, ho
} }
static int davConnect(urlinfo u) static int davConnect(urlinfo u)
/*@globals internalState @*/
/*@modifies u, internalState @*/
{ {
const char * path = NULL; const char * path = NULL;
int rc; int rc;
@ -286,7 +264,6 @@ static int davConnect(urlinfo u)
/* HACK: "301 Moved Permanently" on empty subdir. */ /* HACK: "301 Moved Permanently" on empty subdir. */
if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1)) if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
break; break;
/*@fallthrough@*/
case NE_CONNECT: case NE_CONNECT:
case NE_LOOKUP: case NE_LOOKUP:
default: default:
@ -304,8 +281,6 @@ fprintf(stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n",
} }
static int davInit(const char * url, urlinfo * uret) static int davInit(const char * url, urlinfo * uret)
/*@globals internalState @*/
/*@modifies *uret, internalState @*/
{ {
urlinfo u = NULL; urlinfo u = NULL;
int rc = 0; int rc = 0;
@ -313,23 +288,20 @@ static int davInit(const char * url, urlinfo * uret)
/*@-globs@*/ /* FIX: h_errno annoyance. */ /*@-globs@*/ /* FIX: h_errno annoyance. */
if (urlSplit(url, &u)) if (urlSplit(url, &u))
return -1; /* XXX error returns needed. */ return -1; /* XXX error returns needed. */
/*@=globs@*/
if (u->url != NULL && u->sess == NULL) if (u->url != NULL && u->sess == NULL)
switch (u->urltype) { switch (u->urltype) {
default: default:
assert(u->urltype != u->urltype); assert(u->urltype != u->urltype);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
case URL_IS_HKP: case URL_IS_HKP:
{ ne_server_capabilities * capabilities; { ne_server_capabilities * capabilities;
/* HACK: oneshots should be done Somewhere Else Instead. */ /* HACK: oneshots should be done Somewhere Else Instead. */
/*@-noeffect@*/
rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0); rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
ne_debug_init(stderr, rc); /* XXX oneshot? */ ne_debug_init(stderr, rc); /* XXX oneshot? */
/*@=noeffect@*/
rc = ne_sock_init(); /* XXX oneshot? */ rc = ne_sock_init(); /* XXX oneshot? */
u->lockstore = ne_lockstore_create(); /* XXX oneshot? */ u->lockstore = ne_lockstore_create(); /* XXX oneshot? */
@ -377,10 +349,8 @@ static int davInit(const char * url, urlinfo * uret)
} }
exit: exit:
/*@-boundswrite@*/
if (rc == 0 && uret != NULL) if (rc == 0 && uret != NULL)
*uret = urlLink(u, __FUNCTION__); *uret = urlLink(u, __FUNCTION__);
/*@=boundswrite@*/
u = urlFree(u, "urlSplit (davInit)"); u = urlFree(u, "urlSplit (davInit)");
return rc; return rc;
@ -397,7 +367,6 @@ enum fetch_rtype_e {
struct fetch_resource_s { struct fetch_resource_s {
struct fetch_resource_s *next; struct fetch_resource_s *next;
char *uri; char *uri;
/*@unused@*/
char *displayname; char *displayname;
enum fetch_rtype_e type; enum fetch_rtype_e type;
size_t size; size_t size;
@ -408,9 +377,7 @@ struct fetch_resource_s {
int error_status; /* error status returned for this resource */ int error_status; /* error status returned for this resource */
}; };
/*@null@*/ static void *fetch_destroy_item(struct fetch_resource_s *res)
static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
/*@modifies res @*/
{ {
NE_FREE(res->uri); NE_FREE(res->uri);
NE_FREE(res->error_reason); NE_FREE(res->error_reason);
@ -419,23 +386,18 @@ static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
} }
#ifdef UNUSED #ifdef UNUSED
/*@null@*/ static void *fetch_destroy_list(struct fetch_resource_s *res)
static void *fetch_destroy_list(/*@only@*/ struct fetch_resource_s *res)
/*@modifies res @*/
{ {
struct fetch_resource_s *next; struct fetch_resource_s *next;
/*@-branchstate@*/
for (; res != NULL; res = next) { for (; res != NULL; res = next) {
next = res->next; next = res->next;
res = fetch_destroy_item(res); res = fetch_destroy_item(res);
} }
/*@=branchstate@*/
return NULL; return NULL;
} }
#endif #endif
static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const char *uri) static void *fetch_create_item(void *userdata, const char *uri)
/*@*/
{ {
struct fetch_resource_s * res = ne_calloc(sizeof(*res)); struct fetch_resource_s * res = ne_calloc(sizeof(*res));
return res; return res;
@ -443,11 +405,9 @@ static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const c
/* =============================================================== */ /* =============================================================== */
struct fetch_context_s { struct fetch_context_s {
/*@relnull@*/
struct fetch_resource_s **resrock; struct fetch_resource_s **resrock;
const char *uri; const char *uri;
unsigned int include_target; /* Include resource at href */ unsigned int include_target; /* Include resource at href */
/*@refcounted@*/
urlinfo u; urlinfo u;
int ac; int ac;
int nalloced; int nalloced;
@ -457,10 +417,7 @@ struct fetch_context_s {
time_t * mtimes; time_t * mtimes;
}; };
/*@null@*/ static void *fetch_destroy_context(struct fetch_context_s *ctx)
static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s *ctx)
/*@globals internalState @*/
/*@modifies ctx, internalState @*/
{ {
if (ctx == NULL) if (ctx == NULL)
return NULL; return NULL;
@ -471,17 +428,12 @@ static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s
ctx->mtimes = _free(ctx->mtimes); ctx->mtimes = _free(ctx->mtimes);
ctx->u = urlFree(ctx->u, __FUNCTION__); ctx->u = urlFree(ctx->u, __FUNCTION__);
ctx->uri = _free(ctx->uri); ctx->uri = _free(ctx->uri);
/*@-boundswrite@*/
memset(ctx, 0, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx));
/*@=boundswrite@*/
ctx = _free(ctx); ctx = _free(ctx);
return NULL; return NULL;
} }
/*@null@*/
static void *fetch_create_context(const char *uri) static void *fetch_create_context(const char *uri)
/*@globals internalState @*/
/*@modifies internalState @*/
{ {
struct fetch_context_s * ctx; struct fetch_context_s * ctx;
urlinfo u; urlinfo u;
@ -489,7 +441,6 @@ static void *fetch_create_context(const char *uri)
/*@-globs@*/ /* FIX: h_errno annoyance. */ /*@-globs@*/ /* FIX: h_errno annoyance. */
if (urlSplit(uri, &u)) if (urlSplit(uri, &u))
return NULL; return NULL;
/*@=globs@*/
ctx = ne_calloc(sizeof(*ctx)); ctx = ne_calloc(sizeof(*ctx));
ctx->uri = xstrdup(uri); ctx->uri = xstrdup(uri);
@ -497,7 +448,6 @@ static void *fetch_create_context(const char *uri)
return ctx; return ctx;
} }
/*@unchecked@*/ /*@observer@*/
static const ne_propname fetch_props[] = { static const ne_propname fetch_props[] = {
{ "DAV:", "getcontentlength" }, { "DAV:", "getcontentlength" },
{ "DAV:", "getlastmodified" }, { "DAV:", "getlastmodified" },
@ -511,7 +461,6 @@ static const ne_propname fetch_props[] = {
#define ELM_resourcetype (NE_PROPS_STATE_TOP + 1) #define ELM_resourcetype (NE_PROPS_STATE_TOP + 1)
#define ELM_collection (NE_PROPS_STATE_TOP + 2) #define ELM_collection (NE_PROPS_STATE_TOP + 2)
/*@unchecked@*/ /*@observer@*/
static const struct ne_xml_idmap fetch_idmap[] = { static const struct ne_xml_idmap fetch_idmap[] = {
{ "DAV:", "resourcetype", ELM_resourcetype }, { "DAV:", "resourcetype", ELM_resourcetype },
{ "DAV:", "collection", ELM_collection } { "DAV:", "collection", ELM_collection }
@ -519,8 +468,7 @@ static const struct ne_xml_idmap fetch_idmap[] = {
static int fetch_startelm(void *userdata, int parent, static int fetch_startelm(void *userdata, int parent,
const char *nspace, const char *name, const char *nspace, const char *name,
/*@unused@*/ const char **atts) const char **atts)
/*@*/
{ {
ne_propfind_handler *pfh = userdata; ne_propfind_handler *pfh = userdata;
struct fetch_resource_s *r = ne_propfind_current_private(pfh); struct fetch_resource_s *r = ne_propfind_current_private(pfh);
@ -541,7 +489,6 @@ static int fetch_startelm(void *userdata, int parent,
static int fetch_compare(const struct fetch_resource_s *r1, static int fetch_compare(const struct fetch_resource_s *r1,
const struct fetch_resource_s *r2) const struct fetch_resource_s *r2)
/*@*/
{ {
/* Sort errors first, then collections, then alphabetically */ /* Sort errors first, then collections, then alphabetically */
if (r1->type == resr_error) { if (r1->type == resr_error) {
@ -565,7 +512,6 @@ static int fetch_compare(const struct fetch_resource_s *r1,
static void fetch_results(void *userdata, const char *uri, static void fetch_results(void *userdata, const char *uri,
const ne_prop_result_set *set) const ne_prop_result_set *set)
/*@*/
{ {
struct fetch_context_s *ctx = userdata; struct fetch_context_s *ctx = userdata;
struct fetch_resource_s *current, *previous, *newres; struct fetch_resource_s *current, *previous, *newres;
@ -594,20 +540,16 @@ fprintf(stderr, "==> %s skipping target resource.\n", path);
newres->uri = ne_strdup(path); newres->uri = ne_strdup(path);
/*@-boundsread@*/
clength = ne_propset_value(set, &fetch_props[0]); clength = ne_propset_value(set, &fetch_props[0]);
modtime = ne_propset_value(set, &fetch_props[1]); modtime = ne_propset_value(set, &fetch_props[1]);
isexec = ne_propset_value(set, &fetch_props[2]); isexec = ne_propset_value(set, &fetch_props[2]);
checkin = ne_propset_value(set, &fetch_props[4]); checkin = ne_propset_value(set, &fetch_props[4]);
checkout = ne_propset_value(set, &fetch_props[5]); checkout = ne_propset_value(set, &fetch_props[5]);
/*@=boundsread@*/
/*@-branchstate@*/
if (clength == NULL) if (clength == NULL)
status = ne_propset_status(set, &fetch_props[0]); status = ne_propset_status(set, &fetch_props[0]);
if (modtime == NULL) if (modtime == NULL)
status = ne_propset_status(set, &fetch_props[1]); status = ne_propset_status(set, &fetch_props[1]);
/*@=branchstate@*/
if (newres->type == resr_normal && status != NULL) { if (newres->type == resr_normal && status != NULL) {
/* It's an error! */ /* It's an error! */
@ -663,16 +605,12 @@ fprintf(stderr, "==> %s skipping target resource.\n", path);
if (previous) { if (previous) {
previous->next = newres; previous->next = newres;
} else { } else {
/*@-boundswrite@*/
*ctx->resrock = newres; *ctx->resrock = newres;
/*@=boundswrite@*/
} }
newres->next = current; newres->next = current;
} }
static int davFetch(const urlinfo u, struct fetch_context_s * ctx) static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
/*@globals internalState @*/
/*@modifies ctx, internalState @*/
{ {
const char * path = NULL; const char * path = NULL;
int depth = 1; /* XXX passed arg? */ int depth = 1; /* XXX passed arg? */
@ -724,9 +662,7 @@ static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
val = ne_strndup(s, (se - s)); val = ne_strndup(s, (se - s));
/*@-nullpass@*/
val = ne_path_unescape(val); val = ne_path_unescape(val);
/*@=nullpass@*/
xx = argvAdd(&ctx->av, val); xx = argvAdd(&ctx->av, val);
if (_dav_debug < 0) if (_dav_debug < 0)
@ -748,21 +684,19 @@ fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
switch (current->type) { switch (current->type) {
case resr_normal: case resr_normal:
st_mode = S_IFREG; st_mode = S_IFREG;
/*@switchbreak@*/ break; break;
case resr_collection: case resr_collection:
st_mode = S_IFDIR; st_mode = S_IFDIR;
/*@switchbreak@*/ break; break;
case resr_reference: case resr_reference:
case resr_error: case resr_error:
default: default:
st_mode = 0; st_mode = 0;
/*@switchbreak@*/ break; break;
} }
/*@-boundswrite@*/
ctx->modes[ctx->ac] = st_mode; ctx->modes[ctx->ac] = st_mode;
ctx->sizes[ctx->ac] = current->size; ctx->sizes[ctx->ac] = current->size;
ctx->mtimes[ctx->ac] = current->modtime; ctx->mtimes[ctx->ac] = current->modtime;
/*@=boundswrite@*/
ctx->ac++; ctx->ac++;
current = fetch_destroy_item(current); current = fetch_destroy_item(current);
@ -773,8 +707,6 @@ fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
} }
static int davNLST(struct fetch_context_s * ctx) static int davNLST(struct fetch_context_s * ctx)
/*@globals internalState @*/
/*@modifies ctx, internalState @*/
{ {
urlinfo u = NULL; urlinfo u = NULL;
int rc; int rc;
@ -792,7 +724,6 @@ static int davNLST(struct fetch_context_s * ctx)
/* HACK: "301 Moved Permanently" on empty subdir. */ /* HACK: "301 Moved Permanently" on empty subdir. */
if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1)) if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
break; break;
/*@fallthrough@*/
default: default:
if (_dav_debug) if (_dav_debug)
fprintf(stderr, "*** Fetch from %s:%d failed:\n\t%s\n", fprintf(stderr, "*** Fetch from %s:%d failed:\n\t%s\n",
@ -807,8 +738,7 @@ exit:
} }
/* =============================================================== */ /* =============================================================== */
static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp) static int my_result(const char * msg, int ret, FILE * fp)
/*@modifies *fp @*/
{ {
/* HACK: don't print unless debugging. */ /* HACK: don't print unless debugging. */
if (_dav_debug >= 0) if (_dav_debug >= 0)
@ -829,7 +759,6 @@ static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp)
#ifdef DYING #ifdef DYING
static void hexdump(const unsigned char * buf, ssize_t len) static void hexdump(const unsigned char * buf, ssize_t len)
/*@*/
{ {
int i; int i;
if (len <= 0) if (len <= 0)
@ -843,8 +772,7 @@ static void hexdump(const unsigned char * buf, ssize_t len)
} }
#endif #endif
static void davAcceptRanges(void * userdata, /*@null@*/ const char * value) static void davAcceptRanges(void * userdata, const char * value)
/*@modifies userdata @*/
{ {
urlinfo u = userdata; urlinfo u = userdata;
@ -868,21 +796,17 @@ fprintf(stderr, "<- %s\n", value);
} }
#endif #endif
static void davContentLength(void * userdata, /*@null@*/ const char * value) static void davContentLength(void * userdata, const char * value)
/*@modifies userdata @*/
{ {
FD_t ctrl = userdata; FD_t ctrl = userdata;
if (!(ctrl && value)) return; if (!(ctrl && value)) return;
if (_dav_debug < 0) if (_dav_debug < 0)
fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value); fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
/*@-unrecog@*/
ctrl->contentLength = strtoll(value, NULL, 10); ctrl->contentLength = strtoll(value, NULL, 10);
/*@=unrecog@*/
} }
static void davConnection(void * userdata, /*@null@*/ const char * value) static void davConnection(void * userdata, const char * value)
/*@modifies userdata @*/
{ {
FD_t ctrl = userdata; FD_t ctrl = userdata;
@ -895,8 +819,8 @@ fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
ctrl->persist = 1; ctrl->persist = 1;
} }
/*@-mustmod@*/ /* HACK: stash error in *str. */ /* HACK: stash error in *str. */
int davResp(urlinfo u, FD_t ctrl, /*@unused@*/ char *const * str) int davResp(urlinfo u, FD_t ctrl, char *const * str)
{ {
int rc = 0; int rc = 0;
@ -907,14 +831,11 @@ if (_dav_debug < 0)
fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc); fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc);
/* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */ /* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
/*@-observertrans@*/
if (rc) if (rc)
fdSetSyserrno(ctrl, errno, ftpStrerror(-rc)); fdSetSyserrno(ctrl, errno, ftpStrerror(-rc));
/*@=observertrans@*/
return rc; return rc;
} }
/*@=mustmod@*/
int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg) int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
{ {
@ -933,9 +854,7 @@ fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd
assert(u->sess != NULL); assert(u->sess != NULL);
assert(ctrl->req == NULL); assert(ctrl->req == NULL);
/*@-nullpass@*/
ctrl->req = ne_request_create(u->sess, httpCmd, httpArg); ctrl->req = ne_request_create(u->sess, httpCmd, httpArg);
/*@=nullpass@*/
assert(ctrl->req != NULL); assert(ctrl->req != NULL);
ne_set_request_private(ctrl->req, "fd", ctrl); ne_set_request_private(ctrl->req, "fd", ctrl);
@ -995,9 +914,7 @@ fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, ht
return 0; return 0;
errxit: errxit:
/*@-observertrans@*/
fdSetSyserrno(ctrl, errno, ftpStrerror(rc)); fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
/*@=observertrans@*/
/* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */ /* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */
ctrl = fdLink(ctrl, "error data (davReq)"); ctrl = fdLink(ctrl, "error data (davReq)");
@ -1005,8 +922,8 @@ errxit:
return rc; return rc;
} }
FD_t davOpen(const char * url, /*@unused@*/ int flags, FD_t davOpen(const char * url, int flags,
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret) mode_t mode, urlinfo * uret)
{ {
const char * path = NULL; const char * path = NULL;
urltype urlType = urlPath(url, &path); urltype urlType = urlPath(url, &path);
@ -1048,16 +965,12 @@ assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType == URL_IS_HK
} }
exit: exit:
/*@-boundswrite@*/
if (uret) if (uret)
*uret = u; *uret = u;
/*@=boundswrite@*/
/*@-refcounttrans@*/
return fd; return fd;
/*@=refcounttrans@*/
} }
ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count) ssize_t davRead(void * cookie, char * buf, size_t count)
{ {
FD_t fd = cookie; FD_t fd = cookie;
ssize_t rc; ssize_t rc;
@ -1114,7 +1027,7 @@ hexdump(buf, count);
return rc; return rc;
} }
int davSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, int whence) int davSeek(void * cookie, _libio_pos_t pos, int whence)
{ {
if (_dav_debug < 0) if (_dav_debug < 0)
fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence); fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
@ -1124,9 +1037,7 @@ fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
/*@-mustmod@*/ /* HACK: fd->req is modified. */ /*@-mustmod@*/ /* HACK: fd->req is modified. */
int davClose(void * cookie) int davClose(void * cookie)
{ {
/*@-onlytrans@*/
FD_t fd = cookie; FD_t fd = cookie;
/*@=onlytrans@*/
int rc; int rc;
assert(fd->req != NULL); assert(fd->req != NULL);
@ -1140,7 +1051,6 @@ if (_dav_debug < 0)
fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc); fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
return rc; return rc;
} }
/*@=mustmod@*/
/* =============================================================== */ /* =============================================================== */
int davMkdir(const char * path, mode_t mode) int davMkdir(const char * path, mode_t mode)
@ -1244,8 +1154,6 @@ fprintf(stderr, "*** davUnlink(%s) rc %d\n", path, rc);
#ifdef NOTYET #ifdef NOTYET
static int davChdir(const char * path) static int davChdir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
return davCommand("CWD", path, NULL); return davCommand("CWD", path, NULL);
} }
@ -1254,8 +1162,7 @@ static int davChdir(const char * path)
/* =============================================================== */ /* =============================================================== */
static const char * statstr(const struct stat * st, static const char * statstr(const struct stat * st,
/*@returned@*/ /*@out@*/ char * buf) char * buf)
/*@modifies *buf @*/
{ {
sprintf(buf, sprintf(buf,
"*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n", "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
@ -1270,13 +1177,9 @@ static const char * statstr(const struct stat * st,
return buf; return buf;
} }
/*@unchecked@*/
static int dav_st_ino = 0xdead0000; static int dav_st_ino = 0xdead0000;
/*@-boundswrite@*/ int davStat(const char * path, struct stat *st)
int davStat(const char * path, /*@out@*/ struct stat *st)
/*@globals dav_st_ino, fileSystem, internalState @*/
/*@modifies *st, dav_st_ino, fileSystem, internalState @*/
{ {
struct fetch_context_s * ctx = NULL; struct fetch_context_s * ctx = NULL;
char buf[1024]; char buf[1024];
@ -1316,12 +1219,8 @@ exit:
ctx = fetch_destroy_context(ctx); ctx = fetch_destroy_context(ctx);
return rc; return rc;
} }
/*@=boundswrite@*/
/*@-boundswrite@*/ int davLstat(const char * path, struct stat *st)
int davLstat(const char * path, /*@out@*/ struct stat *st)
/*@globals dav_st_ino, fileSystem, internalState @*/
/*@modifies *st, dav_st_ino, fileSystem, internalState @*/
{ {
struct fetch_context_s * ctx = NULL; struct fetch_context_s * ctx = NULL;
char buf[1024]; char buf[1024];
@ -1361,12 +1260,9 @@ exit:
ctx = fetch_destroy_context(ctx); ctx = fetch_destroy_context(ctx);
return rc; return rc;
} }
/*@=boundswrite@*/
#ifdef NOTYET #ifdef NOTYET
static int davReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz) static int davReadlink(const char * path, char * buf, size_t bufsiz)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *buf, fileSystem, internalState @*/
{ {
int rc; int rc;
rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz); rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
@ -1379,10 +1275,9 @@ fprintf(stderr, "*** davReadlink(%s) rc %d\n", path, rc);
#endif /* WITH_NEON */ #endif /* WITH_NEON */
/* =============================================================== */ /* =============================================================== */
/*@unchecked@*/
int avmagicdir = 0x3607113; int avmagicdir = 0x3607113;
int avClosedir(/*@only@*/ DIR * dir) int avClosedir(DIR * dir)
{ {
AVDIR avdir = (AVDIR)dir; AVDIR avdir = (AVDIR)dir;
@ -1390,9 +1285,7 @@ if (_av_debug)
fprintf(stderr, "*** avClosedir(%p)\n", avdir); fprintf(stderr, "*** avClosedir(%p)\n", avdir);
#if defined(HAVE_PTHREAD_H) #if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon @*/
(void) pthread_mutex_destroy(&avdir->lock); (void) pthread_mutex_destroy(&avdir->lock);
/*@=moduncon =noeffectuncon @*/
#endif #endif
avdir = _free(avdir); avdir = _free(avdir);
@ -1419,15 +1312,12 @@ struct dirent * avReaddir(DIR * dir)
dt = (unsigned char *) (av + (ac + 1)); dt = (unsigned char *) (av + (ac + 1));
i = avdir->offset + 1; i = avdir->offset + 1;
/*@-boundsread@*/
if (i < 0 || i >= ac || av[i] == NULL) if (i < 0 || i >= ac || av[i] == NULL)
return NULL; return NULL;
/*@=boundsread@*/
avdir->offset = i; avdir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */ /* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */ dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */ dp->d_reclen = 0; /* W2DO? */
@ -1435,11 +1325,8 @@ struct dirent * avReaddir(DIR * dir)
#if !defined(__APPLE__) #if !defined(__APPLE__)
dp->d_off = 0; /* W2DO? */ dp->d_off = 0; /* W2DO? */
#endif #endif
/*@-boundsread@*/
dp->d_type = dt[i]; dp->d_type = dt[i];
/*@=boundsread@*/
#endif #endif
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name)); strncpy(dp->d_name, av[i], sizeof(dp->d_name));
if (_av_debug) if (_av_debug)
@ -1448,7 +1335,6 @@ fprintf(stderr, "*** avReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
return dp; return dp;
} }
/*@-boundswrite@*/
DIR * avOpendir(const char * path) DIR * avOpendir(const char * path)
{ {
AVDIR avdir; AVDIR avdir;
@ -1466,49 +1352,37 @@ fprintf(stderr, "*** avOpendir(%s)\n", path);
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1); nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb); avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (avdir + 1); dp = (struct dirent *) (avdir + 1);
av = (const char **) (dp + 1); av = (const char **) (dp + 1);
dt = (unsigned char *) (av + (ac + 1)); dt = (unsigned char *) (av + (ac + 1));
t = (char *) (dt + ac + 1); t = (char *) (dt + ac + 1);
/*@=abstract@*/
avdir->fd = avmagicdir; avdir->fd = avmagicdir;
/*@-usereleased@*/
avdir->data = (char *) dp; avdir->data = (char *) dp;
/*@=usereleased@*/
avdir->allocation = nb; avdir->allocation = nb;
avdir->size = ac; avdir->size = ac;
avdir->offset = -1; avdir->offset = -1;
avdir->filepos = 0; avdir->filepos = 0;
#if defined(HAVE_PTHREAD_H) #if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon -nullpass @*/
(void) pthread_mutex_init(&avdir->lock, NULL); (void) pthread_mutex_init(&avdir->lock, NULL);
/*@=moduncon =noeffectuncon =nullpass @*/
#endif #endif
ac = 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++;
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++; dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++;
/*@=dependenttrans =unrecog@*/
av[ac] = NULL; av[ac] = NULL;
/*@-kepttrans@*/
return (DIR *) avdir; return (DIR *) avdir;
/*@=kepttrans@*/
} }
/*@=boundswrite@*/
#ifdef WITH_NEON #ifdef WITH_NEON
/* =============================================================== */ /* =============================================================== */
/*@unchecked@*/
int davmagicdir = 0x8440291; int davmagicdir = 0x8440291;
int davClosedir(/*@only@*/ DIR * dir) int davClosedir(DIR * dir)
{ {
DAVDIR avdir = (DAVDIR)dir; DAVDIR avdir = (DAVDIR)dir;
@ -1516,9 +1390,7 @@ if (_dav_debug < 0)
fprintf(stderr, "*** davClosedir(%p)\n", avdir); fprintf(stderr, "*** davClosedir(%p)\n", avdir);
#if defined(HAVE_PTHREAD_H) #if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon @*/
(void) pthread_mutex_destroy(&avdir->lock); (void) pthread_mutex_destroy(&avdir->lock);
/*@=moduncon =noeffectuncon @*/
#endif #endif
avdir = _free(avdir); avdir = _free(avdir);
@ -1545,15 +1417,12 @@ struct dirent * davReaddir(DIR * dir)
dt = (unsigned char *) (av + (ac + 1)); dt = (unsigned char *) (av + (ac + 1));
i = avdir->offset + 1; i = avdir->offset + 1;
/*@-boundsread@*/
if (i < 0 || i >= ac || av[i] == NULL) if (i < 0 || i >= ac || av[i] == NULL)
return NULL; return NULL;
/*@=boundsread@*/
avdir->offset = i; avdir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */ /* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */ dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */ dp->d_reclen = 0; /* W2DO? */
@ -1561,11 +1430,8 @@ struct dirent * davReaddir(DIR * dir)
#if !defined(__APPLE__) #if !defined(__APPLE__)
dp->d_off = 0; /* W2DO? */ dp->d_off = 0; /* W2DO? */
#endif #endif
/*@-boundsread@*/
dp->d_type = dt[i]; dp->d_type = dt[i];
/*@=boundsread@*/
#endif #endif
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name)); strncpy(dp->d_name, av[i], sizeof(dp->d_name));
if (_dav_debug < 0) if (_dav_debug < 0)
@ -1574,7 +1440,6 @@ fprintf(stderr, "*** davReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name)
return dp; return dp;
} }
/*@-boundswrite@*/
DIR * davOpendir(const char * path) DIR * davOpendir(const char * path)
{ {
struct fetch_context_s * ctx; struct fetch_context_s * ctx;
@ -1589,14 +1454,12 @@ DIR * davOpendir(const char * path)
/* HACK: glob does not pass dirs with trailing '/' */ /* HACK: glob does not pass dirs with trailing '/' */
nb = strlen(path)+1; nb = strlen(path)+1;
/*@-branchstate@*/
if (path[nb-1] != '/') { if (path[nb-1] != '/') {
char * npath = alloca(nb+1); char * npath = alloca(nb+1);
*npath = '\0'; *npath = '\0';
(void) stpcpy( stpcpy(npath, path), "/"); (void) stpcpy( stpcpy(npath, path), "/");
path = npath; path = npath;
} }
/*@=branchstate@*/
if (_dav_debug < 0) if (_dav_debug < 0)
fprintf(stderr, "*** davOpendir(%s)\n", path); fprintf(stderr, "*** davOpendir(%s)\n", path);
@ -1624,33 +1487,25 @@ fprintf(stderr, "*** davOpendir(%s)\n", path);
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1); nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb); avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (avdir + 1); dp = (struct dirent *) (avdir + 1);
nav = (const char **) (dp + 1); nav = (const char **) (dp + 1);
dt = (unsigned char *) (nav + (ac + 1)); dt = (unsigned char *) (nav + (ac + 1));
t = (char *) (dt + ac + 1); t = (char *) (dt + ac + 1);
/*@=abstract@*/
avdir->fd = davmagicdir; avdir->fd = davmagicdir;
/*@-usereleased@*/
avdir->data = (char *) dp; avdir->data = (char *) dp;
/*@=usereleased@*/
avdir->allocation = nb; avdir->allocation = nb;
avdir->size = ac; avdir->size = ac;
avdir->offset = -1; avdir->offset = -1;
avdir->filepos = 0; avdir->filepos = 0;
#if defined(HAVE_PTHREAD_H) #if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon -nullpass @*/
(void) pthread_mutex_init(&avdir->lock, NULL); (void) pthread_mutex_init(&avdir->lock, NULL);
/*@=moduncon =noeffectuncon =nullpass @*/
#endif #endif
nac = 0; nac = 0;
/*@-dependenttrans -unrecog@*/
dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, "."); t++; dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, "."); t++;
dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, ".."); t++; dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, ".."); t++;
/*@=dependenttrans =unrecog@*/
/* Copy DAV items into DIR elments. */ /* Copy DAV items into DIR elments. */
ac = 0; ac = 0;
@ -1667,10 +1522,7 @@ fprintf(stderr, "*** davOpendir(%s)\n", path);
ctx = fetch_destroy_context(ctx); ctx = fetch_destroy_context(ctx);
/*@-kepttrans@*/
return (DIR *) avdir; return (DIR *) avdir;
/*@=kepttrans@*/
} }
#endif /* WITH_NEON */ #endif /* WITH_NEON */
/*@=modfilesys@*/

View File

@ -37,13 +37,11 @@ typedef DIR * DAVDIR;
/** /**
*/ */
/*@unchecked@*/
extern int avmagicdir; extern int avmagicdir;
#define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir))) #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
/** /**
*/ */
/*@unchecked@*/
extern int davmagicdir; extern int davmagicdir;
#define ISDAVMAGIC(_dir) (!memcmp((_dir), &davmagicdir, sizeof(davmagicdir))) #define ISDAVMAGIC(_dir) (!memcmp((_dir), &davmagicdir, sizeof(davmagicdir)))
@ -56,29 +54,21 @@ extern "C" {
* @param dir argv DIR * @param dir argv DIR
* @return 0 always * @return 0 always
*/ */
int avClosedir(/*@only@*/ DIR * dir) int avClosedir(DIR * dir);
/*@globals fileSystem @*/
/*@modifies dir, fileSystem @*/;
/** /**
* Return next entry from an argv directory. * Return next entry from an argv directory.
* @param dir argv DIR * @param dir argv DIR
* @return next entry * @return next entry
*/ */
/*@dependent@*/ /*@null@*/ struct dirent * avReaddir(DIR * dir);
struct dirent * avReaddir(DIR * dir)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* Create an argv directory from URL collection. * Create an argv directory from URL collection.
* @param path URL for collection path * @param path URL for collection path
* @return argv DIR * @return argv DIR
*/ */
/*@null@*/ DIR * avOpendir(const char * path);
DIR * avOpendir(const char * path)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* Send a http request. * Send a http request.
@ -87,9 +77,7 @@ DIR * avOpendir(const char * path)
* @param httpArg http command argument (NULL if none) * @param httpArg http command argument (NULL if none)
* @returns 0 on success * @returns 0 on success
*/ */
int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg) int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg);
/*@globals fileSystem, internalState @*/
/*@modifies ctrl, fileSystem, internalState @*/;
/** /**
* Read a http response. * Read a http response.
@ -98,112 +86,75 @@ int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
* @retval *str error msg * @retval *str error msg
* @returns 0 on success * @returns 0 on success
*/ */
int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str) int davResp(urlinfo u, FD_t ctrl, char *const * str);
/*@globals fileSystem, internalState @*/
/*@modifies ctrl, *str, fileSystem, internalState @*/;
/** /**
*/ */
/*@null@*/ FD_t davOpen(const char * url, int flags,
FD_t davOpen(const char * url, /*@unused@*/ int flags, mode_t mode, urlinfo * uret);
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
/*@globals internalState @*/
/*@modifies *uret, internalState @*/;
/** /**
*/ */
/*@-incondefs@*/ ssize_t davRead(void * cookie, char * buf, size_t count);
ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
/*@globals fileSystem, internalState @*/
/*@modifies buf, fileSystem, internalState @*/
/*@requires maxSet(buf) >= (count - 1) @*/
/*@ensures maxRead(buf) == result @*/;
/*@=incondefs@*/
/** /**
*/ */
ssize_t davWrite(void * cookie, const char * buf, size_t count) ssize_t davWrite(void * cookie, const char * buf, size_t count);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
*/ */
int davSeek(void * cookie, _libio_pos_t pos, int whence) int davSeek(void * cookie, _libio_pos_t pos, int whence);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
*/ */
int davClose(void * cookie) int davClose(void * cookie);
/*@globals fileSystem, internalState @*/
/*@modifies cookie, fileSystem, internalState @*/;
/** /**
*/ */
int davMkdir(const char * path, mode_t mode) int davMkdir(const char * path, mode_t mode);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
*/ */
int davRmdir(const char * path) int davRmdir(const char * path);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
*/ */
int davRename(const char * oldpath, const char * newpath) int davRename(const char * oldpath, const char * newpath);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
*/ */
int davUnlink(const char * path) int davUnlink(const char * path);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* Close a DAV collection. * Close a DAV collection.
* @param dir argv DIR * @param dir argv DIR
* @return 0 always * @return 0 always
*/ */
int davClosedir(/*@only@*/ DIR * dir) int davClosedir(DIR * dir);
/*@globals fileSystem @*/
/*@modifies dir, fileSystem @*/;
/** /**
* Return next entry from a DAV collection. * Return next entry from a DAV collection.
* @param dir argv DIR * @param dir argv DIR
* @return next entry * @return next entry
*/ */
/*@dependent@*/ /*@null@*/ struct dirent * davReaddir(DIR * dir);
struct dirent * davReaddir(DIR * dir)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* Create an argv directory from DAV collection. * Create an argv directory from DAV collection.
* @param path URL for DAV collection path * @param path URL for DAV collection path
* @return argv DIR * @return argv DIR
*/ */
/*@null@*/ DIR * davOpendir(const char * path);
DIR * davOpendir(const char * path)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* stat(2) clone. * stat(2) clone.
*/ */
int davStat(const char * path, /*@out@*/ struct stat * st) int davStat(const char * path, struct stat * st);
/*@globals fileSystem, internalState @*/
/*@modifies *st, fileSystem, internalState @*/;
/** /**
* lstat(2) clone. * lstat(2) clone.
*/ */
int davLstat(const char * path, /*@out@*/ struct stat * st) int davLstat(const char * path, struct stat * st);
/*@globals fileSystem, internalState @*/
/*@modifies *st, fileSystem, internalState @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -22,20 +22,15 @@
/** /**
* Tokens used by rpmError(). * Tokens used by rpmError().
*/ */
/*@-typeuse @*/
typedef enum rpmerrCode_e { typedef enum rpmerrCode_e {
/*@-enummemuse@*/
RPMERR_GDBMOPEN = _em(2), /*!< gdbm open failed */ RPMERR_GDBMOPEN = _em(2), /*!< gdbm open failed */
RPMERR_GDBMREAD = _em(3), /*!< gdbm read failed */ RPMERR_GDBMREAD = _em(3), /*!< gdbm read failed */
RPMERR_GDBMWRITE = _em(4), /*!< gdbm write failed */ RPMERR_GDBMWRITE = _em(4), /*!< gdbm write failed */
/*@=enummemuse@*/
RPMERR_INTERNAL = _em(5), /*!< internal RPM error */ RPMERR_INTERNAL = _em(5), /*!< internal RPM error */
RPMERR_DBCORRUPT = _em(6), /*!< rpm database is corrupt */ RPMERR_DBCORRUPT = _em(6), /*!< rpm database is corrupt */
/*@-enummemuse@*/
RPMERR_OLDDBCORRUPT = _em(7), /*!< old style rpm database is corrupt */ RPMERR_OLDDBCORRUPT = _em(7), /*!< old style rpm database is corrupt */
RPMERR_OLDDBMISSING = _em(8), /*!< old style rpm database is missing */ RPMERR_OLDDBMISSING = _em(8), /*!< old style rpm database is missing */
RPMERR_NOCREATEDB = _em(9), /*!< cannot create new database */ RPMERR_NOCREATEDB = _em(9), /*!< cannot create new database */
/*@=enummemuse@*/
RPMERR_DBOPEN = _em(10), /*!< database open failed */ RPMERR_DBOPEN = _em(10), /*!< database open failed */
RPMERR_DBGETINDEX = _em(11), /*!< database get from index failed */ RPMERR_DBGETINDEX = _em(11), /*!< database get from index failed */
RPMERR_DBPUTINDEX = _em(12), /*!< database get from index failed */ RPMERR_DBPUTINDEX = _em(12), /*!< database get from index failed */
@ -44,60 +39,44 @@ typedef enum rpmerrCode_e {
RPMERR_RENAME = _em(15), /*!< rename(2) failed */ RPMERR_RENAME = _em(15), /*!< rename(2) failed */
RPMERR_UNLINK = _em(16), /*!< unlink(2) failed */ RPMERR_UNLINK = _em(16), /*!< unlink(2) failed */
RPMERR_RMDIR = _em(17), /*!< rmdir(2) failed */ RPMERR_RMDIR = _em(17), /*!< rmdir(2) failed */
/*@-enummemuse@*/
RPMERR_PKGINSTALLED = _em(18), /*!< package already installed */ RPMERR_PKGINSTALLED = _em(18), /*!< package already installed */
RPMERR_CHOWN = _em(19), /*!< chown() call failed */ RPMERR_CHOWN = _em(19), /*!< chown() call failed */
RPMERR_NOUSER = _em(20), /*!< user does not exist */ RPMERR_NOUSER = _em(20), /*!< user does not exist */
RPMERR_NOGROUP = _em(21), /*!< group does not exist */ RPMERR_NOGROUP = _em(21), /*!< group does not exist */
/*@=enummemuse@*/
RPMERR_MKDIR = _em(22), /*!< mkdir() call failed */ RPMERR_MKDIR = _em(22), /*!< mkdir() call failed */
/*@-enummemuse@*/
RPMERR_FILECONFLICT = _em(23), /*!< file being installed exists */ RPMERR_FILECONFLICT = _em(23), /*!< file being installed exists */
/*@=enummemuse@*/
RPMERR_RPMRC = _em(24), /*!< bad line in rpmrc */ RPMERR_RPMRC = _em(24), /*!< bad line in rpmrc */
RPMERR_NOSPEC = _em(25), /*!< .spec file is missing */ RPMERR_NOSPEC = _em(25), /*!< .spec file is missing */
RPMERR_NOTSRPM = _em(26), /*!< a source rpm was expected */ RPMERR_NOTSRPM = _em(26), /*!< a source rpm was expected */
/*@-enummemuse@*/
RPMERR_FLOCK = _em(27), /*!< locking the database failed */ RPMERR_FLOCK = _em(27), /*!< locking the database failed */
RPMERR_OLDPACKAGE = _em(28), /*!< trying upgrading to old version */ RPMERR_OLDPACKAGE = _em(28), /*!< trying upgrading to old version */
/* RPMERR_BADARCH = _em(29), bad architecture or arch mismatch */ /* RPMERR_BADARCH = _em(29), bad architecture or arch mismatch */
/*@=enummemuse@*/
RPMERR_CREATE = _em(30), /*!< failed to create a file */ RPMERR_CREATE = _em(30), /*!< failed to create a file */
RPMERR_NOSPACE = _em(31), /*!< out of disk space */ RPMERR_NOSPACE = _em(31), /*!< out of disk space */
/*@-enummemuse@*/
RPMERR_NORELOCATE = _em(32), /*!< tried to do improper relocatation */ RPMERR_NORELOCATE = _em(32), /*!< tried to do improper relocatation */
/* RPMERR_BADOS = _em(33), bad architecture or arch mismatch */ /* RPMERR_BADOS = _em(33), bad architecture or arch mismatch */
RPMMESS_BACKUP = _em(34), /*!< backup made during [un]install */ RPMMESS_BACKUP = _em(34), /*!< backup made during [un]install */
/*@=enummemuse@*/
RPMERR_MTAB = _em(35), /*!< failed to read mount table */ RPMERR_MTAB = _em(35), /*!< failed to read mount table */
RPMERR_STAT = _em(36), /*!< failed to stat something */ RPMERR_STAT = _em(36), /*!< failed to stat something */
RPMERR_BADDEV = _em(37), /*!< file on device not listed in mtab */ RPMERR_BADDEV = _em(37), /*!< file on device not listed in mtab */
/*@-enummemuse@*/
RPMMESS_ALTNAME = _em(38), /*!< file written as .rpmnew */ RPMMESS_ALTNAME = _em(38), /*!< file written as .rpmnew */
RPMMESS_PREREQLOOP = _em(39), /*!< loop in prerequisites */ RPMMESS_PREREQLOOP = _em(39), /*!< loop in prerequisites */
RPMERR_BADRELOCATE = _em(40), /*!< bad relocation was specified */ RPMERR_BADRELOCATE = _em(40), /*!< bad relocation was specified */
RPMERR_OLDDB = _em(41), /*!< old format database */ RPMERR_OLDDB = _em(41), /*!< old format database */
/*@=enummemuse@*/
RPMERR_UNMATCHEDIF = _em(107), /*!< unclosed %ifarch or %ifos */ RPMERR_UNMATCHEDIF = _em(107), /*!< unclosed %ifarch or %ifos */
RPMERR_RELOAD = _em(108), /*!< */ RPMERR_RELOAD = _em(108), /*!< */
RPMERR_BADARG = _em(109), /*!< */ RPMERR_BADARG = _em(109), /*!< */
RPMERR_SCRIPT = _em(110), /*!< errors related to script exec */ RPMERR_SCRIPT = _em(110), /*!< errors related to script exec */
RPMERR_READ = _em(111), /*!< */ RPMERR_READ = _em(111), /*!< */
/*@-enummemuse@*/
RPMERR_UNKNOWNOS = _em(112), /*!< */ RPMERR_UNKNOWNOS = _em(112), /*!< */
RPMERR_UNKNOWNARCH = _em(113), /*!< */ RPMERR_UNKNOWNARCH = _em(113), /*!< */
/*@=enummemuse@*/
RPMERR_EXEC = _em(114), /*!< */ RPMERR_EXEC = _em(114), /*!< */
RPMERR_FORK = _em(115), /*!< */ RPMERR_FORK = _em(115), /*!< */
RPMERR_CPIO = _em(116), /*!< */ RPMERR_CPIO = _em(116), /*!< */
/*@-enummemuse@*/
RPMERR_GZIP = _em(117), /*!< */ RPMERR_GZIP = _em(117), /*!< */
/*@=enummemuse@*/
RPMERR_BADSPEC = _em(118), /*!< */ RPMERR_BADSPEC = _em(118), /*!< */
/*@-enummemuse@*/
RPMERR_LDD = _em(119), /*!< couldn't understand ldd output */ RPMERR_LDD = _em(119), /*!< couldn't understand ldd output */
/*@=enummemuse@*/
RPMERR_BADFILENAME = _em(120), /*!< */ RPMERR_BADFILENAME = _em(120), /*!< */
RPMERR_OPEN = _em(121), /*!< */ RPMERR_OPEN = _em(121), /*!< */
RPMERR_POPEN = _em(122), /*!< */ RPMERR_POPEN = _em(122), /*!< */
@ -105,11 +84,9 @@ typedef enum rpmerrCode_e {
RPMERR_QUERY = _em(124), /*!< */ RPMERR_QUERY = _em(124), /*!< */
RPMERR_QFMT = _em(125), /*!< */ RPMERR_QFMT = _em(125), /*!< */
RPMERR_DBCONFIG = _em(126), /*!< */ RPMERR_DBCONFIG = _em(126), /*!< */
/*@-enummemuse@*/
RPMERR_DBERR = _em(127), /*!< */ RPMERR_DBERR = _em(127), /*!< */
RPMERR_BADPACKAGE = _em(128), /*!< getNextHeader: %s */ RPMERR_BADPACKAGE = _em(128), /*!< getNextHeader: %s */
RPMERR_FREELIST = _em(129), /*!< free list corrupt (%u)- please ... */ RPMERR_FREELIST = _em(129), /*!< free list corrupt (%u)- please ... */
/*@=enummemuse@*/
RPMERR_DATATYPE = _em(130), /*!< Data type %d not supported */ RPMERR_DATATYPE = _em(130), /*!< Data type %d not supported */
RPMERR_BUILDROOT = _em(131), /*!< */ RPMERR_BUILDROOT = _em(131), /*!< */
RPMERR_MAKETEMP = _em(132), /*!< makeTempFile failed */ RPMERR_MAKETEMP = _em(132), /*!< makeTempFile failed */
@ -131,11 +108,8 @@ typedef enum rpmerrCode_e {
RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */ RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */
RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */ RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */
/*@-enummemuse@*/
RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */ RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */
/*@=enummemuse@*/
} rpmerrCode; } rpmerrCode;
/*@=typeuse @*/
/** /**
* Retrofit rpmError() onto rpmlog sub-system. * Retrofit rpmError() onto rpmlog sub-system.
@ -144,9 +118,7 @@ typedef enum rpmerrCode_e {
#define rpmErrorCode() rpmlogCode() #define rpmErrorCode() rpmlogCode()
#define rpmErrorString() rpmlogMessage() #define rpmErrorString() rpmlogMessage()
#define rpmErrorSetCallback(_cb) rpmlogSetCallback(_cb) #define rpmErrorSetCallback(_cb) rpmlogSetCallback(_cb)
/*@-typeuse@*/
typedef rpmlogCallback rpmErrorCallBackType; typedef rpmlogCallback rpmErrorCallBackType;
/*@=typeuse@*/
#endif /* H_RPMERR */ #endif /* H_RPMERR */

View File

@ -1,4 +1,3 @@
/*@-bounds@*/
#include "system.h" #include "system.h"
#include <stdlib.h> #include <stdlib.h>
@ -19,7 +18,6 @@ typedef struct rpmhookItem_s {
typedef struct rpmhookBucket_s { typedef struct rpmhookBucket_s {
unsigned long hash; unsigned long hash;
/*@relnull@*/
char *name; char *name;
rpmhookItem item; rpmhookItem item;
} * rpmhookBucket; } * rpmhookBucket;
@ -46,9 +44,7 @@ rpmhookArgs rpmhookArgsFree(rpmhookArgs args)
return NULL; return NULL;
} }
/*@only@*/
static rpmhookTable rpmhookTableNew(int size) static rpmhookTable rpmhookTableNew(int size)
/*@*/
{ {
rpmhookTable table = (rpmhookTable) xcalloc(1, rpmhookTable table = (rpmhookTable) xcalloc(1,
sizeof(*table) + sizeof(table->bucket) * (size-1)); sizeof(*table) + sizeof(table->bucket) * (size-1));
@ -58,7 +54,6 @@ static rpmhookTable rpmhookTableNew(int size)
#if 0 #if 0
static rpmhookTable rpmhookTableFree(rpmhookTable table) static rpmhookTable rpmhookTableFree(rpmhookTable table)
/*@*/
{ {
rpmhookItem item, nextItem; rpmhookItem item, nextItem;
int i; int i;
@ -78,11 +73,9 @@ static rpmhookTable rpmhookTableFree(rpmhookTable table)
} }
#endif #endif
static void rpmhookTableRehash(rpmhookTable *table) static void rpmhookTableRehash(rpmhookTable *table);
/*@modifies *table @*/;
static int rpmhookTableFindBucket(rpmhookTable *table, const char *name) static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
/*@modifies *table @*/
{ {
/* Hash based on http://www.isthe.com/chongo/tech/comp/fnv/ */ /* Hash based on http://www.isthe.com/chongo/tech/comp/fnv/ */
unsigned long perturb; unsigned long perturb;
@ -104,9 +97,7 @@ static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
while (bucket->name && while (bucket->name &&
(bucket->hash != hash || strcmp(bucket->name, name) != 0)) { (bucket->hash != hash || strcmp(bucket->name, name) != 0)) {
/* Collision resolution based on Python's perturb scheme. */ /* Collision resolution based on Python's perturb scheme. */
/*@-shiftimplementation@*/
ret = ((ret << 2) + ret + perturb + 1) % (*table)->size; ret = ((ret << 2) + ret + perturb + 1) % (*table)->size;
/*@=shiftimplementation@*/
perturb >>= 5; perturb >>= 5;
bucket = &(*table)->bucket[ret]; bucket = &(*table)->bucket[ret];
} }
@ -116,12 +107,10 @@ static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
} }
static void rpmhookTableRehash(rpmhookTable *table) static void rpmhookTableRehash(rpmhookTable *table)
/*@modifies *table @*/
{ {
rpmhookTable newtable = rpmhookTableNew((*table)->size*2); rpmhookTable newtable = rpmhookTableNew((*table)->size*2);
int n, i = 0; int n, i = 0;
/*@-branchstate@*/
for (; i != (*table)->size; i++) { for (; i != (*table)->size; i++) {
if ((*table)->bucket[i].name == NULL) if ((*table)->bucket[i].name == NULL)
continue; continue;
@ -129,17 +118,13 @@ static void rpmhookTableRehash(rpmhookTable *table)
newtable->bucket[n].name = (*table)->bucket[i].name; newtable->bucket[n].name = (*table)->bucket[i].name;
newtable->bucket[n].item = (*table)->bucket[i].item; newtable->bucket[n].item = (*table)->bucket[i].item;
} }
/*@=branchstate@*/
newtable->used = (*table)->used; newtable->used = (*table)->used;
/*@-unqualifiedtrans@*/
free(*table); free(*table);
/*@=unqualifiedtrans@*/
*table = newtable; *table = newtable;
} }
static void rpmhookTableAddItem(rpmhookTable *table, const char *name, static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
rpmhookFunc func, void *data) rpmhookFunc func, void *data)
/*@modifies *table @*/
{ {
int n = rpmhookTableFindBucket(table, name); int n = rpmhookTableFindBucket(table, name);
rpmhookBucket bucket = &(*table)->bucket[n]; rpmhookBucket bucket = &(*table)->bucket[n];
@ -151,15 +136,12 @@ static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
while (*item) item = &(*item)->next; while (*item) item = &(*item)->next;
*item = xcalloc(1, sizeof(**item)); *item = xcalloc(1, sizeof(**item));
(*item)->func = func; (*item)->func = func;
/*@-temptrans@*/
(*item)->data = data; (*item)->data = data;
/*@=temptrans@*/
} }
static void rpmhookTableDelItem(rpmhookTable *table, const char *name, static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
/*@null@*/ rpmhookFunc func, /*@null@*/ void *data, rpmhookFunc func, void *data,
int matchfunc, int matchdata) int matchfunc, int matchdata)
/*@modifies *table @*/
{ {
int n = rpmhookTableFindBucket(table, name); int n = rpmhookTableFindBucket(table, name);
rpmhookBucket bucket = &(*table)->bucket[n]; rpmhookBucket bucket = &(*table)->bucket[n];
@ -168,7 +150,6 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
rpmhookItem nextItem; rpmhookItem nextItem;
while (item) { while (item) {
nextItem = item->next; nextItem = item->next;
/*@-branchstate@*/
if ((!matchfunc || item->func == func) && if ((!matchfunc || item->func == func) &&
(!matchdata || item->data == data)) { (!matchdata || item->data == data)) {
free(item); free(item);
@ -179,8 +160,6 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
} else { } else {
lastItem = item; lastItem = item;
} }
/*@=branchstate@*/
/*@-usereleased@*/
item = nextItem; item = nextItem;
} }
if (!bucket->item) { if (!bucket->item) {
@ -188,38 +167,32 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
bucket->name = NULL; bucket->name = NULL;
(*table)->used--; (*table)->used--;
} }
/*@=usereleased@*/
} }
static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap) static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap)
/*@*/
{ {
rpmhookArgs args = rpmhookArgsNew(strlen(argt)); rpmhookArgs args = rpmhookArgsNew(strlen(argt));
int i; int i;
/*@-temptrans@*/
args->argt = argt; args->argt = argt;
/*@=temptrans@*/
for (i = 0; i != args->argc; i++) { for (i = 0; i != args->argc; i++) {
switch (argt[i]) { switch (argt[i]) {
case 's': case 's':
args->argv[i].s = va_arg(ap, char *); args->argv[i].s = va_arg(ap, char *);
/*@switchbreak@*/ break; break;
case 'i': case 'i':
args->argv[i].i = va_arg(ap, int); args->argv[i].i = va_arg(ap, int);
/*@switchbreak@*/ break; break;
case 'f': case 'f':
args->argv[i].f = (float)va_arg(ap, double); args->argv[i].f = (float)va_arg(ap, double);
/*@switchbreak@*/ break; break;
case 'p': case 'p':
args->argv[i].p = va_arg(ap, void *); args->argv[i].p = va_arg(ap, void *);
/*@switchbreak@*/ break; break;
default: default:
/*@-modfilesys @*/
fprintf(stderr, "error: unsupported type '%c' as " fprintf(stderr, "error: unsupported type '%c' as "
"a hook argument\n", argt[i]); "a hook argument\n", argt[i]);
/*@=modfilesys @*/ break;
/*@switchbreak@*/ break;
} }
} }
return args; return args;
@ -227,7 +200,6 @@ static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap)
static void rpmhookTableCallArgs(rpmhookTable *table, const char *name, static void rpmhookTableCallArgs(rpmhookTable *table, const char *name,
rpmhookArgs args) rpmhookArgs args)
/*@modifies *table @*/
{ {
int n = rpmhookTableFindBucket(table, name); int n = rpmhookTableFindBucket(table, name);
rpmhookItem item = (*table)->bucket[n].item; rpmhookItem item = (*table)->bucket[n].item;
@ -238,12 +210,9 @@ static void rpmhookTableCallArgs(rpmhookTable *table, const char *name,
} }
} }
/*@unchecked@*/ /*@only@*/ /*@null@*/
static rpmhookTable globalTable = NULL; static rpmhookTable globalTable = NULL;
void rpmhookRegister(const char *name, rpmhookFunc func, void *data) void rpmhookRegister(const char *name, rpmhookFunc func, void *data)
/*@globals globalTable @*/
/*@modifies globalTable @*/
{ {
if (globalTable == NULL) if (globalTable == NULL)
globalTable = rpmhookTableNew(RPMHOOK_TABLE_INITSIZE); globalTable = rpmhookTableNew(RPMHOOK_TABLE_INITSIZE);
@ -275,9 +244,7 @@ void rpmhookCall(const char *name, const char *argt, ...)
va_list ap; va_list ap;
va_start(ap, argt); va_start(ap, argt);
args = rpmhookArgsParse(argt, ap); args = rpmhookArgsParse(argt, ap);
/*@-noeffect@*/
rpmhookTableCallArgs(&globalTable, name, args); rpmhookTableCallArgs(&globalTable, name, args);
/*@=noeffect@*/
(void) rpmhookArgsFree(args); (void) rpmhookArgsFree(args);
va_end(ap); va_end(ap);
} }
@ -285,9 +252,6 @@ void rpmhookCall(const char *name, const char *argt, ...)
void rpmhookCallArgs(const char *name, rpmhookArgs args) void rpmhookCallArgs(const char *name, rpmhookArgs args)
{ {
/*@-noeffect@*/
if (globalTable != NULL) if (globalTable != NULL)
rpmhookTableCallArgs(&globalTable, name, args); rpmhookTableCallArgs(&globalTable, name, args);
/*@=noeffect@*/
} }
/*@=bounds@*/

View File

@ -2,11 +2,9 @@
#define RPMHOOK_H #define RPMHOOK_H
typedef union { typedef union {
/*@observer@*/
const char * s; const char * s;
int i; int i;
float f; float f;
/*@observer@*/
void * p; void * p;
} rpmhookArgv; } rpmhookArgv;
@ -18,26 +16,14 @@ typedef struct rpmhookArgs_s {
typedef int (*rpmhookFunc) (rpmhookArgs args, void *data); typedef int (*rpmhookFunc) (rpmhookArgs args, void *data);
/*@only@*/ rpmhookArgs rpmhookArgsNew(int argc);
rpmhookArgs rpmhookArgsNew(int argc) rpmhookArgs rpmhookArgsFree(rpmhookArgs args);
/*@*/;
/*@null@*/
rpmhookArgs rpmhookArgsFree(/*@only@*/ /*@null@*/ rpmhookArgs args)
/*@modifies args @*/;
void rpmhookRegister(const char *name, rpmhookFunc func, void *data) void rpmhookRegister(const char *name, rpmhookFunc func, void *data);
/*@globals internalState @*/ void rpmhookUnregister(const char *name, rpmhookFunc func, void *data);
/*@modifies internalState @*/; void rpmhookUnregisterAny(const char *name, rpmhookFunc func);
void rpmhookUnregister(const char *name, rpmhookFunc func, void *data) void rpmhookUnregisterAll(const char *name);
/*@*/; void rpmhookCall(const char *name, const char *argt, ...);
void rpmhookUnregisterAny(const char *name, rpmhookFunc func) void rpmhookCallArgs(const char *name, rpmhookArgs args);
/*@*/;
void rpmhookUnregisterAll(const char *name)
/*@*/;
void rpmhookCall(const char *name, const char *argt, ...)
/*@*/;
void rpmhookCallArgs(const char *name, rpmhookArgs args)
/*@globals internalState @*/
/*@modifies internalState @*/;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -9,20 +9,18 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
/*@-noparams@*/
#include "glob.h" #include "glob.h"
/*@=noparams@*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
/** /**
*/ */
typedef /*@abstract@*/ struct pgpDig_s * pgpDig; typedef struct pgpDig_s * pgpDig;
/** /**
*/ */
typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams; typedef struct pgpDigParams_s * pgpDigParams;
/** \ingroup rpmio /** \ingroup rpmio
* Hide libio API lossage. * Hide libio API lossage.
@ -30,7 +28,6 @@ typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams;
* argument as a pointer rather than as an off_t. The snarl below defines * argument as a pointer rather than as an off_t. The snarl below defines
* typedefs to isolate the lossage. * typedefs to isolate the lossage.
*/ */
/*@{*/
#if defined(__GLIBC__) && \ #if defined(__GLIBC__) && \
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
#define USE_COOKIE_SEEK_POINTER 1 #define USE_COOKIE_SEEK_POINTER 1
@ -40,15 +37,14 @@ typedef _libio_off_t * _libio_pos_t;
typedef off_t _libio_off_t; typedef off_t _libio_off_t;
typedef off_t _libio_pos_t; typedef off_t _libio_pos_t;
#endif #endif
/*@}*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */
typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t; typedef struct _FD_s * FD_t;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
typedef /*@observer@*/ struct FDIO_s * FDIO_t; typedef struct FDIO_s * FDIO_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -57,146 +53,98 @@ extern "C" {
/** \ingroup rpmio /** \ingroup rpmio
* \name RPMIO Vectors. * \name RPMIO Vectors.
*/ */
/*@{*/
/** /**
*/ */
typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes) typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes);
/*@globals errno, fileSystem @*/
/*@modifies *cookie, errno, fileSystem @*/
/*@requires maxSet(buf) >= (nbytes - 1) @*/
/*@ensures maxRead(buf) == result @*/ ;
/** /**
*/ */
typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes) typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes);
/*@globals errno, fileSystem @*/
/*@modifies *cookie, errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence) typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence);
/*@globals errno, fileSystem @*/
/*@modifies *cookie, errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_close_function_t) (void *cookie) typedef int (*fdio_close_function_t) (void *cookie);
/*@globals errno, fileSystem, systemState @*/
/*@modifies *cookie, errno, fileSystem, systemState @*/;
/** /**
*/ */
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_ref_function_t) ( /*@only@*/ void * cookie, typedef FD_t (*fdio_ref_function_t) ( void * cookie,
const char * msg, const char * file, unsigned line) const char * msg, const char * file, unsigned line);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
*/ */
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_deref_function_t) ( /*@only@*/ FD_t fd, typedef FD_t (*fdio_deref_function_t) ( FD_t fd,
const char * msg, const char * file, unsigned line) const char * msg, const char * file, unsigned line);
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/** /**
*/ */
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_new_function_t) (const char * msg, typedef FD_t (*fdio_new_function_t) (const char * msg,
const char * file, unsigned line) const char * file, unsigned line);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_fileno_function_t) (void * cookie) typedef int (*fdio_fileno_function_t) (void * cookie);
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/** /**
*/ */
typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode) typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
*/ */
typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode) typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
*/ */
typedef void * (*fdio_ffileno_function_t) (FD_t fd) typedef void * (*fdio_ffileno_function_t) (FD_t fd);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_fflush_function_t) (FD_t fd) typedef int (*fdio_fflush_function_t) (FD_t fd);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@}*/
/** \ingroup rpmrpc /** \ingroup rpmrpc
* \name RPMRPC Vectors. * \name RPMRPC Vectors.
*/ */
/*@{*/
/** /**
*/ */
typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode) typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_chdir_function_t) (const char * path) typedef int (*fdio_chdir_function_t) (const char * path);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_rmdir_function_t) (const char * path) typedef int (*fdio_rmdir_function_t) (const char * path);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath) typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_unlink_function_t) (const char * path) typedef int (*fdio_unlink_function_t) (const char * path);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/*@-typeuse@*/
/** /**
*/ */
typedef int (*fdio_stat_function_t) (const char * path, /*@out@*/ struct stat * st) typedef int (*fdio_stat_function_t) (const char * path, struct stat * st);
/*@globals errno, fileSystem @*/
/*@modifies *st, errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_lstat_function_t) (const char * path, /*@out@*/ struct stat * st) typedef int (*fdio_lstat_function_t) (const char * path, struct stat * st);
/*@globals errno, fileSystem @*/
/*@modifies *st, errno, fileSystem @*/;
/** /**
*/ */
typedef int (*fdio_access_function_t) (const char * path, int amode) typedef int (*fdio_access_function_t) (const char * path, int amode);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/*@=typeuse@*/
/*@}*/
/** \ingroup rpmio /** \ingroup rpmio
@ -228,331 +176,225 @@ struct FDIO_s {
/** \ingroup rpmio /** \ingroup rpmio
* \name RPMIO Interface. * \name RPMIO Interface.
*/ */
/*@{*/
/** /**
* strerror(3) clone. * strerror(3) clone.
*/ */
/*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd) const char * Fstrerror(FD_t fd);
/*@*/;
/** /**
* fread(3) clone. * fread(3) clone.
*/ */
/*@-incondefs@*/ ssize_t Fread(void * buf, size_t size, size_t nmemb, FD_t fd);
ssize_t Fread(/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, *buf, fileSystem @*/
/*@requires maxSet(buf) >= (nmemb - 1) @*/
/*@ensures maxRead(buf) == result @*/;
/*@=incondefs@*/
/** /**
* fwrite(3) clone. * fwrite(3) clone.
*/ */
/*@-incondefs@*/ ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd);
ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/
/*@requires maxRead(buf) >= nmemb @*/;
/*@=incondefs@*/
/** /**
* fseek(3) clone. * fseek(3) clone.
*/ */
int Fseek(FD_t fd, _libio_off_t offset, int whence) int Fseek(FD_t fd, _libio_off_t offset, int whence);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* fclose(3) clone. * fclose(3) clone.
*/ */
int Fclose( /*@killref@*/ FD_t fd) int Fclose( FD_t fd);
/*@globals fileSystem, internalState @*/
/*@modifies fd, fileSystem, internalState @*/;
/** /**
*/ */
/*@null@*/ FD_t Fdopen(FD_t ofd, const char * fmode) FD_t Fdopen(FD_t ofd, const char * fmode);
/*@globals fileSystem @*/
/*@modifies ofd, fileSystem @*/;
/** /**
* fopen(3) clone. * fopen(3) clone.
*/ */
/*@null@*/ FD_t Fopen(/*@null@*/ const char * path, FD_t Fopen(const char * path,
/*@null@*/ const char * fmode) const char * fmode);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* fflush(3) clone. * fflush(3) clone.
*/ */
int Fflush(/*@null@*/ FD_t fd) int Fflush(FD_t fd);
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/** /**
* ferror(3) clone. * ferror(3) clone.
*/ */
int Ferror(/*@null@*/ FD_t fd) int Ferror(FD_t fd);
/*@*/;
/** /**
* fileno(3) clone. * fileno(3) clone.
*/ */
int Fileno(FD_t fd) int Fileno(FD_t fd);
/*@globals fileSystem @*/
/*@modifies fileSystem@*/;
/** /**
* fcntl(2) clone. * fcntl(2) clone.
*/ */
/*@unused@*/ int Fcntl(FD_t fd, int op, void *lip);
int Fcntl(FD_t fd, int op, void *lip)
/*@globals errno, fileSystem @*/
/*@modifies fd, *lip, errno, fileSystem @*/;
/*@}*/
/** \ingroup rpmrpc /** \ingroup rpmrpc
* \name RPMRPC Interface. * \name RPMRPC Interface.
*/ */
/*@{*/
/** /**
* mkdir(2) clone. * mkdir(2) clone.
*/ */
int Mkdir(const char * path, mode_t mode) int Mkdir(const char * path, mode_t mode);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* chdir(2) clone. * chdir(2) clone.
*/ */
int Chdir(const char * path) int Chdir(const char * path);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* rmdir(2) clone. * rmdir(2) clone.
*/ */
int Rmdir(const char * path) int Rmdir(const char * path);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* rename(2) clone. * rename(2) clone.
*/ */
int Rename(const char * oldpath, const char * newpath) int Rename(const char * oldpath, const char * newpath);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* link(2) clone. * link(2) clone.
*/ */
int Link(const char * oldpath, const char * newpath) int Link(const char * oldpath, const char * newpath);
/*@globals errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* unlink(2) clone. * unlink(2) clone.
*/ */
int Unlink(const char * path) int Unlink(const char * path);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* readlink(2) clone. * readlink(2) clone.
*/ */
/*@-incondefs@*/ int Readlink(const char * path, char * buf, size_t bufsiz);
int Readlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies *buf, errno, fileSystem, internalState @*/
/*@requires maxSet(buf) >= (bufsiz - 1) @*/
/*@ensures maxRead(buf) <= bufsiz @*/;
/*@=incondefs@*/
/** /**
* stat(2) clone. * stat(2) clone.
*/ */
int Stat(const char * path, /*@out@*/ struct stat * st) int Stat(const char * path, struct stat * st);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies *st, errno, fileSystem, internalState @*/;
/** /**
* lstat(2) clone. * lstat(2) clone.
*/ */
int Lstat(const char * path, /*@out@*/ struct stat * st) int Lstat(const char * path, struct stat * st);
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies *st, errno, fileSystem, internalState @*/;
/** /**
* access(2) clone. * access(2) clone.
*/ */
int Access(const char * path, int amode) int Access(const char * path, int amode);
/*@globals errno, fileSystem @*/
/*@modifies errno, fileSystem @*/;
/** /**
* glob_pattern_p(3) clone. * glob_pattern_p(3) clone.
*/ */
int Glob_pattern_p (const char *pattern, int quote) int Glob_pattern_p (const char *pattern, int quote);
/*@*/;
/** /**
* glob_error(3) clone. * glob_error(3) clone.
*/ */
int Glob_error(const char * epath, int eerrno) int Glob_error(const char * epath, int eerrno);
/*@*/;
/** /**
* glob(3) clone. * glob(3) clone.
*/ */
int Glob(const char * pattern, int flags, int Glob(const char * pattern, int flags,
int errfunc(const char * epath, int eerrno), int errfunc(const char * epath, int eerrno),
/*@out@*/ glob_t * pglob) glob_t * pglob);
/*@globals fileSystem @*/
/*@modifies *pglob, fileSystem @*/;
/** /**
* globfree(3) clone. * globfree(3) clone.
*/ */
void Globfree( /*@only@*/ glob_t * pglob) void Globfree( glob_t * pglob);
/*@globals fileSystem @*/
/*@modifies *pglob, fileSystem @*/;
/** /**
* opendir(3) clone. * opendir(3) clone.
*/ */
/*@null@*/ DIR * Opendir(const char * path);
DIR * Opendir(const char * path)
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
/** /**
* readdir(3) clone. * readdir(3) clone.
*/ */
/*@dependent@*/ /*@null@*/ struct dirent * Readdir(DIR * dir);
struct dirent * Readdir(DIR * dir)
/*@globals errno, fileSystem @*/
/*@modifies *dir, errno, fileSystem @*/;
/** /**
* closedir(3) clone. * closedir(3) clone.
*/ */
int Closedir(/*@only@*/ DIR * dir) int Closedir(DIR * dir);
/*@globals errno, fileSystem @*/
/*@modifies *dir, errno, fileSystem @*/;
/*@}*/
/** \ingroup rpmio /** \ingroup rpmio
* \name RPMIO Utilities. * \name RPMIO Utilities.
*/ */
/*@{*/
/** /**
*/ */
off_t fdSize(FD_t fd) off_t fdSize(FD_t fd);
/*@globals fileSystem @*/
/*@modifies fd, fileSystem@*/;
/** /**
*/ */
/*@null@*/ FD_t fdDup(int fdno) FD_t fdDup(int fdno);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
#ifdef UNUSED #ifdef UNUSED
/*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode); FILE *fdFdopen( void * cookie, const char * mode);
#endif #endif
/* XXX Legacy interfaces needed by gnorpm, rpmfind et al */ /* XXX Legacy interfaces needed by gnorpm, rpmfind et al */
/*@-exportlocal@*/
/** /**
*/ */
#ifndef H_RPMIO_INTERNAL /* XXX avoid gcc warning */ #ifndef H_RPMIO_INTERNAL /* XXX avoid gcc warning */
/*@unused@*/ int fdFileno(void * cookie) int fdFileno(void * cookie);
/*@*/;
#define fdFileno(_fd) fdio->_fileno(_fd) #define fdFileno(_fd) fdio->_fileno(_fd)
#endif #endif
/** /**
*/ */
/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode) FD_t fdOpen(const char *path, int flags, mode_t mode);
/*@globals errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
#define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags), (_mode)) #define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags), (_mode))
/** /**
*/ */
/*@-incondefs@*/ ssize_t fdRead(void * cookie, char * buf, size_t count);
ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count)
/*@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)) #define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count))
/*@=incondefs@*/
/** /**
*/ */
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, internalState @*/
/*@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))
/** /**
*/ */
int fdClose( /*@only@*/ void * cookie) int fdClose( void * cookie);
/*@globals errno, fileSystem, systemState, internalState @*/
/*@modifies *cookie, errno, fileSystem, systemState, internalState @*/;
#define fdClose(_fd) fdio->close(_fd) #define fdClose(_fd) fdio->close(_fd)
/** /**
*/ */
/*@unused@*/ FD_t fdLink (void * cookie, const char * msg);
/*@only@*/ /*@null@*/
FD_t fdLink (/*@only@*/ void * cookie, const char * msg)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
#define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__) #define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__)
/** /**
*/ */
/*@unused@*/ FD_t fdFree(FD_t fd, const char * msg);
/*@only@*/ /*@null@*/
FD_t fdFree(/*@only@*/ FD_t fd, const char * msg)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
#define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__) #define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__)
/** /**
*/ */
/*@unused@*/ FD_t fdNew (const char * msg);
/*@only@*/ /*@null@*/
FD_t fdNew (const char * msg)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__) #define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__)
/** /**
*/ */
int fdWritable(FD_t fd, int secs) int fdWritable(FD_t fd, int secs);
/*@globals errno, fileSystem @*/
/*@modifies fd, errno, fileSystem @*/;
/** /**
*/ */
int fdReadable(FD_t fd, int secs) int fdReadable(FD_t fd, int secs);
/*@globals errno @*/
/*@modifies fd, errno @*/;
/*@=exportlocal@*/
/** /**
* Insure that directories in path exist, creating as needed. * Insure that directories in path exist, creating as needed.
@ -562,14 +404,11 @@ int fdReadable(FD_t fd, int secs)
* @param gid directory uid (if created), or -1 to skip * @param gid directory uid (if created), or -1 to skip
* @return 0 on success, errno (or -1) on error * @return 0 on success, errno (or -1) on error
*/ */
int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* FTP and HTTP error codes. * FTP and HTTP error codes.
*/ */
/*@-typeuse@*/
typedef enum ftperrCode_e { typedef enum ftperrCode_e {
FTPERR_NE_ERROR = -1, /*!< Generic error. */ FTPERR_NE_ERROR = -1, /*!< Generic error. */
FTPERR_NE_LOOKUP = -2, /*!< Hostname lookup failed. */ FTPERR_NE_LOOKUP = -2, /*!< Hostname lookup failed. */
@ -594,116 +433,94 @@ typedef enum ftperrCode_e {
FTPERR_NIC_ABORT_IN_PROGRESS= -91, /*!< Abort in progress */ FTPERR_NIC_ABORT_IN_PROGRESS= -91, /*!< Abort in progress */
FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */ FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */
} ftperrCode; } ftperrCode;
/*@=typeuse@*/
/** /**
*/ */
/*@-redecl@*/ const char * ftpStrerror(int errorNumber);
/*@observer@*/ const char * ftpStrerror(int errorNumber)
/*@*/;
/*@=redecl@*/
/** /**
*/ */
/*@unused@*/ void * ufdGetUrlinfo(FD_t fd);
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd)
/*@modifies fd @*/;
/** /**
*/ */
/*@-redecl@*/ const char * urlStrerror(const char * url);
/*@unused@*/
/*@observer@*/ const char * urlStrerror(const char * url)
/*@globals h_errno, internalState @*/
/*@modifies internalState @*/;
/*@=redecl@*/
/** /**
*/ */
/*@-exportlocal@*/ int ufdCopy(FD_t sfd, FD_t tfd);
int ufdCopy(FD_t sfd, FD_t tfd)
/*@globals fileSystem @*/
/*@modifies sfd, tfd, fileSystem @*/;
/*@=exportlocal@*/
/** /**
*/ */
int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd) int ufdGetFile( FD_t sfd, FD_t tfd);
/*@globals fileSystem, internalState @*/
/*@modifies sfd, tfd, fileSystem, internalState @*/;
/** /**
*/ */
/*@unused@*/ int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length) int timedRead(FD_t fd, void * bufptr, int length);
/*@globals fileSystem @*/
/*@modifies fd, *bufptr, fileSystem @*/;
#define timedRead (ufdio->read) #define timedRead (ufdio->read)
/*@-exportlocal@*/
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fdio; extern FDIO_t fdio;
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fpio; extern FDIO_t fpio;
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t ufdio; extern FDIO_t ufdio;
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t gzdio; extern FDIO_t gzdio;
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t bzdio; extern FDIO_t bzdio;
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio; extern FDIO_t fadio;
/*@=exportlocal@*/
/*@}*/
/*@unused@*/ static inline int xislower(int c) /*@*/ { static inline int xislower(int c) {
return (c >= 'a' && c <= 'z'); return (c >= 'a' && c <= 'z');
} }
/*@unused@*/ static inline int xisupper(int c) /*@*/ { static inline int xisupper(int c) {
return (c >= 'A' && c <= 'Z'); return (c >= 'A' && c <= 'Z');
} }
/*@unused@*/ static inline int xisalpha(int c) /*@*/ { static inline int xisalpha(int c) {
return (xislower(c) || xisupper(c)); return (xislower(c) || xisupper(c));
} }
/*@unused@*/ static inline int xisdigit(int c) /*@*/ { static inline int xisdigit(int c) {
return (c >= '0' && c <= '9'); return (c >= '0' && c <= '9');
} }
/*@unused@*/ static inline int xisalnum(int c) /*@*/ { static inline int xisalnum(int c) {
return (xisalpha(c) || xisdigit(c)); return (xisalpha(c) || xisdigit(c));
} }
/*@unused@*/ static inline int xisblank(int c) /*@*/ { static inline int xisblank(int c) {
return (c == ' ' || c == '\t'); return (c == ' ' || c == '\t');
} }
/*@unused@*/ static inline int xisspace(int c) /*@*/ { static inline int xisspace(int c) {
return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v'); return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
} }
/*@unused@*/ static inline int xtolower(int c) /*@*/ { static inline int xtolower(int c) {
return ((xisupper(c)) ? (c | ('a' - 'A')) : c); return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
} }
/*@unused@*/ static inline int xtoupper(int c) /*@*/ { static inline int xtoupper(int c) {
return ((xislower(c)) ? (c & ~('a' - 'A')) : c); return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
} }
/** \ingroup rpmio /** \ingroup rpmio
* Locale insensitive strcasecmp(3). * Locale insensitive strcasecmp(3).
*/ */
int xstrcasecmp(const char * s1, const char * s2) /*@*/; int xstrcasecmp(const char * s1, const char * s2) ;
/** \ingroup rpmio /** \ingroup rpmio
* Locale insensitive strncasecmp(3). * Locale insensitive strncasecmp(3).
*/ */
int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/; int xstrncasecmp(const char *s1, const char * s2, size_t n) ;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -38,9 +38,7 @@
* Values parsed from OpenPGP signature/pubkey packet(s). * Values parsed from OpenPGP signature/pubkey packet(s).
*/ */
struct pgpDigParams_s { struct pgpDigParams_s {
/*@only@*/ /*@null@*/
const char * userid; const char * userid;
/*@only@*/ /*@null@*/
const byte * hash; const byte * hash;
const char * params[4]; const char * params[4];
byte tag; byte tag;
@ -69,19 +67,13 @@ struct pgpDig_s {
size_t nbytes; /*!< No. bytes of plain text. */ size_t nbytes; /*!< No. bytes of plain text. */
/*@only@*/ /*@null@*/
DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */ DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */
/*@only@*/ /*@null@*/
DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */ DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */
/*@only@*/ /*@null@*/
void * sha1; /*!< (dsa) V3 signature hash. */ void * sha1; /*!< (dsa) V3 signature hash. */
size_t sha1len; /*!< (dsa) V3 signature hash length. */ size_t sha1len; /*!< (dsa) V3 signature hash length. */
/*@only@*/ /*@null@*/
DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */ DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */
/*@only@*/ /*@null@*/
DIGEST_CTX hdrmd5ctx; /*!< (rsa) header md5 hash context. */ DIGEST_CTX hdrmd5ctx; /*!< (rsa) header md5 hash context. */
/*@only@*/ /*@null@*/
void * md5; /*!< (rsa) V3 signature hash. */ void * md5; /*!< (rsa) V3 signature hash. */
size_t md5len; /*!< (rsa) V3 signature hash length. */ size_t md5len; /*!< (rsa) V3 signature hash length. */
@ -104,9 +96,7 @@ struct pgpDig_s {
/** \ingroup rpmio /** \ingroup rpmio
*/ */
typedef struct _FDSTACK_s { typedef struct _FDSTACK_s {
/*@exposed@*/
FDIO_t io; FDIO_t io;
/*@dependent@*/
void * fp; void * fp;
int fdno; int fdno;
} FDSTACK_t; } FDSTACK_t;
@ -126,7 +116,7 @@ typedef enum fdOpX_e {
/** \ingroup rpmio /** \ingroup rpmio
* Cumulative statistics for a descriptor. * Cumulative statistics for a descriptor.
*/ */
typedef /*@abstract@*/ struct { typedef struct {
struct rpmop_s ops[FDSTAT_MAX]; /*!< Cumulative statistics. */ struct rpmop_s ops[FDSTAT_MAX]; /*!< Cumulative statistics. */
} * FDSTAT_t; } * FDSTAT_t;
@ -141,7 +131,6 @@ typedef struct _FDDIGEST_s {
* The FD_t File Handle data structure. * The FD_t File Handle data structure.
*/ */
struct _FD_s { struct _FD_s {
/*@refs@*/
int nrefs; int nrefs;
int flags; int flags;
#define RPMIO_DEBUG_IO 0x40000000 #define RPMIO_DEBUG_IO 0x40000000
@ -152,9 +141,7 @@ struct _FD_s {
FDSTACK_t fps[8]; FDSTACK_t fps[8];
int urlType; /* ufdio: */ int urlType; /* ufdio: */
/*@dependent@*/
void * url; /* ufdio: URL info */ void * url; /* ufdio: URL info */
/*@relnull@*/
void * req; /* ufdio: HTTP request */ void * req; /* ufdio: HTTP request */
int rd_timeoutsecs; /* ufdRead: per FD_t timer */ int rd_timeoutsecs; /* ufdRead: per FD_t timer */
@ -164,7 +151,6 @@ struct _FD_s {
int wr_chunked; /* ufdio: */ int wr_chunked; /* ufdio: */
int syserrno; /* last system errno encountered */ int syserrno; /* last system errno encountered */
/*@observer@*/
const void *errcookie; /* gzdio/bzdio/ufdio: */ const void *errcookie; /* gzdio/bzdio/ufdio: */
FDSTAT_t stats; /* I/O statistics */ FDSTAT_t stats; /* I/O statistics */
@ -178,34 +164,20 @@ struct _FD_s {
long int fileSize; /* fadio: */ long int fileSize; /* fadio: */
long int fd_cpioPos; /* cpio: */ long int fd_cpioPos; /* cpio: */
}; };
/*@access FD_t@*/
#define FDSANE(fd) assert(fd && fd->magic == FDMAGIC) #define FDSANE(fd) assert(fd && fd->magic == FDMAGIC)
/*@-redecl@*/
/*@unchecked@*/
extern int _rpmio_debug; extern int _rpmio_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _av_debug; extern int _av_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _ftp_debug; extern int _ftp_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _dav_debug; extern int _dav_debug;
/*@=redecl@*/
#define DBG(_f, _m, _x) \ #define DBG(_f, _m, _x) \
/*@-modfilesys@*/ \ \
if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \ if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \
/*@=modfilesys@*/
#define DBGIO(_f, _x) DBG((_f), RPMIO_DEBUG_IO, _x) #define DBGIO(_f, _x) DBG((_f), RPMIO_DEBUG_IO, _x)
#define DBGREFS(_f, _x) DBG((_f), RPMIO_DEBUG_REFS, _x) #define DBGREFS(_f, _x) DBG((_f), RPMIO_DEBUG_REFS, _x)
@ -216,134 +188,94 @@ extern "C" {
/** \ingroup rpmio /** \ingroup rpmio
*/ */
int fdFgets(FD_t fd, char * buf, size_t len) int fdFgets(FD_t fd, char * buf, size_t len);
/*@globals errno, fileSystem @*/
/*@modifies *buf, fd, errno, fileSystem @*/;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@null@*/ FD_t ftpOpen(const char *url, /*@unused@*/ int flags, FD_t ftpOpen(const char *url, int flags,
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret) mode_t mode, urlinfo *uret);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *uret, fileSystem, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg) int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg);
/*@globals fileSystem, internalState @*/
/*@modifies data, fileSystem, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
int ftpCmd(const char * cmd, const char * url, const char * arg2) int ftpCmd(const char * cmd, const char * url, const char * arg2);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
int ufdClose( /*@only@*/ void * cookie) int ufdClose( void * cookie);
/*@globals fileSystem, internalState @*/
/*@modifies cookie, fileSystem, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
/*@null@*/ FDIO_t fdGetIo(FD_t fd) FDIO_t fdGetIo(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundsread@*/
return fd->fps[fd->nfps].io; return fd->fps[fd->nfps].io;
/*@=boundsread@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@-nullstate@*/ /* FIX: io may be NULL */ /* FIX: io may be NULL */
/*@unused@*/ static inline static inline
void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) void fdSetIo(FD_t fd, FDIO_t io)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundswrite@*/
/*@-assignexpose@*/
fd->fps[fd->nfps].io = io; fd->fps[fd->nfps].io = io;
/*@=assignexpose@*/
/*@=boundswrite@*/
} }
/*@=nullstate@*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
/*@exposed@*/ /*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd) FILE * fdGetFILE(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundsread@*/
/*@+voidabstract@*/
return ((FILE *)fd->fps[fd->nfps].fp); return ((FILE *)fd->fps[fd->nfps].fp);
/*@=voidabstract@*/
/*@=boundsread@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
/*@exposed@*/ /*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd) void * fdGetFp(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundsread@*/
return fd->fps[fd->nfps].fp; return fd->fps[fd->nfps].fp;
/*@=boundsread@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@-nullstate@*/ /* FIX: fp may be NULL */ /* FIX: fp may be NULL */
/*@unused@*/ static inline static inline
void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) void fdSetFp(FD_t fd, void * fp)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundswrite@*/
/*@-assignexpose@*/
fd->fps[fd->nfps].fp = fp; fd->fps[fd->nfps].fp = fp;
/*@=assignexpose@*/
/*@=boundswrite@*/
} }
/*@=nullstate@*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
int fdGetFdno(FD_t fd) int fdGetFdno(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundsread@*/
return fd->fps[fd->nfps].fdno; return fd->fps[fd->nfps].fdno;
/*@=boundsread@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdSetFdno(FD_t fd, int fdno) void fdSetFdno(FD_t fd, int fdno)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
/*@-boundswrite@*/
fd->fps[fd->nfps].fdno = fdno; fd->fps[fd->nfps].fdno = fdno;
/*@=boundswrite@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdSetContentLength(FD_t fd, ssize_t contentLength) void fdSetContentLength(FD_t fd, ssize_t contentLength)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
fd->contentLength = fd->bytesRemain = contentLength; fd->contentLength = fd->bytesRemain = contentLength;
@ -351,9 +283,8 @@ void fdSetContentLength(FD_t fd, ssize_t contentLength)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
if (fd->nfps >= (sizeof(fd->fps)/sizeof(fd->fps[0]) - 1)) if (fd->nfps >= (sizeof(fd->fps)/sizeof(fd->fps[0]) - 1))
@ -366,9 +297,8 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdPop(FD_t fd) void fdPop(FD_t fd)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
if (fd->nfps < 0) return; if (fd->nfps < 0) return;
@ -380,25 +310,20 @@ void fdPop(FD_t fd)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline /*@null@*/ static inline
rpmop fdstat_op(/*@null@*/ FD_t fd, fdOpX opx) rpmop fdstat_op(FD_t fd, fdOpX opx)
/*@*/
{ {
rpmop op = NULL; rpmop op = NULL;
/*@-boundsread@*/
if (fd != NULL && fd->stats != NULL && opx >= 0 && opx < FDSTAT_MAX) if (fd != NULL && fd->stats != NULL && opx >= 0 && opx < FDSTAT_MAX)
op = fd->stats->ops + opx; op = fd->stats->ops + opx;
/*@=boundsread@*/
return op; return op;
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdstat_enter(/*@null@*/ FD_t fd, int opx) void fdstat_enter(FD_t fd, int opx)
/*@globals internalState @*/
/*@modifies internalState @*/
{ {
if (fd == NULL) return; if (fd == NULL) return;
if (fd->stats != NULL) if (fd->stats != NULL)
@ -407,10 +332,8 @@ void fdstat_enter(/*@null@*/ FD_t fd, int opx)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc) void fdstat_exit(FD_t fd, int opx, ssize_t rc)
/*@globals internalState @*/
/*@modifies fd, internalState @*/
{ {
if (fd == NULL) return; if (fd == NULL) return;
if (rc == -1) if (rc == -1)
@ -430,11 +353,8 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@-boundsread@*/ static inline
/*@unused@*/ static inline void fdstat_print(FD_t fd, const char * msg, FILE * fp)
void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{ {
static int usec_scale = (1000*1000); static int usec_scale = (1000*1000);
int opx; int opx;
@ -449,40 +369,35 @@ void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp)
fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n", fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n",
op->count, (long)op->bytes, op->count, (long)op->bytes,
(int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
/*@switchbreak@*/ break; break;
case FDSTAT_WRITE: case FDSTAT_WRITE:
if (msg) fprintf(fp, "%s:", msg); if (msg) fprintf(fp, "%s:", msg);
fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n", fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n",
op->count, (long)op->bytes, op->count, (long)op->bytes,
(int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
/*@switchbreak@*/ break; break;
case FDSTAT_SEEK: case FDSTAT_SEEK:
/*@switchbreak@*/ break; break;
case FDSTAT_CLOSE: case FDSTAT_CLOSE:
/*@switchbreak@*/ break; break;
} }
} }
} }
/*@=boundsread@*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) void fdSetSyserrno(FD_t fd, int syserrno, const void * errcookie)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
fd->syserrno = syserrno; fd->syserrno = syserrno;
/*@-assignexpose@*/
fd->errcookie = errcookie; fd->errcookie = errcookie;
/*@=assignexpose@*/
} }
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
int fdGetRdTimeoutSecs(FD_t fd) int fdGetRdTimeoutSecs(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
return fd->rd_timeoutsecs; return fd->rd_timeoutsecs;
@ -490,9 +405,8 @@ int fdGetRdTimeoutSecs(FD_t fd)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
long int fdGetCpioPos(FD_t fd) long int fdGetCpioPos(FD_t fd)
/*@*/
{ {
FDSANE(fd); FDSANE(fd);
return fd->fd_cpioPos; return fd->fd_cpioPos;
@ -500,9 +414,8 @@ long int fdGetCpioPos(FD_t fd)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdSetCpioPos(FD_t fd, long int cpioPos) void fdSetCpioPos(FD_t fd, long int cpioPos)
/*@modifies fd @*/
{ {
FDSANE(fd); FDSANE(fd);
fd->fd_cpioPos = cpioPos; fd->fd_cpioPos = cpioPos;
@ -510,24 +423,19 @@ void fdSetCpioPos(FD_t fd, long int cpioPos)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@mayexit@*/ /*@unused@*/ static inline static inline
FD_t c2f(/*@null@*/ void * cookie) FD_t c2f(void * cookie)
/*@*/
{ {
/*@-castexpose@*/
FD_t fd = (FD_t) cookie; FD_t fd = (FD_t) cookie;
/*@=castexpose@*/
FDSANE(fd); FDSANE(fd);
/*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ return fd;
} }
/** \ingroup rpmio /** \ingroup rpmio
* Attach digest to fd. * Attach digest to fd.
*/ */
/*@unused@*/ static inline static inline
void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags) void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags)
/*@globals internalState @*/
/*@modifies fd, internalState @*/
{ {
FDDIGEST_t fddig = fd->digests + fd->ndigests; FDDIGEST_t fddig = fd->digests + fd->ndigests;
if (fddig != (fd->digests + FDDIGEST_MAX)) { if (fddig != (fd->digests + FDDIGEST_MAX)) {
@ -542,10 +450,8 @@ void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags)
/** \ingroup rpmio /** \ingroup rpmio
* Update digest(s) attached to fd. * Update digest(s) attached to fd.
*/ */
/*@unused@*/ static inline static inline
void fdUpdateDigests(FD_t fd, const unsigned char * buf, ssize_t buflen) void fdUpdateDigests(FD_t fd, const unsigned char * buf, ssize_t buflen)
/*@globals internalState @*/
/*@modifies fd, internalState @*/
{ {
int i; int i;
@ -562,13 +468,11 @@ void fdUpdateDigests(FD_t fd, const unsigned char * buf, ssize_t buflen)
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo, void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
/*@null@*/ /*@out@*/ void ** datap, void ** datap,
/*@null@*/ /*@out@*/ size_t * lenp, size_t * lenp,
int asAscii) int asAscii)
/*@globals internalState @*/
/*@modifies fd, *datap, *lenp, internalState @*/
{ {
int imax = -1; int imax = -1;
int i; int i;
@ -586,33 +490,26 @@ void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
fddig->hashctx = NULL; fddig->hashctx = NULL;
break; break;
} }
/*@-boundswrite@*/
if (i < 0) { if (i < 0) {
if (datap) *datap = NULL; if (datap) *datap = NULL;
if (lenp) *lenp = 0; if (lenp) *lenp = 0;
} }
/*@=boundswrite@*/
fd->ndigests = imax; fd->ndigests = imax;
if (i < imax) if (i < imax)
fd->ndigests++; /* convert index to count */ fd->ndigests++; /* convert index to count */
} }
/*@-shadow@*/
/** \ingroup rpmio /** \ingroup rpmio
*/ */
/*@unused@*/ static inline static inline
int fdFileno(/*@null@*/ void * cookie) int fdFileno(void * cookie)
/*@*/
{ {
FD_t fd; FD_t fd;
if (cookie == NULL) return -2; if (cookie == NULL) return -2;
fd = c2f(cookie); fd = c2f(cookie);
/*@-boundsread@*/
return fd->fps[0].fdno; return fd->fps[0].fdno;
/*@=boundsread@*/
} }
/*@=shadow@*/
/** /**
* Read an entire file into a buffer. * Read an entire file into a buffer.
@ -622,9 +519,7 @@ int fdFileno(/*@null@*/ void * cookie)
* @return 0 on success * @return 0 on success
*/ */
int rpmioSlurp(const char * fn, int rpmioSlurp(const char * fn,
/*@out@*/ byte ** bp, /*@out@*/ ssize_t * blenp) byte ** bp, ssize_t * blenp);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *bp, *blenp, fileSystem, internalState @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,4 +1,3 @@
/*@-boundsread@*/
/** \ingroup rpmio /** \ingroup rpmio
* \file rpmio/rpmlog.c * \file rpmio/rpmlog.c
*/ */
@ -20,20 +19,17 @@
# endif # endif
#endif #endif
/*@access rpmlogRec @*/
/*@unchecked@*/
static int nrecs = 0; static int nrecs = 0;
/*@unchecked@*/ static rpmlogRec recs = NULL;
static /*@only@*/ /*@null@*/ rpmlogRec recs = NULL;
/** /**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free * @param p memory to free
* @retval NULL always * @retval NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) /*@modifies p@*/ _free(const void * p)
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
@ -59,7 +55,6 @@ const char * rpmlogMessage(void)
return _("(no error)"); return _("(no error)");
} }
/*@-modfilesys@*/
void rpmlogPrint(FILE *f) void rpmlogPrint(FILE *f)
{ {
int i; int i;
@ -74,11 +69,8 @@ void rpmlogPrint(FILE *f)
fprintf(f, " %s", rec->message); fprintf(f, " %s", rec->message);
} }
} }
/*@=modfilesys@*/
void rpmlogClose (void) void rpmlogClose (void)
/*@globals recs, nrecs @*/
/*@modifies recs, nrecs @*/
{ {
int i; int i;
@ -91,22 +83,18 @@ void rpmlogClose (void)
nrecs = 0; nrecs = 0;
} }
void rpmlogOpen (/*@unused@*/ const char *ident, /*@unused@*/ int option, void rpmlogOpen (const char *ident, int option,
/*@unused@*/ int facility) int facility)
{ {
} }
/*@unchecked@*/
static unsigned rpmlogMask = RPMLOG_UPTO( RPMLOG_NOTICE ); static unsigned rpmlogMask = RPMLOG_UPTO( RPMLOG_NOTICE );
#ifdef NOTYET #ifdef NOTYET
/*@unchecked@*/ static unsigned rpmlogFacility = RPMLOG_USER;
static /*@unused@*/ unsigned rpmlogFacility = RPMLOG_USER;
#endif #endif
int rpmlogSetMask (int mask) int rpmlogSetMask (int mask)
/*@globals rpmlogMask @*/
/*@modifies rpmlogMask @*/
{ {
int omask = rpmlogMask; int omask = rpmlogMask;
if (mask) if (mask)
@ -114,24 +102,18 @@ int rpmlogSetMask (int mask)
return omask; return omask;
} }
/*@unchecked@*/ static rpmlogCallback _rpmlogCallback = NULL;
static /*@null@*/ rpmlogCallback _rpmlogCallback = NULL;
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb) rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
/*@globals _rpmlogCallback @*/
/*@modifies _rpmlogCallback @*/
{ {
rpmlogCallback ocb = _rpmlogCallback; rpmlogCallback ocb = _rpmlogCallback;
_rpmlogCallback = cb; _rpmlogCallback = cb;
return ocb; return ocb;
} }
/*@unchecked@*/ /*@null@*/
static FILE * _stdlog = NULL; static FILE * _stdlog = NULL;
FILE * rpmlogSetFile(FILE * fp) FILE * rpmlogSetFile(FILE * fp)
/*@globals _stdlog @*/
/*@modifies _stdlog @*/
{ {
FILE * ofp = _stdlog; FILE * ofp = _stdlog;
_stdlog = fp; _stdlog = fp;
@ -139,7 +121,6 @@ FILE * rpmlogSetFile(FILE * fp)
} }
/*@-readonlytrans@*/ /* FIX: double indirection. */ /*@-readonlytrans@*/ /* FIX: double indirection. */
/*@observer@*/ /*@unchecked@*/
static char *rpmlogMsgPrefix[] = { static char *rpmlogMsgPrefix[] = {
N_("fatal error: "),/*!< RPMLOG_EMERG */ N_("fatal error: "),/*!< RPMLOG_EMERG */
N_("fatal error: "),/*!< RPMLOG_ALERT */ N_("fatal error: "),/*!< RPMLOG_ALERT */
@ -150,27 +131,23 @@ static char *rpmlogMsgPrefix[] = {
"", /*!< RPMLOG_INFO */ "", /*!< RPMLOG_INFO */
"D: ", /*!< RPMLOG_DEBUG */ "D: ", /*!< RPMLOG_DEBUG */
}; };
/*@=readonlytrans@*/
#if !defined(HAVE_VSNPRINTF) #if !defined(HAVE_VSNPRINTF)
static inline int vsnprintf(char * buf, /*@unused@*/ int nb, static inline int vsnprintf(char * buf, int nb,
const char * fmt, va_list ap) const char * fmt, va_list ap)
{ {
return vsprintf(buf, fmt, ap); return vsprintf(buf, fmt, ap);
} }
#endif #endif
/*@-modfilesys@*/ /* FIX: rpmlogMsgPrefix[] dependent, not unqualified */
/*@-compmempass@*/ /* FIX: rpmlogMsgPrefix[] dependent, not unqualified */ /* FIX: rpmlogMsgPrefix[] may be NULL */
/*@-nullstate@*/ /* FIX: rpmlogMsgPrefix[] may be NULL */
static void vrpmlog (unsigned code, const char *fmt, va_list ap) static void vrpmlog (unsigned code, const char *fmt, va_list ap)
/*@globals nrecs, recs, internalState @*/
/*@modifies nrecs, recs, internalState @*/
{ {
unsigned pri = RPMLOG_PRI(code); unsigned pri = RPMLOG_PRI(code);
unsigned mask = RPMLOG_MASK(pri); unsigned mask = RPMLOG_MASK(pri);
#ifdef NOTYET #ifdef NOTYET
/*@unused@*/ unsigned fac = RPMLOG_FAC(code); unsigned fac = RPMLOG_FAC(code);
#endif #endif
char *msgbuf, *msg; char *msgbuf, *msg;
int msgnb = BUFSIZ, nb; int msgnb = BUFSIZ, nb;
@ -179,14 +156,13 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
if ((mask & rpmlogMask) == 0) if ((mask & rpmlogMask) == 0)
return; return;
/*@-boundswrite@*/
msgbuf = xmalloc(msgnb); msgbuf = xmalloc(msgnb);
*msgbuf = '\0'; *msgbuf = '\0';
/* Allocate a sufficently large buffer for output. */ /* Allocate a sufficently large buffer for output. */
while (1) { while (1) {
va_list apc; va_list apc;
/*@-sysunrecog -usedef@*/ va_copy(apc, ap); /*@=sysunrecog =usedef@*/ va_copy(apc, ap);
nb = vsnprintf(msgbuf, msgnb, fmt, apc); nb = vsnprintf(msgbuf, msgnb, fmt, apc);
if (nb > -1 && nb < msgnb) if (nb > -1 && nb < msgnb)
break; break;
@ -195,15 +171,12 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
else /* glibc 2.0 */ else /* glibc 2.0 */
msgnb *= 2; msgnb *= 2;
msgbuf = xrealloc(msgbuf, msgnb); msgbuf = xrealloc(msgbuf, msgnb);
/*@-mods@*/
va_end(apc); va_end(apc);
/*@=mods@*/
} }
msgbuf[msgnb - 1] = '\0'; msgbuf[msgnb - 1] = '\0';
msg = msgbuf; msg = msgbuf;
/* Save copy of all messages at warning (or below == "more important"). */ /* Save copy of all messages at warning (or below == "more important"). */
/*@-branchstate@*/
if (pri <= RPMLOG_WARNING) { if (pri <= RPMLOG_WARNING) {
if (recs == NULL) if (recs == NULL)
@ -218,14 +191,11 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
++nrecs; ++nrecs;
if (_rpmlogCallback) { if (_rpmlogCallback) {
/*@-noeffectuncon@*/ /* FIX: useless callback */ /* FIX: useless callback */
_rpmlogCallback(); _rpmlogCallback();
/*@=noeffectuncon@*/
return; /* XXX Preserve legacy rpmError behavior. */ return; /* XXX Preserve legacy rpmError behavior. */
} }
} }
/*@=branchstate@*/
/*@=boundswrite@*/
/* rpmMessage behavior */ /* rpmMessage behavior */
@ -253,17 +223,14 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
if (pri <= RPMLOG_CRIT) if (pri <= RPMLOG_CRIT)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/*@=compmempass =nullstate@*/
/*@=modfilesys@*/
void rpmlog (int code, const char *fmt, ...) void rpmlog (int code, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
/*@-internalglobs@*/ /* FIX: shrug */ /* FIX: shrug */
vrpmlog(code, fmt, ap); vrpmlog(code, fmt, ap);
/*@=internalglobs@*/
va_end(ap); va_end(ap);
} }
@ -281,4 +248,3 @@ rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
{ {
return rpmlogSetCallback(cb); return rpmlogSetCallback(cb);
} }
/*@=boundsread@*/

View File

@ -19,7 +19,6 @@
* *
* priorities (these are ordered) * priorities (these are ordered)
*/ */
/*@-typeuse@*/
typedef enum rpmlogLvl_e { typedef enum rpmlogLvl_e {
RPMLOG_EMERG = 0, /*!< system is unusable */ RPMLOG_EMERG = 0, /*!< system is unusable */
RPMLOG_ALERT = 1, /*!< action must be taken immediately */ RPMLOG_ALERT = 1, /*!< action must be taken immediately */
@ -30,7 +29,6 @@ typedef enum rpmlogLvl_e {
RPMLOG_INFO = 6, /*!< informational */ RPMLOG_INFO = 6, /*!< informational */
RPMLOG_DEBUG = 7 /*!< debug-level messages */ RPMLOG_DEBUG = 7 /*!< debug-level messages */
} rpmlogLvl; } rpmlogLvl;
/*@=typeuse@*/
#define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
/* extract priority */ /* extract priority */
@ -67,7 +65,6 @@ RPMCODE rpmprioritynames[] =
/** /**
* facility codes * facility codes
*/ */
/*@-enummemuse -typeuse@*/
typedef enum rpmlogFac_e { typedef enum rpmlogFac_e {
RPMLOG_KERN = (0<<3), /*!< kernel messages */ RPMLOG_KERN = (0<<3), /*!< kernel messages */
RPMLOG_USER = (1<<3), /*!< random user-level messages */ RPMLOG_USER = (1<<3), /*!< random user-level messages */
@ -95,7 +92,6 @@ typedef enum rpmlogFac_e {
#define RPMLOG_NFACILITIES 24 /*!< current number of facilities */ #define RPMLOG_NFACILITIES 24 /*!< current number of facilities */
RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3) RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
} rpmlogFac; } rpmlogFac;
/*@=enummemuse =typeuse@*/
#define RPMLOG_FACMASK 0x03f8 /*!< mask to extract facility part */ #define RPMLOG_FACMASK 0x03f8 /*!< mask to extract facility part */
#define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3) #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
@ -156,9 +152,8 @@ typedef void (*rpmlogCallback) (void);
/** /**
*/ */
typedef /*@abstract@*/ struct rpmlogRec_s { typedef struct rpmlogRec_s {
int code; int code;
/*@owned@*/ /*@null@*/
const char * message; const char * message;
} * rpmlogRec; } * rpmlogRec;
@ -170,57 +165,43 @@ extern "C" {
* Return number of rpmError() ressages. * Return number of rpmError() ressages.
* @return number of messages * @return number of messages
*/ */
int rpmlogGetNrecs(void) /*@*/; int rpmlogGetNrecs(void) ;
/** /**
* Print all rpmError() messages. * Print all rpmError() messages.
* @param f file handle (NULL uses stderr) * @param f file handle (NULL uses stderr)
*/ */
void rpmlogPrint(/*@null@*/ FILE *f) void rpmlogPrint(FILE *f);
/*@modifies *f @*/;
/** /**
* Close desriptor used to write to system logger. * Close desriptor used to write to system logger.
* @todo Implement. * @todo Implement.
*/ */
/*@unused@*/ void rpmlogClose (void);
void rpmlogClose (void)
/*@globals internalState@*/
/*@modifies internalState @*/;
/** /**
* Open connection to system logger. * Open connection to system logger.
* @todo Implement. * @todo Implement.
*/ */
/*@unused@*/ void rpmlogOpen (const char * ident, int option, int facility);
void rpmlogOpen (const char * ident, int option, int facility)
/*@globals internalState@*/
/*@modifies internalState @*/;
/** /**
* Set the log mask level. * Set the log mask level.
* @param mask log mask (0 is no operation) * @param mask log mask (0 is no operation)
* @return previous log mask * @return previous log mask
*/ */
int rpmlogSetMask (int mask) int rpmlogSetMask (int mask);
/*@globals internalState@*/
/*@modifies internalState @*/;
/** /**
* Generate a log message using FMT string and option arguments. * Generate a log message using FMT string and option arguments.
*/ */
/*@mayexit@*/ /*@printflike@*/ void rpmlog (int code, const char *fmt, ...) void rpmlog (int code, const char *fmt, ...);
/*@*/;
/*@-exportlocal@*/
/** /**
* Return text of last rpmError() message. * Return text of last rpmError() message.
* @return text of last message * @return text of last message
*/ */
/*@-redecl@*/ const char * rpmlogMessage(void);
/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)
/*@*/;
/*@=redecl@*/
/** /**
* Return error code from last rpmError() message. * Return error code from last rpmError() message.
@ -229,53 +210,41 @@ int rpmlogSetMask (int mask)
* and parsed IMHO. * and parsed IMHO.
* @return code from last message * @return code from last message
*/ */
int rpmlogCode(void) int rpmlogCode(void);
/*@*/;
/** /**
* Set rpmlog callback function. * Set rpmlog callback function.
* @param cb rpmlog callback function * @param cb rpmlog callback function
* @return previous rpmlog callback function * @return previous rpmlog callback function
*/ */
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb) rpmlogCallback rpmlogSetCallback(rpmlogCallback cb);
/*@globals internalState@*/
/*@modifies internalState @*/;
/** /**
* Set rpmlog file handle. * Set rpmlog file handle.
* @param fp rpmlog file handle (NULL uses stdout/stderr) * @param fp rpmlog file handle (NULL uses stdout/stderr)
* @return previous rpmlog file handle * @return previous rpmlog file handle
*/ */
/*@null@*/ FILE * rpmlogSetFile(FILE * fp);
FILE * rpmlogSetFile(/*@null@*/ FILE * fp)
/*@globals internalState@*/
/*@modifies internalState @*/;
/*@=exportlocal@*/
/** /**
* Set rpmlog callback function. * Set rpmlog callback function.
* @deprecated gnorpm needs, use rpmlogSetCallback() instead. * @deprecated gnorpm needs, use rpmlogSetCallback() instead.
*/ */
extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb) extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb);
/*@globals internalState@*/
/*@modifies internalState @*/;
/** /**
* Return error code from last rpmError() message. * Return error code from last rpmError() message.
* @deprecated Perl-RPM needs, use rpmlogCode() instead. * @deprecated Perl-RPM needs, use rpmlogCode() instead.
* @return code from last message * @return code from last message
*/ */
extern int rpmErrorCode(void) extern int rpmErrorCode(void);
/*@*/;
/** /**
* Return text of last rpmError() message. * Return text of last rpmError() message.
* @deprecated gnorpm needs, use rpmlogMessage() instead. * @deprecated gnorpm needs, use rpmlogMessage() instead.
* @return text of last message * @return text of last message
*/ */
/*@-redecl@*/ extern const char * rpmErrorString(void) ;
/*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void) /*@*/;
/*@=redecl@*/
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,4 +1,3 @@
/*@-bounds -realcompare -sizeoftype -protoparammatch @*/
#include "system.h" #include "system.h"
#ifdef WITH_LUA #ifdef WITH_LUA
@ -23,7 +22,7 @@
#include "debug.h" #include "debug.h"
#if !defined(HAVE_VSNPRINTF) #if !defined(HAVE_VSNPRINTF)
static inline int vsnprintf(char * buf, /*@unused@*/ int nb, static inline int vsnprintf(char * buf, int nb,
const char * fmt, va_list ap) const char * fmt, va_list ap)
{ {
return vsprintf(buf, fmt, ap); return vsprintf(buf, fmt, ap);
@ -33,27 +32,22 @@ static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
#define INITSTATE(_lua, lua) \ #define INITSTATE(_lua, lua) \
rpmlua lua = _lua ? _lua : \ rpmlua lua = _lua ? _lua : \
(globalLuaState ? globalLuaState : \ (globalLuaState ? globalLuaState : \
/*@-mods@*/ \ \
(globalLuaState = rpmluaNew()) \ (globalLuaState = rpmluaNew()) \
/*@=mods@*/ \ \
) )
/*@only@*/ /*@unchecked@*/ /*@null@*/
static rpmlua globalLuaState = NULL; static rpmlua globalLuaState = NULL;
static int luaopen_rpm(lua_State *L) static int luaopen_rpm(lua_State *L);
/*@modifies L @*/; static int rpm_print(lua_State *L);
static int rpm_print(lua_State *L)
/*@globals fileSystem @*/
/*@modifies L, fileSystem @*/;
rpmlua rpmluaNew() rpmlua rpmluaNew()
{ {
rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua)); rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua));
lua_State *L = lua_open(); lua_State *L = lua_open();
struct stat st; struct stat st;
/*@-readonlytrans@*/
/*@observer@*/ /*@unchecked@*/
static const luaL_reg lualibs[] = { static const luaL_reg lualibs[] = {
{"base", luaopen_base}, {"base", luaopen_base},
{"table", luaopen_table}, {"table", luaopen_table},
@ -66,15 +60,12 @@ rpmlua rpmluaNew()
{"rpm", luaopen_rpm}, {"rpm", luaopen_rpm},
{NULL, NULL}, {NULL, NULL},
}; };
/*@observer@*/ /*@unchecked@*/
const luaL_reg *lib = lualibs; const luaL_reg *lib = lualibs;
/*@=readonlytrans@*/
lua->L = L; lua->L = L;
for (; lib->name; lib++) { for (; lib->name; lib++) {
/*@-noeffectuncon@*/
(void) lib->func(L); (void) lib->func(L);
/*@=noeffectuncon@*/
lua_settop(L, 0); lua_settop(L, 0);
} }
lua_pushliteral(L, "LUA_PATH"); lua_pushliteral(L, "LUA_PATH");
@ -114,17 +105,14 @@ void rpmluaSetData(rpmlua _lua, const char *key, const void *data)
} }
static void *getdata(lua_State *L, const char *key) static void *getdata(lua_State *L, const char *key)
/*@modifies L @*/
{ {
void *ret = NULL; void *ret = NULL;
lua_pushliteral(L, "rpm_"); lua_pushliteral(L, "rpm_");
lua_pushstring(L, key); lua_pushstring(L, key);
lua_concat(L, 2); lua_concat(L, 2);
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
/*@-branchstate@*/
if (lua_islightuserdata(L, -1)) if (lua_islightuserdata(L, -1))
ret = lua_touserdata(L, -1); ret = lua_touserdata(L, -1);
/*@=branchstate@*/
lua_pop(L, 1); lua_pop(L, 1);
return ret; return ret;
} }
@ -151,7 +139,6 @@ const char *rpmluaGetPrintBuffer(rpmlua _lua)
} }
static int pushvar(lua_State *L, rpmluavType type, void *value) static int pushvar(lua_State *L, rpmluavType type, void *value)
/*@modifies L @*/
{ {
int ret = 0; int ret = 0;
switch (type) { switch (type) {
@ -197,14 +184,11 @@ void rpmluaSetVar(rpmlua _lua, rpmluav var)
} }
static void popvar(lua_State *L, rpmluavType *type, void *value) static void popvar(lua_State *L, rpmluavType *type, void *value)
/*@modifies L, *type, *value @*/
{ {
switch (lua_type(L, -1)) { switch (lua_type(L, -1)) {
case LUA_TSTRING: case LUA_TSTRING:
*type = RPMLUAV_STRING; *type = RPMLUAV_STRING;
/*@-observertrans -dependenttrans @*/
*((const char **)value) = lua_tostring(L, -1); *((const char **)value) = lua_tostring(L, -1);
/*@=observertrans =dependenttrans @*/
break; break;
case LUA_TNUMBER: case LUA_TNUMBER:
*type = RPMLUAV_NUMBER; *type = RPMLUAV_NUMBER;
@ -242,7 +226,6 @@ void rpmluaGetVar(rpmlua _lua, rpmluav var)
#define FINDKEY_CREATE 1 #define FINDKEY_CREATE 1
#define FINDKEY_REMOVE 2 #define FINDKEY_REMOVE 2
static int findkey(lua_State *L, int oper, const char *key, va_list va) static int findkey(lua_State *L, int oper, const char *key, va_list va)
/*@modifies L @*/
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
const char *s, *e; const char *s, *e;
@ -260,13 +243,12 @@ static int findkey(lua_State *L, int oper, const char *key, va_list va)
lua_pushnil(L); lua_pushnil(L);
lua_rawset(L, -3); lua_rawset(L, -3);
lua_pop(L, 1); lua_pop(L, 1);
/*@switchbreak@*/ break; break;
} }
/*@fallthrough@*/
case FINDKEY_RETURN: case FINDKEY_RETURN:
lua_rawget(L, -2); lua_rawget(L, -2);
lua_remove(L, -2); lua_remove(L, -2);
/*@switchbreak@*/ break; break;
case FINDKEY_CREATE: case FINDKEY_CREATE:
lua_rawget(L, -2); lua_rawget(L, -2);
if (!lua_istable(L, -1)) { if (!lua_istable(L, -1)) {
@ -277,7 +259,7 @@ static int findkey(lua_State *L, int oper, const char *key, va_list va)
lua_rawset(L, -4); lua_rawset(L, -4);
} }
lua_remove(L, -2); lua_remove(L, -2);
/*@switchbreak@*/ break; break;
} }
} }
if (*e == '\0') if (*e == '\0')
@ -359,7 +341,6 @@ void rpmluavSetListMode(rpmluav var, int flag)
void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value) void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
{ {
var->keyType = type; var->keyType = type;
/*@-assignexpose -branchstate -temptrans @*/
switch (type) { switch (type) {
case RPMLUAV_NUMBER: case RPMLUAV_NUMBER:
var->key.num = *((double *)value); var->key.num = *((double *)value);
@ -370,13 +351,11 @@ void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
default: default:
break; break;
} }
/*@=assignexpose =branchstate =temptrans @*/
} }
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value) void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
{ {
var->valueType = type; var->valueType = type;
/*@-assignexpose -branchstate -temptrans @*/
switch (type) { switch (type) {
case RPMLUAV_NUMBER: case RPMLUAV_NUMBER:
var->value.num = *((const double *)value); var->value.num = *((const double *)value);
@ -387,13 +366,11 @@ void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
default: default:
break; break;
} }
/*@=assignexpose =branchstate =temptrans @*/
} }
void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value) void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value)
{ {
*type = var->keyType; *type = var->keyType;
/*@-onlytrans@*/
switch (var->keyType) { switch (var->keyType) {
case RPMLUAV_NUMBER: case RPMLUAV_NUMBER:
*((double **)value) = &var->key.num; *((double **)value) = &var->key.num;
@ -404,13 +381,11 @@ void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value)
default: default:
break; break;
} }
/*@=onlytrans@*/
} }
void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value) void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value)
{ {
*type = var->valueType; *type = var->valueType;
/*@-onlytrans@*/
switch (var->valueType) { switch (var->valueType) {
case RPMLUAV_NUMBER: case RPMLUAV_NUMBER:
*((double **)value) = &var->value.num; *((double **)value) = &var->value.num;
@ -421,7 +396,6 @@ void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value)
default: default:
break; break;
} }
/*@=onlytrans@*/
} }
void rpmluavSetKeyNum(rpmluav var, double value) void rpmluavSetKeyNum(rpmluav var, double value)
@ -469,10 +443,8 @@ int rpmluaCheckScript(rpmlua _lua, const char *script, const char *name)
INITSTATE(_lua, lua); INITSTATE(_lua, lua);
lua_State *L = lua->L; lua_State *L = lua->L;
int ret = 0; int ret = 0;
/*@-branchstate@*/
if (name == NULL) if (name == NULL)
name = "<lua>"; name = "<lua>";
/*@=branchstate@*/
if (luaL_loadbuffer(L, script, strlen(script), name) != 0) { if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
rpmError(RPMERR_SCRIPT, rpmError(RPMERR_SCRIPT,
_("invalid syntax in lua scriptlet: %s\n"), _("invalid syntax in lua scriptlet: %s\n"),
@ -488,10 +460,8 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
INITSTATE(_lua, lua); INITSTATE(_lua, lua);
lua_State *L = lua->L; lua_State *L = lua->L;
int ret = 0; int ret = 0;
/*@-branchstate@*/
if (name == NULL) if (name == NULL)
name = "<lua>"; name = "<lua>";
/*@=branchstate@*/
if (luaL_loadbuffer(L, script, strlen(script), name) != 0) { if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
rpmError(RPMERR_SCRIPT, _("invalid syntax in lua script: %s\n"), rpmError(RPMERR_SCRIPT, _("invalid syntax in lua script: %s\n"),
lua_tostring(L, -1)); lua_tostring(L, -1));
@ -527,8 +497,6 @@ int rpmluaRunScriptFile(rpmlua _lua, const char *filename)
/* From lua.c */ /* From lua.c */
static int rpmluaReadline(lua_State *L, const char *prompt) static int rpmluaReadline(lua_State *L, const char *prompt)
/*@globals fileSystem @*/
/*@modifies L, fileSystem @*/
{ {
static char buffer[1024]; static char buffer[1024];
if (prompt) { if (prompt) {
@ -545,8 +513,6 @@ static int rpmluaReadline(lua_State *L, const char *prompt)
/* Based on lua.c */ /* Based on lua.c */
static void _rpmluaInteractive(lua_State *L) static void _rpmluaInteractive(lua_State *L)
/*@globals fileSystem @*/
/*@modifies L, fileSystem @*/
{ {
(void) fputs("\n", stdout); (void) fputs("\n", stdout);
printf("RPM Interactive %s Interpreter\n", LUA_VERSION); printf("RPM Interactive %s Interpreter\n", LUA_VERSION);
@ -556,25 +522,21 @@ static void _rpmluaInteractive(lua_State *L)
if (rpmluaReadline(L, "> ") == 0) if (rpmluaReadline(L, "> ") == 0)
break; break;
if (lua_tostring(L, -1)[0] == '=') { if (lua_tostring(L, -1)[0] == '=') {
/*@-evalorder@*/
(void) lua_pushfstring(L, "print(%s)", lua_tostring(L, -1)+1); (void) lua_pushfstring(L, "print(%s)", lua_tostring(L, -1)+1);
/*@=evalorder@*/
lua_remove(L, -2); lua_remove(L, -2);
} }
for (;;) { for (;;) {
/*@-evalorder@*/
rc = luaL_loadbuffer(L, lua_tostring(L, -1), rc = luaL_loadbuffer(L, lua_tostring(L, -1),
lua_strlen(L, -1), "<lua>"); lua_strlen(L, -1), "<lua>");
/*@=evalorder@*/
if (rc == LUA_ERRSYNTAX && if (rc == LUA_ERRSYNTAX &&
strstr(lua_tostring(L, -1), "near `<eof>'") != NULL) { strstr(lua_tostring(L, -1), "near `<eof>'") != NULL) {
if (rpmluaReadline(L, ">> ") == 0) if (rpmluaReadline(L, ">> ") == 0)
/*@innerbreak@*/ break; break;
lua_remove(L, -2); /* Remove error */ lua_remove(L, -2); /* Remove error */
lua_concat(L, 2); lua_concat(L, 2);
/*@innercontinue@*/ continue; continue;
} }
/*@innerbreak@*/ break; break;
} }
if (rc == 0) if (rc == 0)
rc = lua_pcall(L, 0, 0, 0); rc = lua_pcall(L, 0, 0, 0);
@ -587,20 +549,16 @@ static void _rpmluaInteractive(lua_State *L)
(void) fputs("\n", stdout); (void) fputs("\n", stdout);
} }
/*@-mods@*/
void rpmluaInteractive(rpmlua _lua) void rpmluaInteractive(rpmlua _lua)
{ {
INITSTATE(_lua, lua); INITSTATE(_lua, lua);
_rpmluaInteractive(lua->L); _rpmluaInteractive(lua->L);
} }
/*@=mods@*/
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Lua API */ /* Lua API */
static int rpm_expand(lua_State *L) static int rpm_expand(lua_State *L)
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies L, rpmGlobalMacroContext @*/
{ {
const char *str = luaL_checkstring(L, 1); const char *str = luaL_checkstring(L, 1);
lua_pushstring(L, rpmExpand(str, NULL)); lua_pushstring(L, rpmExpand(str, NULL));
@ -608,8 +566,6 @@ static int rpm_expand(lua_State *L)
} }
static int rpm_define(lua_State *L) static int rpm_define(lua_State *L)
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies L, rpmGlobalMacroContext @*/
{ {
const char *str = luaL_checkstring(L, 1); const char *str = luaL_checkstring(L, 1);
(void) rpmDefineMacro(NULL, str, 0); (void) rpmDefineMacro(NULL, str, 0);
@ -617,22 +573,18 @@ static int rpm_define(lua_State *L)
} }
static int rpm_interactive(lua_State *L) static int rpm_interactive(lua_State *L)
/*@globals fileSystem @*/
/*@modifies L, fileSystem @*/
{ {
_rpmluaInteractive(L); _rpmluaInteractive(L);
return 0; return 0;
} }
typedef struct rpmluaHookData_s { typedef struct rpmluaHookData_s {
/*@shared@*/
lua_State *L; lua_State *L;
int funcRef; int funcRef;
int dataRef; int dataRef;
} * rpmluaHookData; } * rpmluaHookData;
static int rpmluaHookWrapper(rpmhookArgs args, void *data) static int rpmluaHookWrapper(rpmhookArgs args, void *data)
/*@*/
{ {
rpmluaHookData hookdata = (rpmluaHookData)data; rpmluaHookData hookdata = (rpmluaHookData)data;
lua_State *L = hookdata->L; lua_State *L = hookdata->L;
@ -645,23 +597,23 @@ static int rpmluaHookWrapper(rpmhookArgs args, void *data)
case 's': case 's':
lua_pushstring(L, args->argv[i].s); lua_pushstring(L, args->argv[i].s);
lua_rawseti(L, -2, i+1); lua_rawseti(L, -2, i+1);
/*@switchbreak@*/ break; break;
case 'i': case 'i':
lua_pushnumber(L, (lua_Number)args->argv[i].i); lua_pushnumber(L, (lua_Number)args->argv[i].i);
lua_rawseti(L, -2, i+1); lua_rawseti(L, -2, i+1);
/*@switchbreak@*/ break; break;
case 'f': case 'f':
lua_pushnumber(L, (lua_Number)args->argv[i].f); lua_pushnumber(L, (lua_Number)args->argv[i].f);
lua_rawseti(L, -2, i+1); lua_rawseti(L, -2, i+1);
/*@switchbreak@*/ break; break;
case 'p': case 'p':
lua_pushlightuserdata(L, args->argv[i].p); lua_pushlightuserdata(L, args->argv[i].p);
lua_rawseti(L, -2, i+1); lua_rawseti(L, -2, i+1);
/*@switchbreak@*/ break; break;
default: default:
(void) luaL_error(L, "unsupported type '%c' as " (void) luaL_error(L, "unsupported type '%c' as "
"a hook argument\n", args->argt[i]); "a hook argument\n", args->argt[i]);
/*@switchbreak@*/ break; break;
} }
} }
if (lua_pcall(L, 1, 1, 0) != 0) { if (lua_pcall(L, 1, 1, 0) != 0) {
@ -677,8 +629,6 @@ static int rpmluaHookWrapper(rpmhookArgs args, void *data)
} }
static int rpm_register(lua_State *L) static int rpm_register(lua_State *L)
/*@globals internalState @*/
/*@modifies L, internalState @*/
{ {
if (!lua_isstring(L, 1)) { if (!lua_isstring(L, 1)) {
(void) luaL_argerror(L, 1, "hook name expected"); (void) luaL_argerror(L, 1, "hook name expected");
@ -691,9 +641,7 @@ static int rpm_register(lua_State *L)
hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX); hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
hookdata->funcRef = luaL_ref(L, LUA_REGISTRYINDEX); hookdata->funcRef = luaL_ref(L, LUA_REGISTRYINDEX);
/*@-temptrans@*/
hookdata->L = L; hookdata->L = L;
/*@=temptrans@*/
rpmhookRegister(lua_tostring(L, 1), rpmluaHookWrapper, hookdata); rpmhookRegister(lua_tostring(L, 1), rpmluaHookWrapper, hookdata);
return 1; return 1;
} }
@ -701,7 +649,6 @@ static int rpm_register(lua_State *L)
} }
static int rpm_unregister(lua_State *L) static int rpm_unregister(lua_State *L)
/*@modifies L @*/
{ {
if (!lua_isstring(L, 1)) { if (!lua_isstring(L, 1)) {
(void) luaL_argerror(L, 1, "hook name expected"); (void) luaL_argerror(L, 1, "hook name expected");
@ -717,8 +664,6 @@ static int rpm_unregister(lua_State *L)
} }
static int rpm_call(lua_State *L) static int rpm_call(lua_State *L)
/*@globals internalState @*/
/*@modifies L, internalState @*/
{ {
if (!lua_isstring(L, 1)) { if (!lua_isstring(L, 1)) {
(void) luaL_argerror(L, 1, "hook name expected"); (void) luaL_argerror(L, 1, "hook name expected");
@ -732,10 +677,9 @@ static int rpm_call(lua_State *L)
case LUA_TNIL: case LUA_TNIL:
argt[i] = 'p'; argt[i] = 'p';
args->argv[i].p = NULL; args->argv[i].p = NULL;
/*@switchbreak@*/ break; break;
case LUA_TNUMBER: { case LUA_TNUMBER: {
float f = (float)lua_tonumber(L, i+1); float f = (float)lua_tonumber(L, i+1);
/*@+relaxtypes@*/
if (f == (int)f) { if (f == (int)f) {
argt[i] = 'i'; argt[i] = 'i';
args->argv[i].i = (int)f; args->argv[i].i = (int)f;
@ -743,38 +687,33 @@ static int rpm_call(lua_State *L)
argt[i] = 'f'; argt[i] = 'f';
args->argv[i].f = f; args->argv[i].f = f;
} }
/*@=relaxtypes@*/ } break;
} /*@switchbreak@*/ break;
case LUA_TSTRING: case LUA_TSTRING:
argt[i] = 's'; argt[i] = 's';
args->argv[i].s = lua_tostring(L, i+1); args->argv[i].s = lua_tostring(L, i+1);
/*@switchbreak@*/ break; break;
case LUA_TUSERDATA: case LUA_TUSERDATA:
case LUA_TLIGHTUSERDATA: case LUA_TLIGHTUSERDATA:
argt[i] = 'p'; argt[i] = 'p';
args->argv[i].p = lua_touserdata(L, i+1); args->argv[i].p = lua_touserdata(L, i+1);
/*@switchbreak@*/ break; break;
default: default:
(void) luaL_error(L, "unsupported Lua type passed to hook"); (void) luaL_error(L, "unsupported Lua type passed to hook");
argt[i] = 'p'; argt[i] = 'p';
args->argv[i].p = NULL; args->argv[i].p = NULL;
/*@switchbreak@*/ break; break;
} }
} }
/*@-compdef -kepttrans -usereleased @*/
args->argt = argt; args->argt = argt;
rpmhookCallArgs(name, args); rpmhookCallArgs(name, args);
free(argt); free(argt);
(void) rpmhookArgsFree(args); (void) rpmhookArgsFree(args);
/*@=compdef =kepttrans =usereleased @*/
} }
return 0; return 0;
} }
/* Based on luaB_print. */ /* Based on luaB_print. */
static int rpm_print (lua_State *L) static int rpm_print (lua_State *L)
/*@globals fileSystem @*/
/*@modifies L, fileSystem @*/
{ {
rpmlua lua = (rpmlua)getdata(L, "lua"); rpmlua lua = (rpmlua)getdata(L, "lua");
int n = lua_gettop(L); /* number of arguments */ int n = lua_gettop(L); /* number of arguments */
@ -820,8 +759,6 @@ static int rpm_print (lua_State *L)
return 0; return 0;
} }
/*@-readonlytrans@*/
/*@observer@*/ /*@unchecked@*/
static const luaL_reg rpmlib[] = { static const luaL_reg rpmlib[] = {
{"expand", rpm_expand}, {"expand", rpm_expand},
{"define", rpm_define}, {"define", rpm_define},
@ -831,10 +768,8 @@ static const luaL_reg rpmlib[] = {
{"interactive", rpm_interactive}, {"interactive", rpm_interactive},
{NULL, NULL} {NULL, NULL}
}; };
/*@=readonlytrans@*/
static int luaopen_rpm(lua_State *L) static int luaopen_rpm(lua_State *L)
/*@modifies L @*/
{ {
lua_pushvalue(L, LUA_GLOBALSINDEX); lua_pushvalue(L, LUA_GLOBALSINDEX);
luaL_openlib(L, "rpm", rpmlib, 0); luaL_openlib(L, "rpm", rpmlib, 0);
@ -842,4 +777,3 @@ static int luaopen_rpm(lua_State *L)
} }
#endif /* WITH_LUA */ #endif /* WITH_LUA */
/*@=bounds =realcompare =sizeoftype =protoparammatch @*/

View File

@ -39,107 +39,46 @@ struct rpmluav_s {
#endif /* _RPMLUA_INTERNAL */ #endif /* _RPMLUA_INTERNAL */
typedef /*@abstract@*/ struct rpmlua_s * rpmlua; typedef struct rpmlua_s * rpmlua;
typedef /*@abstract@*/ struct rpmluav_s * rpmluav; typedef struct rpmluav_s * rpmluav;
/*@-exportlocal@*/ rpmlua rpmluaNew(void);
/*@only@*/ void *rpmluaFree(rpmlua lua);
rpmlua rpmluaNew(void)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@=exportlocal@*/
void *rpmluaFree(/*@only@*/ rpmlua lua)
/*@modifies lua @*/;
int rpmluaCheckScript(/*@null@*/ rpmlua lua, const char *script, int rpmluaCheckScript(rpmlua lua, const char *script,
/*@null@*/ const char *name) const char *name);
/*@globals fileSystem @*/ int rpmluaRunScript(rpmlua lua, const char *script,
/*@modifies lua, fileSystem @*/; const char *name);
int rpmluaRunScript(/*@null@*/ rpmlua lua, const char *script, int rpmluaRunScriptFile(rpmlua lua, const char *filename);
/*@null@*/ const char *name) void rpmluaInteractive(rpmlua lua);
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
/*@-exportlocal@*/
int rpmluaRunScriptFile(/*@null@*/ rpmlua lua, const char *filename)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
/*@=exportlocal@*/
void rpmluaInteractive(/*@null@*/ rpmlua lua)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
void *rpmluaGetData(/*@null@*/ rpmlua lua, const char *key) void *rpmluaGetData(rpmlua lua, const char *key);
/*@globals fileSystem @*/ void rpmluaSetData(rpmlua lua, const char *key, const void *data);
/*@modifies lua, fileSystem @*/;
/*@-exportlocal@*/
void rpmluaSetData(/*@null@*/ rpmlua lua, const char *key, const void *data)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
/*@=exportlocal@*/
/*@exposed@*/ const char *rpmluaGetPrintBuffer(rpmlua lua);
const char *rpmluaGetPrintBuffer(/*@null@*/ rpmlua lua) void rpmluaSetPrintBuffer(rpmlua lua, int flag);
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
void rpmluaSetPrintBuffer(/*@null@*/ rpmlua lua, int flag)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
void rpmluaGetVar(/*@null@*/ rpmlua lua, rpmluav var) void rpmluaGetVar(rpmlua lua, rpmluav var);
/*@globals fileSystem @*/ void rpmluaSetVar(rpmlua lua, rpmluav var);
/*@modifies lua, var, fileSystem @*/; void rpmluaDelVar(rpmlua lua, const char *key, ...);
void rpmluaSetVar(/*@null@*/ rpmlua lua, rpmluav var) int rpmluaVarExists(rpmlua lua, const char *key, ...);
/*@globals fileSystem @*/ void rpmluaPushTable(rpmlua lua, const char *key, ...);
/*@modifies lua, var, fileSystem @*/; void rpmluaPop(rpmlua lua);
void rpmluaDelVar(/*@null@*/ rpmlua lua, const char *key, ...)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
int rpmluaVarExists(/*@null@*/ rpmlua lua, const char *key, ...)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
void rpmluaPushTable(/*@null@*/ rpmlua lua, const char *key, ...)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
void rpmluaPop(/*@null@*/ rpmlua lua)
/*@globals fileSystem @*/
/*@modifies lua, fileSystem @*/;
/*@only@*/ rpmluav rpmluavNew(void);
rpmluav rpmluavNew(void) void * rpmluavFree(rpmluav var);
/*@*/; void rpmluavSetListMode(rpmluav var, int flag);
void * rpmluavFree(/*@only@*/ rpmluav var) void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value);
/*@modifes var @*/; void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value);
void rpmluavSetListMode(rpmluav var, int flag) void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value);
/*@modifies var @*/; void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value);
/*@-exportlocal@*/
void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
/*@modifies var @*/;
/*@=exportlocal@*/
/*@-exportlocal@*/
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
/*@modifies var @*/;
/*@=exportlocal@*/
/*@-exportlocal@*/
void rpmluavGetKey(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
/*@modifies *type, *value @*/;
/*@=exportlocal@*/
/*@-exportlocal@*/
void rpmluavGetValue(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
/*@modifies *type, *value @*/;
/*@=exportlocal@*/
/* Optional helpers for numbers. */ /* Optional helpers for numbers. */
void rpmluavSetKeyNum(rpmluav var, double value) void rpmluavSetKeyNum(rpmluav var, double value);
/*@modifies var @*/; void rpmluavSetValueNum(rpmluav var, double value);
void rpmluavSetValueNum(rpmluav var, double value) double rpmluavGetKeyNum(rpmluav var);
/*@modifies var @*/; double rpmluavGetValueNum(rpmluav var);
double rpmluavGetKeyNum(rpmluav var) int rpmluavKeyIsNum(rpmluav var);
/*@*/; int rpmluavValueIsNum(rpmluav var);
double rpmluavGetValueNum(rpmluav var)
/*@*/;
int rpmluavKeyIsNum(rpmluav var)
/*@*/;
int rpmluavValueIsNum(rpmluav var)
/*@*/;
#endif /* RPMLUA_H */ #endif /* RPMLUA_H */

View File

@ -6,7 +6,7 @@
*/ */
/*! The structure used to store a macro. */ /*! The structure used to store a macro. */
typedef /*@abstract@*/ struct MacroEntry_s { typedef struct MacroEntry_s {
struct MacroEntry_s *prev;/*!< Macro entry stack. */ struct MacroEntry_s *prev;/*!< Macro entry stack. */
const char *name; /*!< Macro name. */ const char *name; /*!< Macro name. */
const char *opts; /*!< Macro parameters (a la getopt) */ const char *opts; /*!< Macro parameters (a la getopt) */
@ -16,29 +16,22 @@ typedef /*@abstract@*/ struct MacroEntry_s {
} * MacroEntry; } * MacroEntry;
/*! The structure used to store the set of macros in a context. */ /*! The structure used to store the set of macros in a context. */
typedef /*@abstract@*/ struct MacroContext_s { typedef struct MacroContext_s {
/*@owned@*//*@null@*/ MacroEntry *macroTable; /*!< Macro entry table for context. */ /*@owned@*/MacroEntry *macroTable; /*!< Macro entry table for context. */
int macrosAllocated;/*!< No. of allocated macros. */ int macrosAllocated;/*!< No. of allocated macros. */
int firstFree; /*!< No. of macros. */ int firstFree; /*!< No. of macros. */
} * MacroContext; } * MacroContext;
/*@-redecl@*/
/*@checked@*/
extern MacroContext rpmGlobalMacroContext; extern MacroContext rpmGlobalMacroContext;
/*@checked@*/
extern MacroContext rpmCLIMacroContext; extern MacroContext rpmCLIMacroContext;
/*@=redecl@*/
/** \ingroup rpmrc /** \ingroup rpmrc
* List of macro files to read when configuring rpm. * List of macro files to read when configuring rpm.
* This is a colon separated list of files. URI's are permitted as well, * This is a colon separated list of files. URI's are permitted as well,
* identified by the token '://', so file paths must not begin with '//'. * identified by the token '://', so file paths must not begin with '//'.
*/ */
/*@-redecl@*/
/*@observer@*/ /*@checked@*/
extern const char * macrofiles; extern const char * macrofiles;
/*@=redecl@*/
/** /**
* Markers for sources of macros added throughout rpm. * Markers for sources of macros added throughout rpm.
@ -62,10 +55,8 @@ extern "C" {
* @param mc macro context (NULL uses global context). * @param mc macro context (NULL uses global context).
* @param fp file stream (NULL uses stderr). * @param fp file stream (NULL uses stderr).
*/ */
void rpmDumpMacroTable (/*@null@*/ MacroContext mc, void rpmDumpMacroTable (MacroContext mc,
/*@null@*/ FILE * fp) FILE * fp);
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** /**
* Return URL path(s) from a (URL prefixed) pattern glob. * Return URL path(s) from a (URL prefixed) pattern glob.
@ -74,10 +65,8 @@ void rpmDumpMacroTable (/*@null@*/ MacroContext mc,
* @retval *argvPtr array of paths (malloc'd contiguous blob) * @retval *argvPtr array of paths (malloc'd contiguous blob)
* @return 0 on success * @return 0 on success
*/ */
int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr, int rpmGlob(const char * patterns, int * argcPtr,
/*@out@*/ const char *** argvPtr) const char *** argvPtr);
/*@globals fileSystem, internalState @*/
/*@modifies *argcPtr, *argvPtr, fileSystem, internalState @*/;
/** /**
* Expand macro into buffer. * Expand macro into buffer.
@ -89,11 +78,9 @@ int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
* @param slen size of buffer * @param slen size of buffer
* @return 0 on success * @return 0 on success
*/ */
int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc, int expandMacros (void * spec, MacroContext mc,
/*@in@*/ /*@out@*/ char * sbuf, char * sbuf,
size_t slen) size_t slen);
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
/*@modifies *sbuf, rpmGlobalMacroContext, fileSystem @*/;
/** /**
* Add macro to context. * Add macro to context.
@ -104,20 +91,16 @@ int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
* @param b macro body * @param b macro body
* @param level macro recursion level (0 is entry API) * @param level macro recursion level (0 is entry API)
*/ */
void addMacro (/*@null@*/ MacroContext mc, const char * n, void addMacro (MacroContext mc, const char * n,
/*@null@*/ const char * o, const char * o,
/*@null@*/ const char * b, int level) const char * b, int level);
/*@globals rpmGlobalMacroContext @*/
/*@modifies mc, rpmGlobalMacroContext @*/;
/** /**
* Delete macro from context. * Delete macro from context.
* @param mc macro context (NULL uses global context). * @param mc macro context (NULL uses global context).
* @param n macro name * @param n macro name
*/ */
void delMacro (/*@null@*/ MacroContext mc, const char * n) void delMacro (MacroContext mc, const char * n);
/*@globals rpmGlobalMacroContext @*/
/*@modifies mc, rpmGlobalMacroContext @*/;
/** /**
* Define macro in context. * Define macro in context.
@ -126,47 +109,41 @@ void delMacro (/*@null@*/ MacroContext mc, const char * n)
* @param level macro recursion level (0 is entry API) * @param level macro recursion level (0 is entry API)
* @return @todo Document. * @return @todo Document.
*/ */
int rpmDefineMacro (/*@null@*/ MacroContext mc, const char * macro, int rpmDefineMacro (MacroContext mc, const char * macro,
int level) int level);
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies mc, rpmGlobalMacroContext @*/;
/** /**
* Load macros from specific context into global context. * Load macros from specific context into global context.
* @param mc macro context (NULL does nothing). * @param mc macro context (NULL does nothing).
* @param level macro recursion level (0 is entry API) * @param level macro recursion level (0 is entry API)
*/ */
void rpmLoadMacros (/*@null@*/ MacroContext mc, int level) void rpmLoadMacros (MacroContext mc, int level);
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
/** /**
* Load macro context from a macro file. * Load macro context from a macro file.
* @param mc (unused) * @param mc (unused)
* @param fn macro file name * @param fn macro file name
*/ */
int rpmLoadMacroFile(/*@null@*/ MacroContext mc, const char * fn) int rpmLoadMacroFile(MacroContext mc, const char * fn)
/*@globals rpmGlobalMacroContext, /*@globals rpmGlobalMacroContext,
h_errno, fileSystem, internalState @*/ h_errno, fileSystem, internalState @*/
/*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/; ;
/** /**
* Initialize macro context from set of macrofile(s). * Initialize macro context from set of macrofile(s).
* @param mc macro context * @param mc macro context
* @param macrofiles colon separated list of macro files (NULL does nothing) * @param macrofiles colon separated list of macro files (NULL does nothing)
*/ */
void rpmInitMacros (/*@null@*/ MacroContext mc, const char * macrofiles) void rpmInitMacros (MacroContext mc, const char * macrofiles)
/*@globals rpmGlobalMacroContext, rpmCLIMacroContext, /*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
h_errno, fileSystem, internalState @*/ h_errno, fileSystem, internalState @*/
/*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/; ;
/** /**
* Destroy macro context. * Destroy macro context.
* @param mc macro context (NULL uses global context). * @param mc macro context (NULL uses global context).
*/ */
void rpmFreeMacros (/*@null@*/ MacroContext mc) void rpmFreeMacros (MacroContext mc);
/*@globals rpmGlobalMacroContext @*/
/*@modifies mc, rpmGlobalMacroContext @*/;
typedef enum rpmCompressedMagic_e { typedef enum rpmCompressedMagic_e {
COMPRESSED_NOT = 0, /*!< not compressed */ COMPRESSED_NOT = 0, /*!< not compressed */
@ -182,38 +159,29 @@ typedef enum rpmCompressedMagic_e {
* @return 0 on success, 1 on I/O error * @return 0 on success, 1 on I/O error
*/ */
int isCompressed (const char * file, int isCompressed (const char * file,
/*@out@*/ rpmCompressedMagic * compressed) rpmCompressedMagic * compressed);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *compressed, fileSystem, internalState @*/;
/** /**
* Return (malloc'ed) concatenated macro expansion(s). * Return (malloc'ed) concatenated macro expansion(s).
* @param arg macro(s) to expand (NULL terminates list) * @param arg macro(s) to expand (NULL terminates list)
* @return macro expansion (malloc'ed) * @return macro expansion (malloc'ed)
*/ */
char * rpmExpand (/*@null@*/ const char * arg, ...) char * rpmExpand (const char * arg, ...);
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies rpmGlobalMacroContext @*/;
/** /**
* Canonicalize file path. * Canonicalize file path.
* @param path path to canonicalize (in-place) * @param path path to canonicalize (in-place)
* @return canonicalized path (malloc'ed) * @return canonicalized path (malloc'ed)
*/ */
/*@null@*/ char * rpmCleanPath (char * path);
char * rpmCleanPath (/*@returned@*/ /*@null@*/ char * path)
/*@modifies *path @*/;
/** /**
* Return (malloc'ed) expanded, canonicalized, file path. * Return (malloc'ed) expanded, canonicalized, file path.
* @param path macro(s) to expand (NULL terminates list) * @param path macro(s) to expand (NULL terminates list)
* @return canonicalized path (malloc'ed) * @return canonicalized path (malloc'ed)
*/ */
/*@-redecl@*/ /* LCL: shrug */ /* LCL: shrug */
const char * rpmGetPath (/*@null@*/ const char * path, ...) const char * rpmGetPath (const char * path, ...);
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies rpmGlobalMacroContext @*/;
/*@=redecl@*/
/** /**
* Merge 3 args into path, any or all of which may be a url. * Merge 3 args into path, any or all of which may be a url.
@ -225,13 +193,10 @@ const char * rpmGetPath (/*@null@*/ const char * path, ...)
* @param urlfile file URL (often a file, or NULL) * @param urlfile file URL (often a file, or NULL)
* @return expanded, merged, canonicalized path (malloc'ed) * @return expanded, merged, canonicalized path (malloc'ed)
*/ */
/*@-redecl@*/ /* LCL: shrug */ /* LCL: shrug */
const char * rpmGenPath (/*@null@*/ const char * urlroot, const char * rpmGenPath (const char * urlroot,
/*@null@*/ const char * urlmdir, const char * urlmdir,
/*@null@*/ const char * urlfile) const char * urlfile);
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies rpmGlobalMacroContext @*/;
/*@=redecl@*/
/** /**
* Return macro expansion as a numeric value. * Return macro expansion as a numeric value.
@ -240,9 +205,7 @@ const char * rpmGenPath (/*@null@*/ const char * urlroot,
* @param arg macro to expand * @param arg macro to expand
* @return numeric value * @return numeric value
*/ */
int rpmExpandNumeric (const char * arg) int rpmExpandNumeric (const char * arg);
/*@globals rpmGlobalMacroContext, h_errno @*/
/*@modifies rpmGlobalMacroContext @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -9,19 +9,16 @@
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif #endif
/*@-modfilesys@*/ void *vmefail(size_t size)
/*@only@*/ void *vmefail(size_t size)
{ {
fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), (unsigned)size); fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), (unsigned)size);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/*@notreached@*/
return NULL; return NULL;
} }
/*@=modfilesys@*/
#if !(HAVE_MCHECK_H && defined(__GNUC__)) #if !(HAVE_MCHECK_H && defined(__GNUC__))
/*@out@*/ /*@only@*/ void * xmalloc (size_t size) void * xmalloc (size_t size)
{ {
register void *value; register void *value;
if (size == 0) size++; if (size == 0) size++;
@ -31,7 +28,7 @@
return value; return value;
} }
/*@only@*/ void * xcalloc (size_t nmemb, size_t size) void * xcalloc (size_t nmemb, size_t size)
{ {
register void *value; register void *value;
if (size == 0) size++; if (size == 0) size++;
@ -42,7 +39,7 @@
return value; return value;
} }
/*@only@*/ void * xrealloc (/*@only@*/ void *ptr, size_t size) void * xrealloc (void *ptr, size_t size)
{ {
register void *value; register void *value;
if (size == 0) size++; if (size == 0) size++;
@ -52,7 +49,7 @@
return value; return value;
} }
/*@only@*/ char * xstrdup (const char *str) char * xstrdup (const char *str)
{ {
size_t size = strlen(str) + 1; size_t size = strlen(str) + 1;
char *newstr = (char *) malloc (size); char *newstr = (char *) malloc (size);

View File

@ -31,9 +31,8 @@
#define rpmIsDebug() \ #define rpmIsDebug() \
(rpmlogSetMask(0) >= RPMLOG_MASK( RPMMESS_DEBUG )) (rpmlogSetMask(0) >= RPMLOG_MASK( RPMMESS_DEBUG ))
/*@-redef@*/ /* LCL: ??? */ /* LCL: ??? */
typedef /*@abstract@*/ const void * fnpyKey; typedef const void * fnpyKey;
/*@=redef@*/
/** /**
* Bit(s) to identify progress callbacks. * Bit(s) to identify progress callbacks.
@ -68,18 +67,15 @@ extern "C" {
/** /**
*/ */
typedef void * (*rpmCallbackFunction) typedef void * (*rpmCallbackFunction)
(/*@null@*/ const void * h, (const void * h,
const rpmCallbackType what, const rpmCallbackType what,
const unsigned long amount, const unsigned long amount,
const unsigned long total, const unsigned long total,
/*@null@*/ fnpyKey key, fnpyKey key,
/*@null@*/ rpmCallbackData data) rpmCallbackData data);
/*@globals internalState@*/
/*@modifies internalState@*/;
/** /**
*/ */
/*@unused@*/
void urlSetCallback(rpmCallbackFunction notify, rpmCallbackData notifyData, void urlSetCallback(rpmCallbackFunction notify, rpmCallbackData notifyData,
int notifyCount); int notifyCount);

View File

@ -1,4 +1,3 @@
/*@-boundsread@*/
/** \ingroup rpmio signature /** \ingroup rpmio signature
* \file rpmio/rpmpgp.c * \file rpmio/rpmpgp.c
* Routines to handle RFC-2440 detached signatures. * Routines to handle RFC-2440 detached signatures.
@ -8,19 +7,13 @@
#include "rpmio_internal.h" #include "rpmio_internal.h"
#include "debug.h" #include "debug.h"
/*@access pgpDig @*/
/*@access pgpDigParams @*/
/*@unchecked@*/
static int _debug = 0; static int _debug = 0;
/*@unchecked@*/
static int _print = 0; static int _print = 0;
/*@unchecked@*/ /*@null@*/
static pgpDig _dig = NULL; static pgpDig _dig = NULL;
/*@unchecked@*/ /*@null@*/
static pgpDigParams _digp = NULL; static pgpDigParams _digp = NULL;
struct pgpValTbl_s pgpSigTypeTbl[] = { struct pgpValTbl_s pgpSigTypeTbl[] = {
@ -90,13 +83,10 @@ struct pgpValTbl_s pgpHashTbl[] = {
{ -1, "Unknown hash algorithm" }, { -1, "Unknown hash algorithm" },
}; };
/*@-exportlocal -exportheadervar@*/
/*@observer@*/ /*@unchecked@*/
struct pgpValTbl_s pgpKeyServerPrefsTbl[] = { struct pgpValTbl_s pgpKeyServerPrefsTbl[] = {
{ 0x80, "No-modify" }, { 0x80, "No-modify" },
{ -1, "Unknown key server preference" }, { -1, "Unknown key server preference" },
}; };
/*@=exportlocal =exportheadervar@*/
struct pgpValTbl_s pgpSubTypeTbl[] = { struct pgpValTbl_s pgpSubTypeTbl[] = {
{ PGPSUBTYPE_SIG_CREATE_TIME,"signature creation time" }, { PGPSUBTYPE_SIG_CREATE_TIME,"signature creation time" },
@ -188,25 +178,20 @@ struct pgpValTbl_s pgpArmorKeyTbl[] = {
* @param p memory to free * @param p memory to free
* @return NULL always * @return NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) _free(const void * p)
/*@modifies p @*/
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
} }
static void pgpPrtNL(void) static void pgpPrtNL(void)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (!_print) return; if (!_print) return;
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
static void pgpPrtInt(const char *pre, int i) static void pgpPrtInt(const char *pre, int i)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (!_print) return; if (!_print) return;
if (pre && *pre) if (pre && *pre)
@ -215,8 +200,6 @@ static void pgpPrtInt(const char *pre, int i)
} }
static void pgpPrtStr(const char *pre, const char *s) static void pgpPrtStr(const char *pre, const char *s)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (!_print) return; if (!_print) return;
if (pre && *pre) if (pre && *pre)
@ -225,8 +208,6 @@ static void pgpPrtStr(const char *pre, const char *s)
} }
static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen) static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (!_print) return; if (!_print) return;
if (pre && *pre) if (pre && *pre)
@ -235,8 +216,6 @@ static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen)
} }
void pgpPrtVal(const char * pre, pgpValTbl vs, byte val) void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
if (!_print) return; if (!_print) return;
if (pre && *pre) if (pre && *pre)
@ -246,9 +225,8 @@ void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
/** /**
*/ */
/*@unused@*/ static /*@observer@*/ static
const char * pgpMpiHex(const byte *p) const char * pgpMpiHex(const byte *p)
/*@*/
{ {
static char prbuf[2048]; static char prbuf[2048];
char *t = prbuf; char *t = prbuf;
@ -256,14 +234,11 @@ const char * pgpMpiHex(const byte *p)
return prbuf; return prbuf;
} }
/*@-boundswrite@*/
/** /**
* @return 0 on success * @return 0 on success
*/ */
static int pgpHexSet(const char * pre, int lbits, static int pgpHexSet(const char * pre, int lbits,
/*@out@*/ mpnumber * mpn, const byte * p, const byte * pend) mpnumber * mpn, const byte * p, const byte * pend)
/*@globals fileSystem @*/
/*@modifies mpn, fileSystem @*/
{ {
unsigned int mbits = pgpMpiBits(p); unsigned int mbits = pgpMpiBits(p);
unsigned int nbits; unsigned int nbits;
@ -291,7 +266,6 @@ if (_debug && _print)
fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data); fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
return 0; return 0;
} }
/*@=boundswrite@*/
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype) int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
{ {
@ -312,29 +286,26 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
case PGPSUBTYPE_PREFER_SYMKEY: /* preferred symmetric algorithms */ case PGPSUBTYPE_PREFER_SYMKEY: /* preferred symmetric algorithms */
for (i = 1; i < plen; i++) for (i = 1; i < plen; i++)
pgpPrtVal(" ", pgpSymkeyTbl, p[i]); pgpPrtVal(" ", pgpSymkeyTbl, p[i]);
/*@switchbreak@*/ break; break;
case PGPSUBTYPE_PREFER_HASH: /* preferred hash algorithms */ case PGPSUBTYPE_PREFER_HASH: /* preferred hash algorithms */
for (i = 1; i < plen; i++) for (i = 1; i < plen; i++)
pgpPrtVal(" ", pgpHashTbl, p[i]); pgpPrtVal(" ", pgpHashTbl, p[i]);
/*@switchbreak@*/ break; break;
case PGPSUBTYPE_PREFER_COMPRESS:/* preferred compression algorithms */ case PGPSUBTYPE_PREFER_COMPRESS:/* preferred compression algorithms */
for (i = 1; i < plen; i++) for (i = 1; i < plen; i++)
pgpPrtVal(" ", pgpCompressionTbl, p[i]); pgpPrtVal(" ", pgpCompressionTbl, p[i]);
/*@switchbreak@*/ break; break;
case PGPSUBTYPE_KEYSERVER_PREFERS:/* key server preferences */ case PGPSUBTYPE_KEYSERVER_PREFERS:/* key server preferences */
for (i = 1; i < plen; i++) for (i = 1; i < plen; i++)
pgpPrtVal(" ", pgpKeyServerPrefsTbl, p[i]); pgpPrtVal(" ", pgpKeyServerPrefsTbl, p[i]);
/*@switchbreak@*/ break; break;
case PGPSUBTYPE_SIG_CREATE_TIME: case PGPSUBTYPE_SIG_CREATE_TIME:
/*@-mods -mayaliasunique @*/
if (_digp && !(_digp->saved & PGPDIG_SAVED_TIME) && if (_digp && !(_digp->saved & PGPDIG_SAVED_TIME) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE)) (sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{ {
_digp->saved |= PGPDIG_SAVED_TIME; _digp->saved |= PGPDIG_SAVED_TIME;
memcpy(_digp->time, p+1, sizeof(_digp->time)); memcpy(_digp->time, p+1, sizeof(_digp->time));
} }
/*@=mods =mayaliasunique @*/
/*@fallthrough@*/
case PGPSUBTYPE_SIG_EXPIRE_TIME: case PGPSUBTYPE_SIG_EXPIRE_TIME:
case PGPSUBTYPE_KEY_EXPIRE_TIME: case PGPSUBTYPE_KEY_EXPIRE_TIME:
if ((plen - 1) == 4) { if ((plen - 1) == 4) {
@ -343,18 +314,15 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t); fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
} else } else
pgpPrtHex("", p+1, plen-1); pgpPrtHex("", p+1, plen-1);
/*@switchbreak@*/ break; break;
case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */ case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
/*@-mods -mayaliasunique @*/
if (_digp && !(_digp->saved & PGPDIG_SAVED_ID) && if (_digp && !(_digp->saved & PGPDIG_SAVED_ID) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE)) (sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{ {
_digp->saved |= PGPDIG_SAVED_ID; _digp->saved |= PGPDIG_SAVED_ID;
memcpy(_digp->signid, p+1, sizeof(_digp->signid)); memcpy(_digp->signid, p+1, sizeof(_digp->signid));
} }
/*@=mods =mayaliasunique @*/
/*@fallthrough@*/
case PGPSUBTYPE_EXPORTABLE_CERT: case PGPSUBTYPE_EXPORTABLE_CERT:
case PGPSUBTYPE_TRUST_SIG: case PGPSUBTYPE_TRUST_SIG:
case PGPSUBTYPE_REGEX: case PGPSUBTYPE_REGEX:
@ -383,7 +351,7 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
case PGPSUBTYPE_INTERNAL_110: case PGPSUBTYPE_INTERNAL_110:
default: default:
pgpPrtHex("", p+1, plen-1); pgpPrtHex("", p+1, plen-1);
/*@switchbreak@*/ break; break;
} }
pgpPrtNL(); pgpPrtNL();
p += plen; p += plen;
@ -392,25 +360,19 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
return 0; return 0;
} }
/*@-varuse =readonlytrans @*/
/*@observer@*/ /*@unchecked@*/
static const char * pgpSigRSA[] = { static const char * pgpSigRSA[] = {
" m**d =", " m**d =",
NULL, NULL,
}; };
/*@observer@*/ /*@unchecked@*/
static const char * pgpSigDSA[] = { static const char * pgpSigDSA[] = {
" r =", " r =",
" s =", " s =",
NULL, NULL,
}; };
/*@=varuse =readonlytrans @*/
static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigtype, static int pgpPrtSigParams(pgpTag tag, byte pubkey_algo, byte sigtype,
const byte *p, const byte *h, unsigned int hlen) const byte *p, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
const byte * pend = h + hlen; const byte * pend = h + hlen;
int i; int i;
@ -426,9 +388,9 @@ static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigty
(void) mpnsethex(&_dig->c, pgpMpiHex(p)); (void) mpnsethex(&_dig->c, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data); fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
pgpPrtStr("", pgpSigRSA[i]); pgpPrtStr("", pgpSigRSA[i]);
@ -442,13 +404,13 @@ fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
switch (i) { switch (i) {
case 0: /* r */ case 0: /* r */
xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->r, p, pend); xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->r, p, pend);
/*@switchbreak@*/ break; break;
case 1: /* s */ case 1: /* s */
xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->s, p, pend); xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->s, p, pend);
/*@switchbreak@*/ break; break;
default: default:
xx = 1; xx = 1;
/*@switchbreak@*/ break; break;
} }
if (xx) return xx; if (xx) return xx;
} }
@ -465,8 +427,6 @@ fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
} }
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
byte version = h[0]; byte version = h[0];
byte * p; byte * p;
@ -571,8 +531,6 @@ fprintf(stderr, " unhash[%u] -- %s\n", plen, pgpHexStr(p, plen));
return rc; return rc;
} }
/*@-varuse =readonlytrans @*/
/*@observer@*/ /*@unchecked@*/
static const char * pgpPublicRSA[] = { static const char * pgpPublicRSA[] = {
" n =", " n =",
" e =", " e =",
@ -580,7 +538,6 @@ static const char * pgpPublicRSA[] = {
}; };
#ifdef NOTYET #ifdef NOTYET
/*@observer@*/ /*@unchecked@*/
static const char * pgpSecretRSA[] = { static const char * pgpSecretRSA[] = {
" d =", " d =",
" p =", " p =",
@ -590,7 +547,6 @@ static const char * pgpSecretRSA[] = {
}; };
#endif #endif
/*@observer@*/ /*@unchecked@*/
static const char * pgpPublicDSA[] = { static const char * pgpPublicDSA[] = {
" p =", " p =",
" q =", " q =",
@ -600,14 +556,12 @@ static const char * pgpPublicDSA[] = {
}; };
#ifdef NOTYET #ifdef NOTYET
/*@observer@*/ /*@unchecked@*/
static const char * pgpSecretDSA[] = { static const char * pgpSecretDSA[] = {
" x =", " x =",
NULL, NULL,
}; };
#endif #endif
/*@observer@*/ /*@unchecked@*/
static const char * pgpPublicELGAMAL[] = { static const char * pgpPublicELGAMAL[] = {
" p =", " p =",
" g =", " g =",
@ -616,18 +570,14 @@ static const char * pgpPublicELGAMAL[] = {
}; };
#ifdef NOTYET #ifdef NOTYET
/*@observer@*/ /*@unchecked@*/
static const char * pgpSecretELGAMAL[] = { static const char * pgpSecretELGAMAL[] = {
" x =", " x =",
NULL, NULL,
}; };
#endif #endif
/*@=varuse =readonlytrans @*/
static const byte * pgpPrtPubkeyParams(byte pubkey_algo, static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen) const byte *p, const byte *h, unsigned int hlen)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
int i; int i;
@ -640,14 +590,14 @@ static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
(void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p)); (void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl); fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl);
/*@switchbreak@*/ break; break;
case 1: /* e */ case 1: /* e */
(void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p)); (void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data); fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data);
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
pgpPrtStr("", pgpPublicRSA[i]); pgpPrtStr("", pgpPublicRSA[i]);
@ -659,24 +609,24 @@ fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->r
(void) mpbsethex(&_dig->p, pgpMpiHex(p)); (void) mpbsethex(&_dig->p, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl); fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl);
/*@switchbreak@*/ break; break;
case 1: /* q */ case 1: /* q */
(void) mpbsethex(&_dig->q, pgpMpiHex(p)); (void) mpbsethex(&_dig->q, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl); fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl);
/*@switchbreak@*/ break; break;
case 2: /* g */ case 2: /* g */
(void) mpnsethex(&_dig->g, pgpMpiHex(p)); (void) mpnsethex(&_dig->g, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data); fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data);
/*@switchbreak@*/ break; break;
case 3: /* y */ case 3: /* y */
(void) mpnsethex(&_dig->y, pgpMpiHex(p)); (void) mpnsethex(&_dig->y, pgpMpiHex(p));
if (_debug && _print) if (_debug && _print)
fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data); fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
pgpPrtStr("", pgpPublicDSA[i]); pgpPrtStr("", pgpPublicDSA[i]);
@ -694,10 +644,8 @@ fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
return p; return p;
} }
static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo, static const byte * pgpPrtSeckeyParams(byte pubkey_algo,
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen) const byte *p, const byte *h, unsigned int hlen)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{ {
int i; int i;
@ -712,21 +660,20 @@ static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
case 0x00: case 0x00:
pgpPrtVal(" simple ", pgpHashTbl, p[2]); pgpPrtVal(" simple ", pgpHashTbl, p[2]);
p += 2; p += 2;
/*@innerbreak@*/ break; break;
case 0x01: case 0x01:
pgpPrtVal(" salted ", pgpHashTbl, p[2]); pgpPrtVal(" salted ", pgpHashTbl, p[2]);
pgpPrtHex("", p+3, 8); pgpPrtHex("", p+3, 8);
p += 10; p += 10;
/*@innerbreak@*/ break; break;
case 0x03: case 0x03:
pgpPrtVal(" iterated/salted ", pgpHashTbl, p[2]); pgpPrtVal(" iterated/salted ", pgpHashTbl, p[2]);
/*@-shiftnegative -shiftimplementation @*/ /* FIX: unsigned cast */ /* FIX: unsigned cast */
i = (16 + (p[11] & 0xf)) << ((p[11] >> 4) + 6); i = (16 + (p[11] & 0xf)) << ((p[11] >> 4) + 6);
/*@=shiftnegative =shiftimplementation @*/
pgpPrtHex("", p+3, 8); pgpPrtHex("", p+3, 8);
pgpPrtInt(" iter", i); pgpPrtInt(" iter", i);
p += 11; p += 11;
/*@innerbreak@*/ break; break;
} }
break; break;
default: default:
@ -769,8 +716,6 @@ static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
} }
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
byte version = *h; byte version = *h;
const byte * p; const byte * p;
@ -829,10 +774,7 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
return rc; return rc;
} }
/*@-boundswrite@*/
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
/*@globals _digp @*/
/*@modifies *_digp @*/
{ {
pgpPrtVal("", pgpTagTbl, tag); pgpPrtVal("", pgpTagTbl, tag);
if (_print) if (_print)
@ -845,7 +787,6 @@ int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
} }
return 0; return 0;
} }
/*@=boundswrite@*/
int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
{ {
@ -873,7 +814,7 @@ int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
return 0; return 0;
} }
int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen, int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
byte * keyid) byte * keyid)
{ {
const byte *s = pkt; const byte *s = pkt;
@ -893,13 +834,11 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
switch (v->pubkey_algo) { switch (v->pubkey_algo) {
case PGPPUBKEYALGO_RSA: case PGPPUBKEYALGO_RSA:
s += (pgpMpiLen(s) - 8); s += (pgpMpiLen(s) - 8);
/*@-boundswrite@*/
memmove(keyid, s, 8); memmove(keyid, s, 8);
/*@=boundswrite@*/
rc = 0; rc = 0;
/*@innerbreak@*/ break; break;
default: /* TODO: md5 of mpi bodies (i.e. no length) */ default: /* TODO: md5 of mpi bodies (i.e. no length) */
/*@innerbreak@*/ break; break;
} }
} break; } break;
case 4: case 4:
@ -912,11 +851,11 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
case PGPPUBKEYALGO_RSA: case PGPPUBKEYALGO_RSA:
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
s += pgpMpiLen(s); s += pgpMpiLen(s);
/*@innerbreak@*/ break; break;
case PGPPUBKEYALGO_DSA: case PGPPUBKEYALGO_DSA:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
s += pgpMpiLen(s); s += pgpMpiLen(s);
/*@innerbreak@*/ break; break;
} }
ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE); ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
@ -924,9 +863,7 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
(void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 0); (void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 0);
s = SHA1 + 12; s = SHA1 + 12;
/*@-boundswrite@*/
memmove(keyid, s, 8); memmove(keyid, s, 8);
/*@=boundswrite@*/
rc = 0; rc = 0;
if (SHA1) free(SHA1); if (SHA1) free(SHA1);
@ -970,14 +907,11 @@ int pgpPrtPkt(const byte *pkt, unsigned int pleft)
case PGPTAG_PUBLIC_KEY: case PGPTAG_PUBLIC_KEY:
/* Get the public key fingerprint. */ /* Get the public key fingerprint. */
if (_digp) { if (_digp) {
/*@-mods@*/
if (!pgpPubkeyFingerprint(pkt, pktlen, _digp->signid)) if (!pgpPubkeyFingerprint(pkt, pktlen, _digp->signid))
_digp->saved |= PGPDIG_SAVED_ID; _digp->saved |= PGPDIG_SAVED_ID;
else else
memset(_digp->signid, 0, sizeof(_digp->signid)); memset(_digp->signid, 0, sizeof(_digp->signid));
/*@=mods@*/
} }
/*@fallthrough@*/
case PGPTAG_PUBLIC_SUBKEY: case PGPTAG_PUBLIC_SUBKEY:
rc = pgpPrtKey(tag, h, hlen); rc = pgpPrtKey(tag, h, hlen);
break; break;
@ -1023,7 +957,6 @@ pgpDig pgpNewDig(void)
return dig; return dig;
} }
/*@-boundswrite@*/
void pgpCleanDig(pgpDig dig) void pgpCleanDig(pgpDig dig)
{ {
if (dig != NULL) { if (dig != NULL) {
@ -1032,12 +965,11 @@ void pgpCleanDig(pgpDig dig)
dig->pubkey.userid = _free(dig->pubkey.userid); dig->pubkey.userid = _free(dig->pubkey.userid);
dig->signature.hash = _free(dig->signature.hash); dig->signature.hash = _free(dig->signature.hash);
dig->pubkey.hash = _free(dig->pubkey.hash); dig->pubkey.hash = _free(dig->pubkey.hash);
/*@-unqualifiedtrans@*/ /* FIX: double indirection */ /* FIX: double indirection */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
dig->signature.params[i] = _free(dig->signature.params[i]); dig->signature.params[i] = _free(dig->signature.params[i]);
dig->pubkey.params[i] = _free(dig->pubkey.params[i]); dig->pubkey.params[i] = _free(dig->pubkey.params[i]);
} }
/*@=unqualifiedtrans@*/
memset(&dig->signature, 0, sizeof(dig->signature)); memset(&dig->signature, 0, sizeof(dig->signature));
memset(&dig->pubkey, 0, sizeof(dig->pubkey)); memset(&dig->pubkey, 0, sizeof(dig->pubkey));
@ -1053,30 +985,22 @@ void pgpCleanDig(pgpDig dig)
mpnfree(&dig->c); mpnfree(&dig->c);
mpnfree(&dig->rsahm); mpnfree(&dig->rsahm);
} }
/*@-nullstate@*/
return; return;
/*@=nullstate@*/
} }
/*@=boundswrite@*/
pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig) pgpDig pgpFreeDig(pgpDig dig)
/*@modifies dig @*/
{ {
if (dig != NULL) { if (dig != NULL) {
/* DUmp the signature/pubkey data. */ /* DUmp the signature/pubkey data. */
pgpCleanDig(dig); pgpCleanDig(dig);
/*@-branchstate@*/
if (dig->hdrsha1ctx != NULL) if (dig->hdrsha1ctx != NULL)
(void) rpmDigestFinal(dig->hdrsha1ctx, NULL, NULL, 0); (void) rpmDigestFinal(dig->hdrsha1ctx, NULL, NULL, 0);
/*@=branchstate@*/
dig->hdrsha1ctx = NULL; dig->hdrsha1ctx = NULL;
/*@-branchstate@*/
if (dig->sha1ctx != NULL) if (dig->sha1ctx != NULL)
(void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0); (void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0);
/*@=branchstate@*/
dig->sha1ctx = NULL; dig->sha1ctx = NULL;
mpbfree(&dig->p); mpbfree(&dig->p);
@ -1088,17 +1012,13 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
mpnfree(&dig->s); mpnfree(&dig->s);
#ifdef NOTYET #ifdef NOTYET
/*@-branchstate@*/
if (dig->hdrmd5ctx != NULL) if (dig->hdrmd5ctx != NULL)
(void) rpmDigestFinal(dig->hdrmd5ctx, NULL, NULL, 0); (void) rpmDigestFinal(dig->hdrmd5ctx, NULL, NULL, 0);
/*@=branchstate@*/
dig->hdrmd5ctx = NULL; dig->hdrmd5ctx = NULL;
#endif #endif
/*@-branchstate@*/
if (dig->md5ctx != NULL) if (dig->md5ctx != NULL)
(void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0); (void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0);
/*@=branchstate@*/
dig->md5ctx = NULL; dig->md5ctx = NULL;
mpbfree(&dig->rsa_pk.n); mpbfree(&dig->rsa_pk.n);
@ -1113,8 +1033,6 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
} }
int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing) int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
/*@globals _dig, _digp, _print @*/
/*@modifies _dig, _digp, *_digp, _print @*/
{ {
unsigned int val = *pkts; unsigned int val = *pkts;
const byte *p; const byte *p;
@ -1140,7 +1058,6 @@ int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
return 0; return 0;
} }
/*@-boundswrite@*/
pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen) pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
{ {
byte * b = NULL; byte * b = NULL;
@ -1199,7 +1116,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
continue; continue;
*t = '\0'; *t = '\0';
pstate++; pstate++;
/*@switchbreak@*/ break; break;
case 1: case 1:
enc = NULL; enc = NULL;
rc = pgpValTok(pgpArmorKeyTbl, t, te); rc = pgpValTok(pgpArmorKeyTbl, t, te);
@ -1211,7 +1128,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
} }
enc = te; /* Start of encoded packets */ enc = te; /* Start of encoded packets */
pstate++; pstate++;
/*@switchbreak@*/ break; break;
case 2: case 2:
crcenc = NULL; crcenc = NULL;
if (*t != '=') if (*t != '=')
@ -1219,7 +1136,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
*t++ = '\0'; /* Terminate encoded packets */ *t++ = '\0'; /* Terminate encoded packets */
crcenc = t; /* Start of encoded crc */ crcenc = t; /* Start of encoded crc */
pstate++; pstate++;
/*@switchbreak@*/ break; break;
case 3: case 3:
pstate = 0; pstate = 0;
if (!TOKEQ(t, "-----END PGP ")) { if (!TOKEQ(t, "-----END PGP ")) {
@ -1272,7 +1189,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
blen = declen; blen = declen;
ec = PGPARMOR_PUBKEY; /* XXX ASCII Pubkeys only, please. */ ec = PGPARMOR_PUBKEY; /* XXX ASCII Pubkeys only, please. */
goto exit; goto exit;
/*@notreached@*/ /*@switchbreak@*/ break; break;
} }
} }
ec = PGPARMOR_NONE; ec = PGPARMOR_NONE;
@ -1286,7 +1203,6 @@ exit:
*pktlen = blen; *pktlen = blen;
return ec; return ec;
} }
/*@=boundswrite@*/
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns) char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
{ {
@ -1297,7 +1213,6 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
int lc; int lc;
nt = ((ns + 2) / 3) * 4; nt = ((ns + 2) / 3) * 4;
/*@-globs@*/
/* Add additional bytes necessary for eol string(s). */ /* Add additional bytes necessary for eol string(s). */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) { if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line; lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
@ -1305,18 +1220,14 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
++lc; ++lc;
nt += lc * strlen(b64encode_eolstr); nt += lc * strlen(b64encode_eolstr);
} }
/*@=globs@*/
nt += 512; /* XXX slop for armor and crc */ nt += 512; /* XXX slop for armor and crc */
/*@-boundswrite@*/
val = t = xmalloc(nt + 1); val = t = xmalloc(nt + 1);
*t = '\0'; *t = '\0';
t = stpcpy(t, "-----BEGIN PGP "); t = stpcpy(t, "-----BEGIN PGP ");
t = stpcpy(t, pgpValStr(pgpArmorTbl, atype)); t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
/*@-globs@*/
t = stpcpy( stpcpy(t, "-----\nVersion: rpm-"), VERSION); t = stpcpy( stpcpy(t, "-----\nVersion: rpm-"), VERSION);
/*@=globs@*/
t = stpcpy(t, " (beecrypt-4.1.2)\n\n"); t = stpcpy(t, " (beecrypt-4.1.2)\n\n");
if ((enc = b64encode(s, ns)) != NULL) { if ((enc = b64encode(s, ns)) != NULL) {
@ -1332,9 +1243,7 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
t = stpcpy(t, "-----END PGP "); t = stpcpy(t, "-----END PGP ");
t = stpcpy(t, pgpValStr(pgpArmorTbl, atype)); t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
t = stpcpy(t, "-----\n"); t = stpcpy(t, "-----\n");
/*@=boundswrite@*/
return val; return val;
} }
/*@=boundsread@*/

View File

@ -13,20 +13,18 @@
#include <string.h> #include <string.h>
#if !defined(_BEECRYPT_API_H) #if !defined(_BEECRYPT_API_H)
/*@-redef@*/
typedef unsigned char byte; typedef unsigned char byte;
/*@=redef@*/
#endif /* _BEECRYPT_API_H */ #endif /* _BEECRYPT_API_H */
/** /**
*/ */
typedef /*@abstract@*/ struct DIGEST_CTX_s * DIGEST_CTX; typedef struct DIGEST_CTX_s * DIGEST_CTX;
/** /**
*/ */
typedef const struct pgpValTbl_s { typedef const struct pgpValTbl_s {
int val; int val;
/*@observer@*/ const char * str; const char * str;
} * pgpValTbl; } * pgpValTbl;
/** /**
@ -64,7 +62,6 @@ typedef enum pgpTag_e {
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpTagTbl[]; extern struct pgpValTbl_s pgpTagTbl[];
/** /**
@ -114,7 +111,6 @@ typedef struct pgpPktPubkey_s {
* There are a number of possible meanings for a signature, which are * There are a number of possible meanings for a signature, which are
* specified in a signature type octet in any given signature. * specified in a signature type octet in any given signature.
*/ */
/*@-typeuse@*/
typedef enum pgpSigType_e { typedef enum pgpSigType_e {
PGPSIGTYPE_BINARY = 0x00, /*!< Binary document */ PGPSIGTYPE_BINARY = 0x00, /*!< Binary document */
PGPSIGTYPE_TEXT = 0x01, /*!< Canonical text document */ PGPSIGTYPE_TEXT = 0x01, /*!< Canonical text document */
@ -134,11 +130,9 @@ typedef enum pgpSigType_e {
PGPSIGTYPE_CERT_REVOKE = 0x30, /*!< Certification revocation */ PGPSIGTYPE_CERT_REVOKE = 0x30, /*!< Certification revocation */
PGPSIGTYPE_TIMESTAMP = 0x40 /*!< Timestamp */ PGPSIGTYPE_TIMESTAMP = 0x40 /*!< Timestamp */
} pgpSigType; } pgpSigType;
/*@=typeuse@*/
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpSigTypeTbl[]; extern struct pgpValTbl_s pgpSigTypeTbl[];
/** /**
@ -164,7 +158,6 @@ extern struct pgpValTbl_s pgpSigTypeTbl[];
* encryption. Implementations SHOULD implement RSA keys. * encryption. Implementations SHOULD implement RSA keys.
* Implementations MAY implement any other algorithm. * Implementations MAY implement any other algorithm.
*/ */
/*@-typeuse@*/
typedef enum pgpPubkeyAlgo_e { typedef enum pgpPubkeyAlgo_e {
PGPPUBKEYALGO_RSA = 1, /*!< RSA */ PGPPUBKEYALGO_RSA = 1, /*!< RSA */
PGPPUBKEYALGO_RSA_ENCRYPT = 2, /*!< RSA(Encrypt-Only) */ PGPPUBKEYALGO_RSA_ENCRYPT = 2, /*!< RSA(Encrypt-Only) */
@ -176,11 +169,9 @@ typedef enum pgpPubkeyAlgo_e {
PGPPUBKEYALGO_ELGAMAL = 20, /*!< Elgamal */ PGPPUBKEYALGO_ELGAMAL = 20, /*!< Elgamal */
PGPPUBKEYALGO_DH = 21 /*!< Diffie-Hellman (X9.42) */ PGPPUBKEYALGO_DH = 21 /*!< Diffie-Hellman (X9.42) */
} pgpPubkeyAlgo; } pgpPubkeyAlgo;
/*@=typeuse@*/
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpPubkeyTbl[]; extern struct pgpValTbl_s pgpPubkeyTbl[];
/** /**
@ -207,7 +198,6 @@ extern struct pgpValTbl_s pgpPubkeyTbl[];
* implement IDEA and CAST5. Implementations MAY implement any other * implement IDEA and CAST5. Implementations MAY implement any other
* algorithm. * algorithm.
*/ */
/*@-typeuse@*/
typedef enum pgpSymkeyAlgo_e { typedef enum pgpSymkeyAlgo_e {
PGPSYMKEYALGO_PLAINTEXT = 0, /*!< Plaintext */ PGPSYMKEYALGO_PLAINTEXT = 0, /*!< Plaintext */
PGPSYMKEYALGO_IDEA = 1, /*!< IDEA */ PGPSYMKEYALGO_IDEA = 1, /*!< IDEA */
@ -222,12 +212,10 @@ typedef enum pgpSymkeyAlgo_e {
PGPSYMKEYALGO_TWOFISH = 10, /*!< TWOFISH(256-bit key) */ PGPSYMKEYALGO_TWOFISH = 10, /*!< TWOFISH(256-bit key) */
PGPSYMKEYALGO_NOENCRYPT = 110 /*!< no encryption */ PGPSYMKEYALGO_NOENCRYPT = 110 /*!< no encryption */
} pgpSymkeyAlgo; } pgpSymkeyAlgo;
/*@=typeuse@*/
/** /**
* Symmetric key (string, value) pairs. * Symmetric key (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpSymkeyTbl[]; extern struct pgpValTbl_s pgpSymkeyTbl[];
/** /**
@ -245,19 +233,16 @@ extern struct pgpValTbl_s pgpSymkeyTbl[];
* Implementations MUST implement uncompressed data. Implementations * Implementations MUST implement uncompressed data. Implementations
* SHOULD implement ZIP. Implementations MAY implement ZLIB. * SHOULD implement ZIP. Implementations MAY implement ZLIB.
*/ */
/*@-typeuse@*/
typedef enum pgpCompressAlgo_e { typedef enum pgpCompressAlgo_e {
PGPCOMPRESSALGO_NONE = 0, /*!< Uncompressed */ PGPCOMPRESSALGO_NONE = 0, /*!< Uncompressed */
PGPCOMPRESSALGO_ZIP = 1, /*!< ZIP */ PGPCOMPRESSALGO_ZIP = 1, /*!< ZIP */
PGPCOMPRESSALGO_ZLIB = 2, /*!< ZLIB */ PGPCOMPRESSALGO_ZLIB = 2, /*!< ZLIB */
PGPCOMPRESSALGO_BZIP2 = 3 /*!< BZIP2 */ PGPCOMPRESSALGO_BZIP2 = 3 /*!< BZIP2 */
} pgpCompressAlgo; } pgpCompressAlgo;
/*@=typeuse@*/
/** /**
* Compression (string, value) pairs. * Compression (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpCompressionTbl[]; extern struct pgpValTbl_s pgpCompressionTbl[];
/** /**
@ -296,7 +281,6 @@ typedef enum pgpHashAlgo_e {
/** /**
* Hash (string, value) pairs. * Hash (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpHashTbl[]; extern struct pgpValTbl_s pgpHashTbl[];
/** /**
@ -426,7 +410,6 @@ typedef struct pgpPktSigV4_s {
* marked critical but is unknown to the evaluating software, the * marked critical but is unknown to the evaluating software, the
* evaluator SHOULD consider the signature to be in error. * evaluator SHOULD consider the signature to be in error.
*/ */
/*@-typeuse@*/
typedef enum pgpSubType_e { typedef enum pgpSubType_e {
PGPSUBTYPE_NONE = 0, /*!< none */ PGPSUBTYPE_NONE = 0, /*!< none */
PGPSUBTYPE_SIG_CREATE_TIME = 2, /*!< signature creation time */ PGPSUBTYPE_SIG_CREATE_TIME = 2, /*!< signature creation time */
@ -467,12 +450,10 @@ typedef enum pgpSubType_e {
PGPSUBTYPE_CRITICAL = 128 /*!< critical subpacket marker */ PGPSUBTYPE_CRITICAL = 128 /*!< critical subpacket marker */
} pgpSubType; } pgpSubType;
/*@=typeuse@*/
/** /**
* Subtype (string, value) pairs. * Subtype (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpSubTypeTbl[]; extern struct pgpValTbl_s pgpSubTypeTbl[];
/** /**
@ -926,7 +907,6 @@ union pgpPktPre_u {
/** /**
*/ */
/*@-typeuse@*/
typedef enum pgpArmor_e { typedef enum pgpArmor_e {
PGPARMOR_ERR_CRC_CHECK = -7, PGPARMOR_ERR_CRC_CHECK = -7,
PGPARMOR_ERR_BODY_DECODE = -6, PGPARMOR_ERR_BODY_DECODE = -6,
@ -945,17 +925,14 @@ typedef enum pgpArmor_e {
PGPARMOR_PRIVKEY = 6, /*!< PRIVATE KEY BLOCK */ PGPARMOR_PRIVKEY = 6, /*!< PRIVATE KEY BLOCK */
PGPARMOR_SECKEY = 7 /*!< SECRET KEY BLOCK */ PGPARMOR_SECKEY = 7 /*!< SECRET KEY BLOCK */
} pgpArmor; } pgpArmor;
/*@=typeuse@*/
/** /**
* Armor (string, value) pairs. * Armor (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpArmorTbl[]; extern struct pgpValTbl_s pgpArmorTbl[];
/** /**
*/ */
/*@-typeuse@*/
typedef enum pgpArmorKey_e { typedef enum pgpArmorKey_e {
PGPARMORKEY_VERSION = 1, /*!< Version: */ PGPARMORKEY_VERSION = 1, /*!< Version: */
PGPARMORKEY_COMMENT = 2, /*!< Comment: */ PGPARMORKEY_COMMENT = 2, /*!< Comment: */
@ -963,12 +940,10 @@ typedef enum pgpArmorKey_e {
PGPARMORKEY_HASH = 4, /*!< Hash: */ PGPARMORKEY_HASH = 4, /*!< Hash: */
PGPARMORKEY_CHARSET = 5 /*!< Charset: */ PGPARMORKEY_CHARSET = 5 /*!< Charset: */
} pgpArmorKey; } pgpArmorKey;
/*@=typeuse@*/
/** /**
* Armor key (string, value) pairs. * Armor key (string, value) pairs.
*/ */
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpArmorKeyTbl[]; extern struct pgpValTbl_s pgpArmorKeyTbl[];
/** \ingroup rpmio /** \ingroup rpmio
@ -979,7 +954,6 @@ typedef enum rpmDigestFlags_e {
} rpmDigestFlags; } rpmDigestFlags;
/*@-fcnuse@*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -990,16 +964,13 @@ extern "C" {
* @param nbytes no. of bytes * @param nbytes no. of bytes
* @return native-endian integer * @return native-endian integer
*/ */
/*@unused@*/ static inline static inline
unsigned int pgpGrab(const byte *s, int nbytes) unsigned int pgpGrab(const byte *s, int nbytes)
/*@*/
{ {
unsigned int i = 0; unsigned int i = 0;
int nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i)); int nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i));
/*@-boundsread@*/
while (nb--) while (nb--)
i = (i << 8) | *s++; i = (i << 8) | *s++;
/*@=boundsread@*/
return i; return i;
} }
@ -1009,11 +980,9 @@ unsigned int pgpGrab(const byte *s, int nbytes)
* @retval *lenp no. of bytes in packet * @retval *lenp no. of bytes in packet
* @return no. of bytes in length prefix * @return no. of bytes in length prefix
*/ */
/*@unused@*/ static inline static inline
int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp) int pgpLen(const byte *s, unsigned int *lenp)
/*@modifies *lenp @*/
{ {
/*@-boundswrite@*/
if (*s < 192) { if (*s < 192) {
(*lenp) = *s++; (*lenp) = *s++;
return 1; return 1;
@ -1024,7 +993,6 @@ int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
(*lenp) = pgpGrab(s+1, 4); (*lenp) = pgpGrab(s+1, 4);
return 5; return 5;
} }
/*@=boundswrite@*/
} }
/** /**
@ -1032,10 +1000,8 @@ int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
* @param p pointer to multiprecision integer * @param p pointer to multiprecision integer
* @return no. of bits * @return no. of bits
*/ */
/*@unused@*/ static inline static inline
unsigned int pgpMpiBits(const byte *p) unsigned int pgpMpiBits(const byte *p)
/*@requires maxRead(p) >= 1 @*/
/*@*/
{ {
return ((p[0] << 8) | p[1]); return ((p[0] << 8) | p[1]);
} }
@ -1045,10 +1011,8 @@ unsigned int pgpMpiBits(const byte *p)
* @param p pointer to multiprecision integer * @param p pointer to multiprecision integer
* @return no. of bytes * @return no. of bytes
*/ */
/*@unused@*/ static inline static inline
unsigned int pgpMpiLen(const byte *p) unsigned int pgpMpiLen(const byte *p)
/*@requires maxRead(p) >= 1 @*/
/*@*/
{ {
return (2 + ((pgpMpiBits(p)+7)>>3)); return (2 + ((pgpMpiBits(p)+7)>>3));
} }
@ -1060,12 +1024,10 @@ unsigned int pgpMpiLen(const byte *p)
* @param nbytes no. of bytes * @param nbytes no. of bytes
* @return target buffer * @return target buffer
*/ */
/*@unused@*/ static inline static inline
char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes) char * pgpHexCvt(char *t, const byte *s, int nbytes)
/*@modifies *t @*/
{ {
static char hex[] = "0123456789abcdef"; static char hex[] = "0123456789abcdef";
/*@-boundswrite@*/
while (nbytes-- > 0) { while (nbytes-- > 0) {
unsigned int i; unsigned int i;
i = *s++; i = *s++;
@ -1073,7 +1035,6 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
*t++ = hex[ (i ) & 0xf ]; *t++ = hex[ (i ) & 0xf ];
} }
*t = '\0'; *t = '\0';
/*@=boundswrite@*/
return t; return t;
} }
@ -1084,9 +1045,8 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
* @param plen no. of bytes * @param plen no. of bytes
* @return hex formatted string * @return hex formatted string
*/ */
/*@unused@*/ static inline /*@observer@*/ static inline
char * pgpHexStr(const byte *p, unsigned int plen) char * pgpHexStr(const byte *p, unsigned int plen)
/*@*/
{ {
static char prbuf[8*BUFSIZ]; /* XXX ick */ static char prbuf[8*BUFSIZ]; /* XXX ick */
char *t = prbuf; char *t = prbuf;
@ -1100,10 +1060,8 @@ char * pgpHexStr(const byte *p, unsigned int plen)
* @param p bytes * @param p bytes
* @return hex formatted string * @return hex formatted string
*/ */
/*@unused@*/ static inline /*@observer@*/ static inline
const char * pgpMpiStr(const byte *p) const char * pgpMpiStr(const byte *p)
/*@requires maxRead(p) >= 3 @*/
/*@*/
{ {
static char prbuf[8*BUFSIZ]; /* XXX ick */ static char prbuf[8*BUFSIZ]; /* XXX ick */
char *t = prbuf; char *t = prbuf;
@ -1119,9 +1077,8 @@ const char * pgpMpiStr(const byte *p)
* @param val byte value to lookup * @param val byte value to lookup
* @return string value of byte * @return string value of byte
*/ */
/*@unused@*/ static inline /*@observer@*/ static inline
const char * pgpValStr(pgpValTbl vs, byte val) const char * pgpValStr(pgpValTbl vs, byte val)
/*@*/
{ {
do { do {
if (vs->val == val) if (vs->val == val)
@ -1137,9 +1094,8 @@ const char * pgpValStr(pgpValTbl vs, byte val)
* @param se end-of-string address * @param se end-of-string address
* @return byte value * @return byte value
*/ */
/*@unused@*/ static inline static inline
int pgpValTok(pgpValTbl vs, const char * s, const char * se) int pgpValTok(pgpValTbl vs, const char * s, const char * se)
/*@*/
{ {
do { do {
int vlen = strlen(vs->str); int vlen = strlen(vs->str);
@ -1149,16 +1105,13 @@ int pgpValTok(pgpValTbl vs, const char * s, const char * se)
return vs->val; return vs->val;
} }
/*@-exportlocal@*/
/** /**
* Print an OpenPGP value. * Print an OpenPGP value.
* @param pre output prefix * @param pre output prefix
* @param vs table of (string,value) pairs * @param vs table of (string,value) pairs
* @param val byte value to print * @param val byte value to print
*/ */
void pgpPrtVal(const char * pre, pgpValTbl vs, byte val) void pgpPrtVal(const char * pre, pgpValTbl vs, byte val);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* Print/parse an OpenPGP subtype packet. * Print/parse an OpenPGP subtype packet.
@ -1167,9 +1120,7 @@ void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
* @param sigtype signature type * @param sigtype signature type
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype) int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* Print/parse an OpenPGP signature packet. * Print/parse an OpenPGP signature packet.
@ -1178,9 +1129,7 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
* @param hlen packet length (no. of bytes) * @param hlen packet length (no. of bytes)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP key packet. * Print/parse an OpenPGP key packet.
@ -1189,9 +1138,7 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
* @param hlen packet length (no. of bytes) * @param hlen packet length (no. of bytes)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP userid packet. * Print/parse an OpenPGP userid packet.
@ -1200,9 +1147,7 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
* @param hlen packet length (no. of bytes) * @param hlen packet length (no. of bytes)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/** /**
* Print/parse an OpenPGP comment packet. * Print/parse an OpenPGP comment packet.
@ -1211,9 +1156,7 @@ int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
* @param hlen packet length (no. of bytes) * @param hlen packet length (no. of bytes)
* @return 0 on success * @return 0 on success
*/ */
int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen) int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen);
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** /**
* Calculate OpenPGP public key fingerprint. * Calculate OpenPGP public key fingerprint.
@ -1224,8 +1167,7 @@ int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
* @return 0 on sucess, else -1 * @return 0 on sucess, else -1
*/ */
int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen, int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
/*@out@*/ byte * keyid) byte * keyid);
/*@modifies *keyid @*/;
/** /**
* Print/parse next OpenPGP packet. * Print/parse next OpenPGP packet.
@ -1233,10 +1175,7 @@ int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
* @param pleft no. bytes remaining * @param pleft no. bytes remaining
* @return -1 on error, otherwise this packet length * @return -1 on error, otherwise this packet length
*/ */
int pgpPrtPkt(const byte *pkt, unsigned int pleft) int pgpPrtPkt(const byte *pkt, unsigned int pleft);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
/*@=exportlocal@*/
/** /**
* Print/parse a OpenPGP packet(s). * Print/parse a OpenPGP packet(s).
@ -1246,9 +1185,7 @@ int pgpPrtPkt(const byte *pkt, unsigned int pleft)
* @param printing should packets be printed? * @param printing should packets be printed?
* @return -1 on error, 0 on success * @return -1 on error, 0 on success
*/ */
int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing) int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing);
/*@globals fileSystem, internalState @*/
/*@modifies dig, fileSystem, internalState @*/;
/** /**
* Parse armored OpenPGP packets from a file. * Parse armored OpenPGP packets from a file.
@ -1258,9 +1195,7 @@ int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
* @return type of armor found * @return type of armor found
*/ */
pgpArmor pgpReadPkts(const char * fn, pgpArmor pgpReadPkts(const char * fn,
/*@out@*/ const byte ** pkt, /*@out@*/ size_t * pktlen) const byte ** pkt, size_t * pktlen);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
/** /**
* Wrap a OpenPGP packets in ascii armor for transport. * Wrap a OpenPGP packets in ascii armor for transport.
@ -1269,45 +1204,36 @@ pgpArmor pgpReadPkts(const char * fn,
* @param ns binary pkt data length * @param ns binary pkt data length
* @return formatted string * @return formatted string
*/ */
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns) char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns);
/*@*/;
/** /**
* Create a container for parsed OpenPGP packates. * Create a container for parsed OpenPGP packates.
* @return container * @return container
*/ */
/*@only@*/ pgpDig pgpNewDig(void);
pgpDig pgpNewDig(void)
/*@*/;
/** /**
* Release (malloc'd) data from container. * Release (malloc'd) data from container.
* @param dig container * @param dig container
*/ */
void pgpCleanDig(/*@null@*/ pgpDig dig) void pgpCleanDig(pgpDig dig);
/*@modifies dig @*/;
/** /**
* Destroy a container for parsed OpenPGP packates. * Destroy a container for parsed OpenPGP packates.
* @param dig container * @param dig container
* @return NULL always * @return NULL always
*/ */
/*@only@*/ /*@null@*/ pgpDig pgpFreeDig(pgpDig dig);
pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
/*@modifies dig @*/;
/** /**
* Is buffer at beginning of an OpenPGP packet? * Is buffer at beginning of an OpenPGP packet?
* @param p buffer * @param p buffer
* @return 1 if an OpenPGP packet, 0 otherwise * @return 1 if an OpenPGP packet, 0 otherwise
*/ */
/*@unused@*/ static inline static inline
int pgpIsPkt(const byte * p) int pgpIsPkt(const byte * p)
/*@*/
{ {
/*@-boundsread@*/
unsigned int val = *p++; unsigned int val = *p++;
/*@=boundsread@*/
pgpTag tag; pgpTag tag;
int rc; int rc;
@ -1363,17 +1289,14 @@ int pgpIsPkt(const byte * p)
* @param len no. of bytes * @param len no. of bytes
* @return crc of buffer * @return crc of buffer
*/ */
/*@unused@*/ static inline static inline
unsigned int pgpCRC(const byte *octets, size_t len) unsigned int pgpCRC(const byte *octets, size_t len)
/*@*/
{ {
unsigned int crc = CRC24_INIT; unsigned int crc = CRC24_INIT;
int i; int i;
while (len--) { while (len--) {
/*@-boundsread@*/
crc ^= (*octets++) << 16; crc ^= (*octets++) << 16;
/*@=boundsread@*/
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
crc <<= 1; crc <<= 1;
if (crc & 0x1000000) if (crc & 0x1000000)
@ -1388,9 +1311,7 @@ unsigned int pgpCRC(const byte *octets, size_t len)
* @param octx existing digest context * @param octx existing digest context
* @return duplicated digest context * @return duplicated digest context
*/ */
/*@only@*/ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx);
DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
/*@*/;
/** \ingroup rpmio /** \ingroup rpmio
* Initialize digest. * Initialize digest.
@ -1399,9 +1320,7 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
* @param flags bit(s) to control digest operation * @param flags bit(s) to control digest operation
* @return digest context * @return digest context
*/ */
/*@only@*/ /*@null@*/ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags);
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
/*@*/;
/** \ingroup rpmio /** \ingroup rpmio
* Update context with next plain text buffer. * Update context with next plain text buffer.
@ -1410,8 +1329,7 @@ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
* @param len no. bytes of data * @param len no. bytes of data
* @return 0 on success * @return 0 on success
*/ */
int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len) int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len);
/*@modifies ctx @*/;
/** \ingroup rpmio /** \ingroup rpmio
* Return digest and destroy context. * Return digest and destroy context.
@ -1424,14 +1342,12 @@ int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
* @param asAscii return digest as ascii string? * @param asAscii return digest as ascii string?
* @return 0 on success * @return 0 on success
*/ */
int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx, int rpmDigestFinal(DIGEST_CTX ctx,
/*@null@*/ /*@out@*/ void ** datap, void ** datap,
/*@null@*/ /*@out@*/ size_t * lenp, int asAscii) size_t * lenp, int asAscii);
/*@modifies *datap, *lenp @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/*@=fcnuse@*/
#endif /* H_RPMPGP */ #endif /* H_RPMPGP */

View File

@ -16,27 +16,21 @@
#include "ugid.h" #include "ugid.h"
#include "debug.h" #include "debug.h"
/*@access DIR @*/
/*@access FD_t @*/
/*@access urlinfo @*/
/** /**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free * @param p memory to free
* @retval NULL always * @retval NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) _free(const void * p)
/*@modifies p@*/
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
} }
/* =============================================================== */ /* =============================================================== */
static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode) static int ftpMkdir(const char * path, mode_t mode)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
int rc; int rc;
if ((rc = ftpCmd("MKD", path, NULL)) != 0) if ((rc = ftpCmd("MKD", path, NULL)) != 0)
@ -51,22 +45,16 @@ static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
} }
static int ftpChdir(const char * path) static int ftpChdir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
return ftpCmd("CWD", path, NULL); return ftpCmd("CWD", path, NULL);
} }
static int ftpRmdir(const char * path) static int ftpRmdir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
return ftpCmd("RMD", path, NULL); return ftpCmd("RMD", path, NULL);
} }
static int ftpRename(const char * oldpath, const char * newpath) static int ftpRename(const char * oldpath, const char * newpath)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
int rc; int rc;
if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0) if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0)
@ -75,8 +63,6 @@ static int ftpRename(const char * oldpath, const char * newpath)
} }
static int ftpUnlink(const char * path) static int ftpUnlink(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
return ftpCmd("DELE", path, NULL); return ftpCmd("DELE", path, NULL);
} }
@ -90,23 +76,22 @@ int Mkdir (const char * path, mode_t mode)
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpMkdir(path, mode); return ftpMkdir(path, mode);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davMkdir(path, mode); return davMkdir(path, mode);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return mkdir(path, mode); return mkdir(path, mode);
} }
@ -119,7 +104,7 @@ int Chdir (const char * path)
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpChdir(path); return ftpChdir(path);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef NOTYET #ifdef NOTYET
@ -127,17 +112,16 @@ int Chdir (const char * path)
#else #else
return -2; return -2;
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return chdir(path); return chdir(path);
} }
@ -150,23 +134,22 @@ int Rmdir (const char * path)
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpRmdir(path); return ftpRmdir(path);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davRmdir(path); return davRmdir(path);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return rmdir(path); return rmdir(path);
} }
@ -189,7 +172,7 @@ int Rename (const char * oldpath, const char * newpath)
#ifdef WITH_NEON #ifdef WITH_NEON
return davRename(oldpath, newpath); return davRename(oldpath, newpath);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH: case URL_IS_PATH:
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
@ -198,7 +181,7 @@ int Rename (const char * oldpath, const char * newpath)
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
newut = urlPath(newpath, &ne); newut = urlPath(newpath, &ne);
@ -210,7 +193,7 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i
!xstrncasecmp(oldpath, newpath, (oe - oldpath)))) !xstrncasecmp(oldpath, newpath, (oe - oldpath))))
return -2; return -2;
return ftpRename(oldpath, newpath); return ftpRename(oldpath, newpath);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */ case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH: case URL_IS_PATH:
@ -223,7 +206,7 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return rename(oldpath, newpath); return rename(oldpath, newpath);
} }
@ -246,7 +229,7 @@ int Link (const char * oldpath, const char * newpath)
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
newut = urlPath(newpath, &ne); newut = urlPath(newpath, &ne);
@ -269,7 +252,7 @@ fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return link(oldpath, newpath); return link(oldpath, newpath);
} }
@ -283,23 +266,22 @@ int Unlink(const char * path) {
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpUnlink(path); return ftpUnlink(path);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davUnlink(path); return davUnlink(path);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return unlink(path); return unlink(path);
} }
@ -312,26 +294,18 @@ int Unlink(const char * path) {
/* /*
* FIXME: this is broken. It depends on mc not crossing border on month! * FIXME: this is broken. It depends on mc not crossing border on month!
*/ */
/*@unchecked@*/
static int current_mday; static int current_mday;
/*@unchecked@*/
static int current_mon; static int current_mon;
/*@unchecked@*/
static int current_year; static int current_year;
/* Following stuff (parse_ls_lga) is used by ftpfs and extfs */ /* Following stuff (parse_ls_lga) is used by ftpfs and extfs */
#define MAXCOLS 30 #define MAXCOLS 30
/*@unchecked@*/
static char *columns [MAXCOLS]; /* Points to the string in column n */ static char *columns [MAXCOLS]; /* Points to the string in column n */
/*@unchecked@*/
static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */ static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */
/*@-boundswrite@*/
static int static int
vfs_split_text (char *p) vfs_split_text (char *p)
/*@globals columns, column_ptr @*/
/*@modifies *p, columns, column_ptr @*/
{ {
char *original = p; char *original = p;
int numcols; int numcols;
@ -349,41 +323,31 @@ vfs_split_text (char *p)
} }
return numcols; return numcols;
} }
/*@=boundswrite@*/
/*@-boundsread@*/
static int static int
is_num (int idx) is_num (int idx)
/*@*/
{ {
if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9') if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9')
return 0; return 0;
return 1; return 1;
} }
/*@=boundsread@*/
/*@-boundsread@*/
static int static int
is_dos_date(/*@null@*/ const char *str) is_dos_date(const char *str)
/*@*/
{ {
if (str != NULL && strlen(str) == 8 && if (str != NULL && strlen(str) == 8 &&
str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL) str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
return 1; return 1;
return 0; return 0;
} }
/*@=boundsread@*/
static int static int
is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) is_week (const char * str, struct tm * tim)
/*@modifies *tim @*/
{ {
/*@observer@*/ static const char * week = "SunMonTueWedThuFriSat"; static const char * week = "SunMonTueWedThuFriSat";
const char * pos; const char * pos;
/*@-observertrans -mayaliasunique@*/
if (str != NULL && (pos=strstr(week, str)) != NULL) { if (str != NULL && (pos=strstr(week, str)) != NULL) {
/*@=observertrans =mayaliasunique@*/
if (tim != NULL) if (tim != NULL)
tim->tm_wday = (pos - week)/3; tim->tm_wday = (pos - week)/3;
return 1; return 1;
@ -392,15 +356,12 @@ is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
} }
static int static int
is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) is_month (const char * str, struct tm * tim)
/*@modifies *tim @*/
{ {
/*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec"; static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
const char * pos; const char * pos;
/*@-observertrans -mayaliasunique@*/
if (str != NULL && (pos = strstr(month, str)) != NULL) { if (str != NULL && (pos = strstr(month, str)) != NULL) {
/*@=observertrans -mayaliasunique@*/
if (tim != NULL) if (tim != NULL)
tim->tm_mon = (pos - month)/3; tim->tm_mon = (pos - month)/3;
return 1; return 1;
@ -409,8 +370,7 @@ is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
} }
static int static int
is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) is_time (const char * str, struct tm * tim)
/*@modifies *tim @*/
{ {
const char * p, * p2; const char * p, * p2;
@ -428,8 +388,7 @@ is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
return 1; return 1;
} }
static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim) static int is_year(const char * str, struct tm * tim)
/*@modifies *tim @*/
{ {
long year; long year;
@ -461,7 +420,6 @@ static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
static int static int
vfs_parse_filetype (char c) vfs_parse_filetype (char c)
/*@*/
{ {
switch (c) { switch (c) {
case 'd': return S_IFDIR; case 'd': return S_IFDIR;
@ -480,7 +438,6 @@ vfs_parse_filetype (char c)
} }
static int vfs_parse_filemode (const char *p) static int vfs_parse_filemode (const char *p)
/*@*/
{ /* converts rw-rw-rw- into 0666 */ { /* converts rw-rw-rw- into 0666 */
int res = 0; int res = 0;
switch (*(p++)) { switch (*(p++)) {
@ -538,9 +495,7 @@ static int vfs_parse_filemode (const char *p)
return res; return res;
} }
/*@-boundswrite@*/ static int vfs_parse_filedate(int idx, time_t *t)
static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
/*@modifies *t @*/
{ /* This thing parses from idx in columns[] array */ { /* This thing parses from idx in columns[] array */
char *p; char *p;
@ -585,9 +540,7 @@ static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
/* Here just this special case with MM-DD-YY */ /* Here just this special case with MM-DD-YY */
if (is_dos_date(p)){ if (is_dos_date(p)){
/*@-mods@*/
p[2] = p[5] = '-'; p[2] = p[5] = '-';
/*@=mods@*/
memset(d, 0, sizeof(d)); memset(d, 0, sizeof(d));
if (sscanf(p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3){ if (sscanf(p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3){
@ -646,14 +599,11 @@ static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
*t = 0; *t = 0;
return idx; return idx;
} }
/*@=boundswrite@*/
/*@-boundswrite@*/
static int static int
vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st, vfs_parse_ls_lga (char * p, struct stat * st,
/*@out@*/ const char ** filename, const char ** filename,
/*@out@*/ const char ** linkname) const char ** linkname)
/*@modifies *p, *st, *filename, *linkname @*/
{ {
int idx, idx2, num_cols; int idx, idx2, num_cols;
int i; int i;
@ -676,13 +626,11 @@ vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st,
if (strlen (p) <= 8 || p [8] != ']') if (strlen (p) <= 8 || p [8] != ']')
goto error; goto error;
/* Should parse here the Notwell permissions :) */ /* Should parse here the Notwell permissions :) */
/*@-unrecog@*/
if (S_ISDIR (st->st_mode)) if (S_ISDIR (st->st_mode))
st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IXUSR | S_IXGRP | S_IXOTH); st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IXUSR | S_IXGRP | S_IXOTH);
else else
st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR); st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR);
p += 9; p += 9;
/*@=unrecog@*/
} else { } else {
if ((i = vfs_parse_filemode(p)) == -1) if ((i = vfs_parse_filemode(p)) == -1)
goto error; goto error;
@ -846,13 +794,10 @@ error:
} }
#endif #endif
/*@-usereleased@*/
if (p_copy != p) /* Carefull! */ if (p_copy != p) /* Carefull! */
/*@=usereleased@*/
g_free (p_copy); g_free (p_copy);
return 0; return 0;
} }
/*@=boundswrite@*/
typedef enum { typedef enum {
DO_FTP_STAT = 1, DO_FTP_STAT = 1,
@ -864,20 +809,17 @@ typedef enum {
/** /**
*/ */
/*@unchecked@*/
static size_t ftpBufAlloced = 0; static size_t ftpBufAlloced = 0;
/** /**
*/ */
/*@unchecked@*/ static char * ftpBuf = NULL;
static /*@only@*/ char * ftpBuf = NULL;
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
/*@-boundswrite@*/
static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall, static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
/*@out@*/ /*@null@*/ struct stat * st, struct stat * st,
/*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz) char * rlbuf, size_t rlbufsiz)
/*@globals ftpBufAlloced, ftpBuf, /*@globals ftpBufAlloced, ftpBuf,
h_errno, fileSystem, internalState @*/ h_errno, fileSystem, internalState @*/
/*@modifies *st, *rlbuf, ftpBufAlloced, ftpBuf, /*@modifies *st, *rlbuf, ftpBufAlloced, ftpBuf,
@ -910,14 +852,12 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
break; break;
default: default:
urldn = alloca_strdup(url); urldn = alloca_strdup(url);
/*@-branchstate@*/
if ((bn = strrchr(urldn, '/')) == NULL) if ((bn = strrchr(urldn, '/')) == NULL)
return -2; return -2;
else if (bn == path) else if (bn == path)
bn = "."; bn = ".";
else else
*bn++ = '\0'; *bn++ = '\0';
/*@=branchstate@*/
nbn = strlen(bn); nbn = strlen(bn);
rc = ftpChdir(urldn); /* XXX don't care about CWD */ rc = ftpChdir(urldn); /* XXX don't care about CWD */
@ -980,44 +920,44 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
while (*se && *se != '\n') se++; while (*se && *se != '\n') se++;
if (se > s && se[-1] == '\r') se[-1] = '\0'; if (se > s && se[-1] == '\r') se[-1] = '\0';
if (*se == '\0') if (*se == '\0')
/*@innerbreak@*/ break; break;
*se++ = '\0'; *se++ = '\0';
if (!strncmp(s, "total ", sizeof("total ")-1)) if (!strncmp(s, "total ", sizeof("total ")-1))
/*@innercontinue@*/ continue; continue;
o = NULL; o = NULL;
for (bingo = 0, n = se; n >= s; n--) { for (bingo = 0, n = se; n >= s; n--) {
switch (*n) { switch (*n) {
case '\0': case '\0':
oe = ne = n; oe = ne = n;
/*@switchbreak@*/ break; break;
case ' ': case ' ':
if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) { if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) {
while (*(++n) == ' ') while (*(++n) == ' ')
{}; {};
bingo++; bingo++;
/*@switchbreak@*/ break; break;
} }
for (o = n + 1; *o == ' '; o++) for (o = n + 1; *o == ' '; o++)
{}; {};
n -= 3; n -= 3;
ne = n; ne = n;
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
if (bingo) if (bingo)
/*@innerbreak@*/ break; break;
} }
if (nbn != (ne - n)) /* Same name length? */ if (nbn != (ne - n)) /* Same name length? */
/*@innercontinue@*/ continue; continue;
if (strncmp(n, bn, nbn)) /* Same name? */ if (strncmp(n, bn, nbn)) /* Same name? */
/*@innercontinue@*/ continue; continue;
moretodo = 0; moretodo = 0;
/*@innerbreak@*/ break; break;
} }
if (moretodo && se > s) { if (moretodo && se > s) {
@ -1034,7 +974,6 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
if (o && oe) { if (o && oe) {
/* XXX FIXME: symlink, replace urldn/bn from [o,oe) and restart */ /* XXX FIXME: symlink, replace urldn/bn from [o,oe) and restart */
} }
/*@fallthrough@*/
case DO_FTP_LSTAT: case DO_FTP_LSTAT:
if (st == NULL || !(n && ne)) { if (st == NULL || !(n && ne)) {
rc = -1; rc = -1;
@ -1066,11 +1005,9 @@ exit:
(void) ufdClose(fd); (void) ufdClose(fd);
return rc; return rc;
} }
/*@=boundswrite@*/
static const char * statstr(const struct stat * st, static const char * statstr(const struct stat * st,
/*@returned@*/ /*@out@*/ char * buf) char * buf)
/*@modifies *buf @*/
{ {
sprintf(buf, sprintf(buf,
"*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n", "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
@ -1085,13 +1022,10 @@ static const char * statstr(const struct stat * st,
return buf; return buf;
} }
/*@unchecked@*/
static int ftp_st_ino = 0xdead0000; static int ftp_st_ino = 0xdead0000;
/* FIXME: borked for path with trailing '/' */ /* FIXME: borked for path with trailing '/' */
static int ftpStat(const char * path, /*@out@*/ struct stat *st) static int ftpStat(const char * path, struct stat *st)
/*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
/*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{ {
char buf[1024]; char buf[1024];
int rc; int rc;
@ -1105,9 +1039,7 @@ fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
} }
/* FIXME: borked for path with trailing '/' */ /* FIXME: borked for path with trailing '/' */
static int ftpLstat(const char * path, /*@out@*/ struct stat *st) static int ftpLstat(const char * path, struct stat *st)
/*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
/*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
{ {
char buf[1024]; char buf[1024];
int rc; int rc;
@ -1120,9 +1052,7 @@ fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
return rc; return rc;
} }
static int ftpReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz) static int ftpReadlink(const char * path, char * buf, size_t bufsiz)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies *buf, fileSystem, internalState @*/
{ {
int rc; int rc;
rc = ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz); rc = ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
@ -1131,11 +1061,7 @@ fprintf(stderr, "*** ftpReadlink(%s) rc %d\n", path, rc);
return rc; return rc;
} }
/*@-boundswrite@*/
/*@null@*/
static DIR * ftpOpendir(const char * path) static DIR * ftpOpendir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{ {
AVDIR avdir; AVDIR avdir;
struct dirent * dp; struct dirent * dp;
@ -1167,7 +1093,7 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
switch (c) { switch (c) {
case '/': case '/':
sb = se; sb = se;
/*@switchbreak@*/ break; break;
case '\r': case '\r':
if (sb == NULL) { if (sb == NULL) {
for (sb = se; sb > s && sb[-1] != ' '; sb--) for (sb = se; sb > s && sb[-1] != ' '; sb--)
@ -1179,41 +1105,33 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
if (*se == '\n') se++; if (*se == '\n') se++;
sb = NULL; sb = NULL;
s = se; s = se;
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1); nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb); avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (avdir + 1); dp = (struct dirent *) (avdir + 1);
av = (const char **) (dp + 1); av = (const char **) (dp + 1);
dt = (unsigned char *) (av + (ac + 1)); dt = (unsigned char *) (av + (ac + 1));
t = (char *) (dt + ac + 1); t = (char *) (dt + ac + 1);
/*@=abstract@*/
avdir->fd = avmagicdir; avdir->fd = avmagicdir;
/*@-usereleased@*/
avdir->data = (char *) dp; avdir->data = (char *) dp;
/*@=usereleased@*/
avdir->allocation = nb; avdir->allocation = nb;
avdir->size = ac; avdir->size = ac;
avdir->offset = -1; avdir->offset = -1;
avdir->filepos = 0; avdir->filepos = 0;
#if defined(HAVE_PTHREAD_H) #if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon@*/
(void) pthread_mutex_init(&avdir->lock, NULL); (void) pthread_mutex_init(&avdir->lock, NULL);
/*@=moduncon =noeffectuncon@*/
#endif #endif
ac = 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++;
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; sb = NULL;
s = se = ftpBuf; s = se = ftpBuf;
while ((c = *se) != '\0') { while ((c = *se) != '\0') {
@ -1221,40 +1139,36 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
switch (c) { switch (c) {
case '/': case '/':
sb = se; sb = se;
/*@switchbreak@*/ break; break;
case '\r': case '\r':
/*@-dependenttrans@*/
av[ac] = t; av[ac] = t;
/*@=dependenttrans@*/
if (sb == NULL) { if (sb == NULL) {
/*@-unrecog@*/
switch(*s) { switch(*s) {
case 'p': case 'p':
dt[ac] = DT_FIFO; dt[ac] = DT_FIFO;
/*@innerbreak@*/ break; break;
case 'c': case 'c':
dt[ac] = DT_CHR; dt[ac] = DT_CHR;
/*@innerbreak@*/ break; break;
case 'd': case 'd':
dt[ac] = DT_DIR; dt[ac] = DT_DIR;
/*@innerbreak@*/ break; break;
case 'b': case 'b':
dt[ac] = DT_BLK; dt[ac] = DT_BLK;
/*@innerbreak@*/ break; break;
case '-': case '-':
dt[ac] = DT_REG; dt[ac] = DT_REG;
/*@innerbreak@*/ break; break;
case 'l': case 'l':
dt[ac] = DT_LNK; dt[ac] = DT_LNK;
/*@innerbreak@*/ break; break;
case 's': case 's':
dt[ac] = DT_SOCK; dt[ac] = DT_SOCK;
/*@innerbreak@*/ break; break;
default: default:
dt[ac] = DT_UNKNOWN; dt[ac] = DT_UNKNOWN;
/*@innerbreak@*/ break; break;
} }
/*@=unrecog@*/
for (sb = se; sb > s && sb[-1] != ' '; sb--) for (sb = se; sb > s && sb[-1] != ' '; sb--)
{}; {};
} }
@ -1264,18 +1178,15 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
if (*se == '\n') se++; if (*se == '\n') se++;
sb = NULL; sb = NULL;
s = se; s = se;
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
av[ac] = NULL; av[ac] = NULL;
/*@-kepttrans@*/
return (DIR *) avdir; return (DIR *) avdir;
/*@=kepttrans@*/
} }
/*@=boundswrite@*/
int Stat(const char * path, struct stat * st) int Stat(const char * path, struct stat * st)
{ {
@ -1287,23 +1198,22 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpStat(path, st); return ftpStat(path, st);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davStat(path, st); return davStat(path, st);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return stat(path, st); return stat(path, st);
} }
@ -1318,23 +1228,22 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpLstat(path, st); return ftpLstat(path, st);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davLstat(path, st); return davLstat(path, st);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return lstat(path, st); return lstat(path, st);
} }
@ -1347,7 +1256,7 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpReadlink(path, buf, bufsiz); return ftpReadlink(path, buf, bufsiz);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef NOTYET #ifdef NOTYET
@ -1355,21 +1264,19 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
#else #else
return -2; return -2;
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
/*@-compdef@*/ /* FIX: *buf is undefined */ /* FIX: *buf is undefined */
return readlink(path, buf, bufsiz); return readlink(path, buf, bufsiz);
/*@=compdef@*/
} }
int Access(const char * path, int amode) int Access(const char * path, int amode)
@ -1385,14 +1292,13 @@ fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return access(path, amode); return access(path, amode);
} }
@ -1438,7 +1344,7 @@ int Glob_pattern_p (const char * pattern, int quote)
return (0); return (0);
} }
int Glob_error(/*@unused@*/const char * epath, /*@unused@*/ int eerrno) int Glob_error(/*@unused@*/const char * epath, int eerrno)
{ {
return 1; return 1;
} }
@ -1449,34 +1355,29 @@ int Glob(const char *pattern, int flags,
const char * lpath; const char * lpath;
int ut = urlPath(pattern, &lpath); int ut = urlPath(pattern, &lpath);
/*@-castfcnptr@*/
if (_rpmio_debug) if (_rpmio_debug)
fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob); fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
/*@=castfcnptr@*/
switch (ut) { switch (ut) {
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
case URL_IS_FTP: case URL_IS_FTP:
/*@-type@*/
pglob->gl_closedir = (void *) Closedir; pglob->gl_closedir = (void *) Closedir;
pglob->gl_readdir = (void *) Readdir; pglob->gl_readdir = (void *) Readdir;
pglob->gl_opendir = (void *) Opendir; pglob->gl_opendir = (void *) Opendir;
pglob->gl_lstat = Lstat; pglob->gl_lstat = Lstat;
pglob->gl_stat = Stat; pglob->gl_stat = Stat;
/*@=type@*/
flags |= GLOB_ALTDIRFUNC; flags |= GLOB_ALTDIRFUNC;
flags &= ~GLOB_TILDE; flags &= ~GLOB_TILDE;
break; break;
case URL_IS_PATH: case URL_IS_PATH:
pattern = lpath; pattern = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return -2; return -2;
/*@notreached@*/ break; break;
} }
return glob(pattern, flags, errfunc, pglob); return glob(pattern, flags, errfunc, pglob);
} }
@ -1498,27 +1399,24 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
switch (ut) { switch (ut) {
case URL_IS_FTP: case URL_IS_FTP:
return ftpOpendir(path); return ftpOpendir(path);
/*@notreached@*/ break; break;
case URL_IS_HTTPS: case URL_IS_HTTPS:
case URL_IS_HTTP: case URL_IS_HTTP:
#ifdef WITH_NEON #ifdef WITH_NEON
return davOpendir(path); return davOpendir(path);
#endif #endif
/*@notreached@*/ break; break;
case URL_IS_PATH: case URL_IS_PATH:
path = lpath; path = lpath;
/*@fallthrough@*/
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
break; break;
case URL_IS_DASH: case URL_IS_DASH:
case URL_IS_HKP: case URL_IS_HKP:
default: default:
return NULL; return NULL;
/*@notreached@*/ break; break;
} }
/*@-dependenttrans@*/
return opendir(path); return opendir(path);
/*@=dependenttrans@*/
} }
struct dirent * Readdir(DIR * dir) struct dirent * Readdir(DIR * dir)

View File

@ -19,13 +19,9 @@
#endif #endif
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
/*@unchecked@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t rpmsigTbl_lock = PTHREAD_MUTEX_INITIALIZER;
#else #else
/*@unchecked@*/
/*@-type@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/*@=type@*/
#endif #endif
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock); #define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
@ -56,8 +52,8 @@ static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#define DO_LOCK() #define DO_LOCK()
#define DO_UNLOCK() #define DO_UNLOCK()
#define INIT_LOCK() #define INIT_LOCK()
#define ADD_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/ #define ADD_REF(__tbl) (0)
#define SUB_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/ #define SUB_REF(__tbl) (0)
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) #define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
#define CLEANUP_RESET(__execute, __oldtype) #define CLEANUP_RESET(__execute, __oldtype)
@ -72,16 +68,11 @@ static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#include "debug.h" #include "debug.h"
#define _RPMSQ_DEBUG 0 #define _RPMSQ_DEBUG 0
/*@unchecked@*/
int _rpmsq_debug = _RPMSQ_DEBUG; int _rpmsq_debug = _RPMSQ_DEBUG;
/*@unchecked@*/
static struct rpmsqElem rpmsqRock; static struct rpmsqElem rpmsqRock;
/*@-compmempass@*/
/*@unchecked@*/
rpmsq rpmsqQueue = &rpmsqRock; rpmsq rpmsqQueue = &rpmsqRock;
/*@=compmempass@*/
int rpmsqInsert(void * elem, void * prev) int rpmsqInsert(void * elem, void * prev)
{ {
@ -99,9 +90,7 @@ fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
sq->reaped = 0; sq->reaped = 0;
sq->status = 0; sq->status = 0;
sq->reaper = 1; sq->reaper = 1;
/*@-bounds@*/
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
sq->id = ME(); sq->id = ME();
ret = pthread_mutex_init(&sq->mutex, NULL); ret = pthread_mutex_init(&sq->mutex, NULL);
@ -132,11 +121,9 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
ret = pthread_mutex_destroy(&sq->mutex); ret = pthread_mutex_destroy(&sq->mutex);
sq->id = NULL; sq->id = NULL;
/*@-bounds@*/
if (sq->pipes[1]) ret = close(sq->pipes[1]); if (sq->pipes[1]) ret = close(sq->pipes[1]);
if (sq->pipes[0]) ret = close(sq->pipes[0]); if (sq->pipes[0]) ret = close(sq->pipes[0]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
#ifdef NOTYET /* rpmpsmWait debugging message needs */ #ifdef NOTYET /* rpmpsmWait debugging message needs */
sq->reaper = 1; sq->reaper = 1;
sq->status = 0; sq->status = 0;
@ -149,11 +136,8 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
return ret; return ret;
} }
/*@unchecked@*/
sigset_t rpmsqCaught; sigset_t rpmsqCaught;
/*@unchecked@*/
/*@-fullinitblock@*/
static struct rpmsig_s { static struct rpmsig_s {
int signum; int signum;
void (*handler) (int signum, void * info, void * context); void (*handler) (int signum, void * info, void * context);
@ -174,10 +158,9 @@ static struct rpmsig_s {
#define rpmsigTbl_sigpipe (&rpmsigTbl[5]) #define rpmsigTbl_sigpipe (&rpmsigTbl[5])
{ -1, NULL }, { -1, NULL },
}; };
/*@=fullinitblock@*/
void rpmsqAction(int signum, void rpmsqAction(int signum,
/*@unused@*/ void * info, /*@unused@*/ void * context) void * info, void * context)
{ {
int save = errno; int save = errno;
rpmsig tbl; rpmsig tbl;
@ -197,7 +180,7 @@ void rpmsqAction(int signum,
/* XXX errno set to ECHILD/EINVAL/EINTR. */ /* XXX errno set to ECHILD/EINVAL/EINTR. */
if (reaped <= 0) if (reaped <= 0)
/*@innerbreak@*/ break; break;
/* XXX insque(3)/remque(3) are dequeue, not ring. */ /* XXX insque(3)/remque(3) are dequeue, not ring. */
for (sq = rpmsqQueue->q_forw; for (sq = rpmsqQueue->q_forw;
@ -207,7 +190,7 @@ void rpmsqAction(int signum,
int ret; int ret;
if (sq->child != reaped) if (sq->child != reaped)
/*@innercontinue@*/ continue; continue;
sq->reaped = reaped; sq->reaped = reaped;
sq->status = status; sq->status = status;
@ -218,21 +201,19 @@ void rpmsqAction(int signum,
*/ */
ret = pthread_mutex_unlock(&sq->mutex); ret = pthread_mutex_unlock(&sq->mutex);
/*@innerbreak@*/ break; break;
} }
} }
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
break; break;
} }
errno = save; errno = save;
} }
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) int rpmsqEnable(int signum, rpmsqAction_t handler)
/*@globals rpmsigTbl @*/
/*@modifies rpmsigTbl @*/
{ {
int tblsignum = (signum >= 0 ? signum : -signum); int tblsignum = (signum >= 0 ? signum : -signum);
struct sigaction sa; struct sigaction sa;
@ -309,11 +290,9 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
if (!nothreads) { if (!nothreads) {
if(pthread_mutex_lock(&sq->mutex)) { if(pthread_mutex_lock(&sq->mutex)) {
/* Yack we did not get the lock, lets just give up */ /* Yack we did not get the lock, lets just give up */
/*@-bounds@*/
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
goto out; goto out;
} }
} }
@ -321,22 +300,18 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
pid = fork(); pid = fork();
if (pid < (pid_t) 0) { /* fork failed. */ if (pid < (pid_t) 0) { /* fork failed. */
sq->child = (pid_t)-1; sq->child = (pid_t)-1;
/*@-bounds@*/
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
goto out; goto out;
} else if (pid == (pid_t) 0) { /* Child. */ } else if (pid == (pid_t) 0) { /* Child. */
int yy; int yy;
/* Block to permit parent time to wait. */ /* Block to permit parent time to wait. */
/*@-bounds@*/
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
xx = read(sq->pipes[0], &yy, sizeof(yy)); xx = read(sq->pipes[0], &yy, sizeof(yy));
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
#ifdef _RPMSQ_DEBUG #ifdef _RPMSQ_DEBUG
if (_rpmsq_debug) if (_rpmsq_debug)
@ -366,8 +341,6 @@ out:
* @return 0 on success * @return 0 on success
*/ */
static int rpmsqWaitUnregister(rpmsq sq) static int rpmsqWaitUnregister(rpmsq sq)
/*@globals fileSystem, internalState @*/
/*@modifies sq, fileSystem, internalState @*/
{ {
int nothreads = 0; int nothreads = 0;
int ret = 0; int ret = 0;
@ -377,19 +350,16 @@ static int rpmsqWaitUnregister(rpmsq sq)
ret = sighold(SIGCHLD); ret = sighold(SIGCHLD);
/* Start the child, linux often runs child before parent. */ /* Start the child, linux often runs child before parent. */
/*@-bounds@*/
if (sq->pipes[0] >= 0) if (sq->pipes[0] >= 0)
xx = close(sq->pipes[0]); xx = close(sq->pipes[0]);
if (sq->pipes[1] >= 0) if (sq->pipes[1] >= 0)
xx = close(sq->pipes[1]); xx = close(sq->pipes[1]);
sq->pipes[0] = sq->pipes[1] = -1; sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
/* Put a stopwatch on the time spent waiting to measure performance gain. */ /* Put a stopwatch on the time spent waiting to measure performance gain. */
(void) rpmswEnter(&sq->op, -1); (void) rpmswEnter(&sq->op, -1);
/* Wait for handler to receive SIGCHLD. */ /* Wait for handler to receive SIGCHLD. */
/*@-infloops@*/
while (ret == 0 && sq->reaped != sq->child) { while (ret == 0 && sq->reaped != sq->child) {
if (nothreads) if (nothreads)
/* Note that sigpause re-enables SIGCHLD. */ /* Note that sigpause re-enables SIGCHLD. */
@ -406,7 +376,6 @@ static int rpmsqWaitUnregister(rpmsq sq)
xx = sighold(SIGCHLD); xx = sighold(SIGCHLD);
} }
} }
/*@=infloops@*/
/* Accumulate stopwatch time spent waiting, potential performance gain. */ /* Accumulate stopwatch time spent waiting, potential performance gain. */
sq->ms_scriptlets += rpmswExit(&sq->op, -1)/1000; sq->ms_scriptlets += rpmswExit(&sq->op, -1)/1000;
@ -492,8 +461,6 @@ int rpmsqThreadEqual(void * thread)
*/ */
static void static void
sigchld_cancel (void *arg) sigchld_cancel (void *arg)
/*@globals rpmsigTbl, fileSystem, internalState @*/
/*@modifies rpmsigTbl, fileSystem, internalState @*/
{ {
pid_t child = *(pid_t *) arg; pid_t child = *(pid_t *) arg;
pid_t result; pid_t result;
@ -517,8 +484,6 @@ sigchld_cancel (void *arg)
*/ */
int int
rpmsqExecve (const char ** argv) rpmsqExecve (const char ** argv)
/*@globals rpmsigTbl @*/
/*@modifies rpmsigTbl @*/
{ {
int oldtype; int oldtype;
int status = -1; int status = -1;

View File

@ -22,13 +22,9 @@ typedef struct rpmsqElem * rpmsq;
* @param info (siginfo_t) signal info * @param info (siginfo_t) signal info
* @param context signal context * @param context signal context
*/ */
typedef void (*rpmsqAction_t) (int signum, void * info, void * context) typedef void (*rpmsqAction_t) (int signum, void * info, void * context);
/*@*/;
/*@-redecl@*/
/*@unchecked@*/
extern int _rpmsq_debug; extern int _rpmsq_debug;
/*@=redecl@*/
/** /**
* SIGCHLD queue element. * SIGCHLD queue element.
@ -43,18 +39,13 @@ struct rpmsqElem {
rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */ rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */
int reaper; /*!< Register SIGCHLD handler? */ int reaper; /*!< Register SIGCHLD handler? */
int pipes[2]; /*!< Parent/child interlock. */ int pipes[2]; /*!< Parent/child interlock. */
/*@shared@*/
void * id; /*!< Blocking thread id (pthread_t). */ void * id; /*!< Blocking thread id (pthread_t). */
pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */ pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */
pthread_cond_t cond; pthread_cond_t cond;
}; };
/*@-exportlocal@*/
/*@unchecked@*/
extern rpmsq rpmsqQueue; extern rpmsq rpmsqQueue;
/*@=exportlocal@*/
/*@unchecked@*/
extern sigset_t rpmsqCaught; extern sigset_t rpmsqCaught;
#ifdef __cplusplus #ifdef __cplusplus
@ -67,22 +58,14 @@ extern "C" {
* @param prev previous node from queue * @param prev previous node from queue
* @return 0 on success * @return 0 on success
*/ */
/*@-exportlocal@*/ int rpmsqInsert(void * elem, void * prev);
int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
/*@globals systemState @*/
/*@modifies elem, prev, systemState @*/;
/*@=exportlocal@*/
/** /**
* Remove node from queue. * Remove node from queue.
* @param elem node to link * @param elem node to link
* @return 0 on success * @return 0 on success
*/ */
/*@-exportlocal@*/ int rpmsqRemove(void * elem);
int rpmsqRemove(/*@null@*/ void * elem)
/*@globals fileSystem, internalState @*/
/*@modifies elem, fileSystem, internalState @*/;
/*@=exportlocal@*/
/** /**
* Default signal handler. * Default signal handler.
@ -90,11 +73,7 @@ int rpmsqRemove(/*@null@*/ void * elem)
* @param info (siginfo_t) signal info * @param info (siginfo_t) signal info
* @param context signal context * @param context signal context
*/ */
/*@-exportlocal@*/ void rpmsqAction(int signum, void * info, void * context);
void rpmsqAction(int signum, void * info, void * context)
/*@globals rpmsqCaught, rpmsqQueue, errno, fileSystem @*/
/*@modifies rpmsqCaught, rpmsqQueue, errno, fileSystem @*/;
/*@=exportlocal@*/
/** /**
* Enable or disable a signal handler. * Enable or disable a signal handler.
@ -102,27 +81,21 @@ void rpmsqAction(int signum, void * info, void * context)
* @param handler sa_sigaction handler (or NULL to use rpmsqHandler()) * @param handler sa_sigaction handler (or NULL to use rpmsqHandler())
* @return no. of refs, -1 on error * @return no. of refs, -1 on error
*/ */
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler) int rpmsqEnable(int signum, rpmsqAction_t handler);
/*@globals rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/
/*@modifies rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/;
/** /**
* Fork a child process. * Fork a child process.
* @param sq scriptlet queue element * @param sq scriptlet queue element
* @return fork(2) pid * @return fork(2) pid
*/ */
pid_t rpmsqFork(rpmsq sq) pid_t rpmsqFork(rpmsq sq);
/*@globals fileSystem, internalState @*/
/*@modifies sq, fileSystem, internalState @*/;
/** /**
* Wait for child process to be reaped. * Wait for child process to be reaped.
* @param sq scriptlet queue element * @param sq scriptlet queue element
* @return reaped child pid * @return reaped child pid
*/ */
pid_t rpmsqWait(rpmsq sq) pid_t rpmsqWait(rpmsq sq);
/*@globals fileSystem, internalState @*/
/*@modifies sq, fileSystem, internalState @*/;
/** /**
* Call a function in a thread. * Call a function in a thread.
@ -130,34 +103,26 @@ pid_t rpmsqWait(rpmsq sq)
* @param arg function argument * @param arg function argument
* @return thread pointer (NULL on error) * @return thread pointer (NULL on error)
*/ */
void * rpmsqThread(void * (*start) (void * arg), void * arg) void * rpmsqThread(void * (*start) (void * arg), void * arg);
/*@globals internalState @*/
/*@modifies internalState @*/;
/** /**
* Wait for thread to terminate. * Wait for thread to terminate.
* @param thread thread * @param thread thread
* @return 0 on success * @return 0 on success
*/ */
int rpmsqJoin(/*@null@*/ void * thread) int rpmsqJoin(void * thread);
/*@globals internalState @*/
/*@modifies internalState @*/;
/** /**
* Compare thread with current thread. * Compare thread with current thread.
* @param thread thread * @param thread thread
* @return 0 if not equal * @return 0 if not equal
*/ */
int rpmsqThreadEqual(/*@null@*/ void * thread) int rpmsqThreadEqual(void * thread);
/*@globals internalState @*/
/*@modifies internalState @*/;
/** /**
* Execute a command, returning its status. * Execute a command, returning its status.
*/ */
int rpmsqExecve (const char ** argv) int rpmsqExecve (const char ** argv);
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -6,16 +6,12 @@
#include <rpmsw.h> #include <rpmsw.h>
#include "debug.h" #include "debug.h"
/*@unchecked@*/
static rpmtime_t rpmsw_overhead = 0; static rpmtime_t rpmsw_overhead = 0;
/*@unchecked@*/
static rpmtime_t rpmsw_cycles = 1; static rpmtime_t rpmsw_cycles = 1;
/*@unchecked@*/
static int rpmsw_type = 0; static int rpmsw_type = 0;
/*@unchecked@*/
static int rpmsw_initialized = 0; static int rpmsw_initialized = 0;
#if defined(__i386__) #if defined(__i386__)
@ -95,9 +91,8 @@ rpmsw rpmswNow(rpmsw sw)
* @return difference in milli-seconds * @return difference in milli-seconds
*/ */
static inline static inline
rpmtime_t tvsub(/*@null@*/ const struct timeval * etv, rpmtime_t tvsub(const struct timeval * etv,
/*@null@*/ const struct timeval * btv) const struct timeval * btv)
/*@*/
{ {
time_t secs, usecs; time_t secs, usecs;
if (etv == NULL || btv == NULL) return 0; if (etv == NULL || btv == NULL) return 0;
@ -134,8 +129,6 @@ rpmtime_t rpmswDiff(rpmsw end, rpmsw begin)
#if defined(HP_TIMING_NOW) #if defined(HP_TIMING_NOW)
static rpmtime_t rpmswCalibrate(void) static rpmtime_t rpmswCalibrate(void)
/*@globals internalState @*/
/*@modifies internalState @*/
{ {
struct rpmsw_s begin, end; struct rpmsw_s begin, end;
rpmtime_t ticks; rpmtime_t ticks;
@ -143,9 +136,7 @@ static rpmtime_t rpmswCalibrate(void)
int rc; int rc;
int i; int i;
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
/*@=uniondef@*/
req.tv_sec = 0; req.tv_sec = 0;
req.tv_nsec = 20 * 1000 * 1000; req.tv_nsec = 20 * 1000 * 1000;
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
@ -156,9 +147,7 @@ static rpmtime_t rpmswCalibrate(void)
break; break;
req = rem; /* structure assignment */ req = rem; /* structure assignment */
} }
/*@-uniondef@*/
ticks = rpmswDiff(rpmswNow(&end), &begin); ticks = rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
return ticks; return ticks;
} }
@ -194,9 +183,7 @@ rpmtime_t rpmswInit(void)
/* Start wall clock. */ /* Start wall clock. */
rpmsw_type = 0; rpmsw_type = 0;
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
/*@=uniondef@*/
/* Get no. of cycles while doing nanosleep. */ /* Get no. of cycles while doing nanosleep. */
rpmsw_type = 1; rpmsw_type = 1;
@ -207,9 +194,7 @@ rpmtime_t rpmswInit(void)
/* Compute wall clock delta in usecs. */ /* Compute wall clock delta in usecs. */
rpmsw_type = 0; rpmsw_type = 0;
/*@-uniondef@*/
sum_usecs += rpmswDiff(rpmswNow(&end), &begin); sum_usecs += rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
rpmsw_type = 1; rpmsw_type = 1;
/* Compute cycles/usec */ /* Compute cycles/usec */
@ -219,10 +204,8 @@ rpmtime_t rpmswInit(void)
#endif #endif
/* Calculate timing overhead in usecs. */ /* Calculate timing overhead in usecs. */
/*@-uniondef@*/
(void) rpmswNow(&begin); (void) rpmswNow(&begin);
sum_overhead += rpmswDiff(rpmswNow(&end), &begin); sum_overhead += rpmswDiff(rpmswNow(&end), &begin);
/*@=uniondef@*/
rpmsw_overhead = sum_overhead/(i+1); rpmsw_overhead = sum_overhead/(i+1);
@ -241,9 +224,7 @@ int rpmswEnter(rpmop op, ssize_t rc)
op->bytes = 0; op->bytes = 0;
op->usecs = 0; op->usecs = 0;
} }
/*@-uniondef@*/
(void) rpmswNow(&op->begin); (void) rpmswNow(&op->begin);
/*@=uniondef@*/
return 0; return 0;
} }
@ -254,9 +235,7 @@ rpmtime_t rpmswExit(rpmop op, ssize_t rc)
if (op == NULL) if (op == NULL)
return 0; return 0;
/*@-uniondef@*/
op->usecs += rpmswDiff(rpmswNow(&end), &op->begin); op->usecs += rpmswDiff(rpmswNow(&end), &op->begin);
/*@=uniondef@*/
if (rc > 0) if (rc > 0)
op->bytes += rc; op->bytes += rc;
op->begin = end; /* structure assignment */ op->begin = end; /* structure assignment */

View File

@ -45,31 +45,19 @@ extern "C" {
* @param *sw time stamp * @param *sw time stamp
* @return 0 on success * @return 0 on success
*/ */
/*@-exportlocal@*/ rpmsw rpmswNow(rpmsw sw);
/*@null@*/
rpmsw rpmswNow(/*@returned@*/ rpmsw sw)
/*@globals internalState @*/
/*@modifies sw, internalState @*/;
/*@=exportlocal@*/
/** Return benchmark time stamp difference. /** Return benchmark time stamp difference.
* @param *end end time stamp * @param *end end time stamp
* @param *begin begin time stamp * @param *begin begin time stamp
* @return difference in micro-seconds * @return difference in micro-seconds
*/ */
/*@-exportlocal@*/ rpmtime_t rpmswDiff(rpmsw end, rpmsw begin);
rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
/*@*/;
/*@=exportlocal@*/
/** Return benchmark time stamp overhead. /** Return benchmark time stamp overhead.
* @return overhead in micro-seconds * @return overhead in micro-seconds
*/ */
/*@-exportlocal@*/ rpmtime_t rpmswInit(void);
rpmtime_t rpmswInit(void)
/*@globals internalState @*/
/*@modifies internalState @*/;
/*@=exportlocal@*/
/** \ingroup rpmio /** \ingroup rpmio
* Enter timed operation. * Enter timed operation.
@ -77,9 +65,7 @@ rpmtime_t rpmswInit(void)
* @param rc -1 clears usec counter * @param rc -1 clears usec counter
* @return 0 always * @return 0 always
*/ */
int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc) int rpmswEnter(rpmop op, ssize_t rc);
/*@globals internalState @*/
/*@modifies *op, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
* Exit timed operation. * Exit timed operation.
@ -87,9 +73,7 @@ int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc)
* @param rc per-operation data (e.g. bytes transferred) * @param rc per-operation data (e.g. bytes transferred)
* @return cumulative usecs for operation * @return cumulative usecs for operation
*/ */
rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc) rpmtime_t rpmswExit(rpmop op, ssize_t rc);
/*@globals internalState @*/
/*@modifies op, internalState @*/;
/** \ingroup rpmio /** \ingroup rpmio
* Sum statistic counters. * Sum statistic counters.
@ -97,8 +81,7 @@ rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc)
* @param from operation statistics * @param from operation statistics
* @return cumulative usecs for operation * @return cumulative usecs for operation
*/ */
rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from) rpmtime_t rpmswAdd(rpmop to, rpmop from);
/*@modifies to @*/;
/** \ingroup rpmio /** \ingroup rpmio
* Subtract statistic counters. * Subtract statistic counters.
@ -106,8 +89,7 @@ rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from)
* @param from operation statistics * @param from operation statistics
* @return cumulative usecs for operation * @return cumulative usecs for operation
*/ */
rpmtime_t rpmswSub(rpmop to, rpmop from) rpmtime_t rpmswSub(rpmop to, rpmop from);
/*@modifies to @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -23,28 +23,20 @@ typedef enum urltype_e {
#define URLMAGIC 0xd00b1ed0 #define URLMAGIC 0xd00b1ed0
#define URLSANE(u) assert(u && u->magic == URLMAGIC) #define URLSANE(u) assert(u && u->magic == URLMAGIC)
typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo; typedef struct urlinfo_s * urlinfo;
/** /**
* URL control structure. * URL control structure.
*/ */
struct urlinfo_s { struct urlinfo_s {
/*@refs@*/ int nrefs; /*!< no. of references */ int nrefs; /*!< no. of references */
/*@owned@*/ /*@relnull@*/
const char * url; /*!< copy of original url */ const char * url; /*!< copy of original url */
/*@owned@*/ /*@relnull@*/
const char * scheme; /*!< URI scheme. */ const char * scheme; /*!< URI scheme. */
/*@owned@*/ /*@null@*/
const char * user; /*!< URI user. */ const char * user; /*!< URI user. */
/*@owned@*/ /*@null@*/
const char * password; /*!< URI password. */ const char * password; /*!< URI password. */
/*@owned@*/ /*@relnull@*/
const char * host; /*!< URI host. */ const char * host; /*!< URI host. */
/*@owned@*/ /*@null@*/
const char * portstr; /*!< URI port string. */ const char * portstr; /*!< URI port string. */
/*@owned@*/ /*@null@*/
const char * proxyu; /*!< FTP: proxy user */ const char * proxyu; /*!< FTP: proxy user */
/*@owned@*/ /*@null@*/
const char * proxyh; /*!< FTP/HTTP: proxy host */ const char * proxyh; /*!< FTP/HTTP: proxy host */
int proxyp; /*!< FTP/HTTP: proxy port */ int proxyp; /*!< FTP/HTTP: proxy port */
int port; /*!< URI port. */ int port; /*!< URI port. */
@ -52,11 +44,8 @@ struct urlinfo_s {
FD_t ctrl; /*!< control channel */ FD_t ctrl; /*!< control channel */
FD_t data; /*!< per-xfer data channel */ FD_t data; /*!< per-xfer data channel */
/*@relnull@*/
void * capabilities; /*!< neon: ne_server_capabilities ptr */ void * capabilities; /*!< neon: ne_server_capabilities ptr */
/*@relnull@*/
void * lockstore; /*!< neon: ne_lock_store ptr */ void * lockstore; /*!< neon: ne_lock_store ptr */
/*@relnull@*/
void * sess; /*!< neon: ne_session ptr */ void * sess; /*!< neon: ne_session ptr */
off_t current; /*!< neon: current body offset. */ off_t current; /*!< neon: current body offset. */
off_t total; /*!< neon: total body length. */ off_t total; /*!< neon: total body length. */
@ -71,7 +60,6 @@ typedef enum {
#endif #endif
int bufAlloced; /*!< sizeof I/O buffer */ int bufAlloced; /*!< sizeof I/O buffer */
/*@owned@*/
char * buf; /*!< I/O buffer */ char * buf; /*!< I/O buffer */
int openError; /*!< Type of open failure */ int openError; /*!< Type of open failure */
int httpVersion; int httpVersion;
@ -83,18 +71,13 @@ typedef enum {
extern "C" { extern "C" {
#endif #endif
/*@unchecked@*/
extern int _url_count; /*!< No. of cached URL's. */ extern int _url_count; /*!< No. of cached URL's. */
/*@unchecked@*/
/*@only@*/ /*@null@*/
extern urlinfo * _url_cache; /*!< URL cache. */ extern urlinfo * _url_cache; /*!< URL cache. */
/*@unchecked@*/
extern int _url_iobuf_size; /*!< Initial size of URL I/O buffer. */ extern int _url_iobuf_size; /*!< Initial size of URL I/O buffer. */
#define RPMURL_IOBUF_SIZE 4096 #define RPMURL_IOBUF_SIZE 4096
/*@unchecked@*/
extern int _url_debug; /*!< URL debugging? */ extern int _url_debug; /*!< URL debugging? */
#define RPMURL_DEBUG_IO 0x40000000 #define RPMURL_DEBUG_IO 0x40000000
#define RPMURL_DEBUG_REFS 0x20000000 #define RPMURL_DEBUG_REFS 0x20000000
@ -105,10 +88,10 @@ extern int _url_debug; /*!< URL debugging? */
* @param msg debugging identifier (unused) * @param msg debugging identifier (unused)
* @return new instance * @return new instance
*/ */
/*@unused@*/ urlinfo urlNew(const char * msg) /*@*/; urlinfo urlNew(const char * msg) ;
/** @todo Remove debugging entry from the ABI. */ /** @todo Remove debugging entry from the ABI. */
urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/; urlinfo XurlNew(const char * msg, const char * file, unsigned line) ;
#define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__) #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
/** /**
@ -117,12 +100,10 @@ urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/;
* @param msg debugging identifier (unused) * @param msg debugging identifier (unused)
* @return referenced instance * @return referenced instance
*/ */
/*@unused@*/ urlinfo urlLink(urlinfo u, const char * msg) urlinfo urlLink(urlinfo u, const char * msg);
/*@modifies u @*/;
/** @todo Remove debugging entry from the ABI. */ /** @todo Remove debugging entry from the ABI. */
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line) urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line);
/*@modifies u @*/;
#define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__) #define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
/** /**
@ -131,31 +112,24 @@ urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
* @param msg debugging identifier (unused) * @param msg debugging identifier (unused)
* @return dereferenced instance (NULL if freed) * @return dereferenced instance (NULL if freed)
*/ */
/*@unused@*/ urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg) urlinfo urlFree( urlinfo u, const char * msg);
/*@globals fileSystem, internalState @*/
/*@modifies u, fileSystem, internalState @*/;
/** @todo Remove debugging entry from the ABI. */ /** @todo Remove debugging entry from the ABI. */
urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg, urlinfo XurlFree( urlinfo u, const char * msg,
const char * file, unsigned line) const char * file, unsigned line);
/*@globals fileSystem, internalState @*/
/*@modifies u, fileSystem, internalState @*/;
#define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__) #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
/** /**
* Free cached URL control structures. * Free cached URL control structures.
*/ */
void urlFreeCache(void) void urlFreeCache(void);
/*@globals _url_cache, _url_count, fileSystem, internalState @*/
/*@modifies _url_cache, _url_count, fileSystem, internalState @*/;
/** /**
* Return type of URL. * Return type of URL.
* @param url url string * @param url url string
* @return type of url * @return type of url
*/ */
urltype urlIsURL(const char * url) urltype urlIsURL(const char * url);
/*@*/;
/** /**
* Return path component of URL. * Return path component of URL.
@ -163,11 +137,7 @@ urltype urlIsURL(const char * url)
* @retval pathp pointer to path component of url * @retval pathp pointer to path component of url
* @return type of url * @return type of url
*/ */
/*@-incondefs@*/ urltype urlPath(const char * url, const char ** pathp);
urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
/*@ensures maxSet(*pathp) == 0 /\ maxRead(*pathp) == 0 @*/
/*@modifies *pathp @*/;
/*@=incondefs@*/
/** /**
* Parse URL string into a control structure. * Parse URL string into a control structure.
@ -175,9 +145,7 @@ urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
* @retval uret address of new control instance pointer * @retval uret address of new control instance pointer
* @return 0 on success, -1 on error * @return 0 on success, -1 on error
*/ */
int urlSplit(const char * url, /*@out@*/ urlinfo * uret) int urlSplit(const char * url, urlinfo * uret);
/*@globals h_errno, internalState @*/
/*@modifies *uret, internalState @*/;
/** /**
* Copy data from URL to local file. * Copy data from URL to local file.
@ -185,9 +153,7 @@ int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
* @param dest file name of destination * @param dest file name of destination
* @return 0 on success, otherwise FTPERR_* code * @return 0 on success, otherwise FTPERR_* code
*/ */
int urlGetFile(const char * url, /*@null@*/ const char * dest) int urlGetFile(const char * url, const char * dest);
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -17,10 +17,8 @@ int xstrcasecmp(const char * s1, const char * s2)
do do
{ {
/*@-boundsread@*/
c1 = xtolower (*p1++); c1 = xtolower (*p1++);
c2 = xtolower (*p2++); c2 = xtolower (*p2++);
/*@=boundsread@*/
if (c1 == '\0') if (c1 == '\0')
break; break;
} }
@ -40,10 +38,8 @@ int xstrncasecmp(const char *s1, const char *s2, size_t n)
do do
{ {
/*@-boundsread@*/
c1 = xtolower (*p1++); c1 = xtolower (*p1++);
c2 = xtolower (*p2++); c2 = xtolower (*p2++);
/*@=boundsread@*/
if (c1 == '\0' || c1 != c2) if (c1 == '\0' || c1 != c2)
break; break;
} while (--n > 0); } while (--n > 0);

View File

@ -40,12 +40,10 @@ AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM\
* @param nbytes no. of bytes * @param nbytes no. of bytes
* @return target buffer * @return target buffer
*/ */
/*@unused@*/ static inline static inline
char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes) char * pgpHexCvt(char *t, const byte *s, int nbytes)
/*@modifies *t @*/
{ {
static char hex[] = "0123456789abcdef"; static char hex[] = "0123456789abcdef";
/*@-boundswrite@*/
while (nbytes-- > 0) { while (nbytes-- > 0) {
unsigned int i; unsigned int i;
i = *s++; i = *s++;
@ -53,7 +51,6 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
*t++ = hex[ (i ) & 0xf ]; *t++ = hex[ (i ) & 0xf ];
} }
*t = '\0'; *t = '\0';
/*@=boundswrite@*/
return t; return t;
} }
@ -64,9 +61,8 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
* @param plen no. of bytes * @param plen no. of bytes
* @return hex formatted string * @return hex formatted string
*/ */
/*@unused@*/ static inline /*@observer@*/ static inline
char * pgpHexStr(const byte *p, unsigned int plen) char * pgpHexStr(const byte *p, unsigned int plen)
/*@*/
{ {
static char prbuf[2048]; static char prbuf[2048];
char *t = prbuf; char *t = prbuf;

View File

@ -60,9 +60,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
@ -78,7 +78,7 @@ _dav_debug = -1;
printDir(ftppath); printDir(ftppath);
printDir(httppath); printDir(httppath);
/*@i@*/ urlFreeCache(); urlFreeCache();
return 0; return 0;
} }

View File

@ -8,7 +8,6 @@
#include "debug.h" #include "debug.h"
/*@unchecked@*/
static int _fts_debug = 0; static int _fts_debug = 0;
#if 0 #if 0
@ -153,9 +152,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
@ -174,7 +173,7 @@ _dav_debug = 1;
ftsWalk(httpspath); ftsWalk(httpspath);
#endif #endif
/*@i@*/ urlFreeCache(); urlFreeCache();
return 0; return 0;
} }

View File

@ -61,9 +61,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
@ -94,7 +94,7 @@ _dav_debug = 1;
readFile(httpspath); readFile(httpspath);
#endif #endif
/*@i@*/ urlFreeCache(); urlFreeCache();
return 0; return 0;
} }

View File

@ -75,9 +75,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }

View File

@ -116,9 +116,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
@ -129,7 +129,7 @@ main(int argc, const char *argv[])
readKeys(hkppath); readKeys(hkppath);
/*@i@*/ urlFreeCache(); urlFreeCache();
return 0; return 0;
} }

View File

@ -104,10 +104,8 @@ fprintf(stderr, " D: "), mpfprintln(stderr, ysize, D);
if (result) { if (result) {
mpsetx(b->size, result, ysize, A); mpsetx(b->size, result, ysize, A);
/*@-usedef@*/
if (*A & 0x80000000) if (*A & 0x80000000)
(void) mpneg(b->size, result); (void) mpneg(b->size, result);
/*@=usedef@*/
while (--k > 0) while (--k > 0)
mpadd(b->size, result, result); mpadd(b->size, result, result);
} }
@ -397,10 +395,8 @@ fprintf(stderr, " D: "), mpfprintln(stderr, ysize, D);
if (result) if (result)
{ {
mpsetx(b->size, result, ysize, D); mpsetx(b->size, result, ysize, D);
/*@-usedef@*/
if (*D & 0x80000000) if (*D & 0x80000000)
(void) mpadd(b->size, result, b->modl); (void) mpadd(b->size, result, b->modl);
/*@=usedef@*/
} }
fprintf(stderr, "=== EXIT: "), mpfprintln(stderr, b->size, result); fprintf(stderr, "=== EXIT: "), mpfprintln(stderr, b->size, result);
@ -477,7 +473,7 @@ main(int argc, const char * argv[])
while ((rc = poptGetNextOpt(optCon)) > 0) { while ((rc = poptGetNextOpt(optCon)) > 0) {
switch (rc) { switch (rc) {
default: default:
/*@switchbreak@*/ break; break;
} }
} }

View File

@ -121,9 +121,9 @@ main(int argc, const char *argv[])
switch (rc) { switch (rc) {
case 'v': case 'v':
rpmIncreaseVerbosity(); rpmIncreaseVerbosity();
/*@switchbreak@*/ break; break;
default: default:
/*@switchbreak@*/ break; break;
} }
} }
@ -144,7 +144,7 @@ _dav_debug = -1;
doFile(httpspath); doFile(httpspath);
#endif #endif
/*@i@*/ urlFreeCache(); urlFreeCache();
return 0; return 0;
} }

View File

@ -35,8 +35,7 @@ main (int argc, const char *argv[])
const char * fn; const char * fn;
int rc, ec = 0; int rc, ec = 0;
while ((rc = poptGetNextOpt(optCon)) > 0) while ((rc = poptGetNextOpt(optCon)) > 0);
;
if ((args = poptGetArgs(optCon)) != NULL) if ((args = poptGetArgs(optCon)) != NULL)
while ((fn = *args++) != NULL) { while ((fn = *args++) != NULL) {

View File

@ -15,7 +15,7 @@
int unameToUid(const char * thisUname, uid_t * uid) int unameToUid(const char * thisUname, uid_t * uid)
{ {
/*@only@*/ static char * lastUname = NULL; static char * lastUname = NULL;
static size_t lastUnameLen = 0; static size_t lastUnameLen = 0;
static size_t lastUnameAlloced; static size_t lastUnameAlloced;
static uid_t lastUid; static uid_t lastUid;
@ -26,9 +26,7 @@ int unameToUid(const char * thisUname, uid_t * uid)
lastUnameLen = 0; lastUnameLen = 0;
return -1; return -1;
} else if (strcmp(thisUname, "root") == 0) { } else if (strcmp(thisUname, "root") == 0) {
/*@-boundswrite@*/
*uid = 0; *uid = 0;
/*@=boundswrite@*/
return 0; return 0;
} }
@ -40,15 +38,12 @@ int unameToUid(const char * thisUname, uid_t * uid)
lastUnameAlloced = thisUnameLen + 10; lastUnameAlloced = thisUnameLen + 10;
lastUname = xrealloc(lastUname, lastUnameAlloced); /* XXX memory leak */ lastUname = xrealloc(lastUname, lastUnameAlloced); /* XXX memory leak */
} }
/*@-boundswrite@*/
strcpy(lastUname, thisUname); strcpy(lastUname, thisUname);
/*@=boundswrite@*/
pwent = getpwnam(thisUname); pwent = getpwnam(thisUname);
if (pwent == NULL) { if (pwent == NULL) {
/*@-internalglobs@*/ /* FIX: shrug */ /* FIX: shrug */
endpwent(); endpwent();
/*@=internalglobs@*/
pwent = getpwnam(thisUname); pwent = getpwnam(thisUname);
if (pwent == NULL) return -1; if (pwent == NULL) return -1;
} }
@ -56,16 +51,14 @@ int unameToUid(const char * thisUname, uid_t * uid)
lastUid = pwent->pw_uid; lastUid = pwent->pw_uid;
} }
/*@-boundswrite@*/
*uid = lastUid; *uid = lastUid;
/*@=boundswrite@*/
return 0; return 0;
} }
int gnameToGid(const char * thisGname, gid_t * gid) int gnameToGid(const char * thisGname, gid_t * gid)
{ {
/*@only@*/ static char * lastGname = NULL; static char * lastGname = NULL;
static size_t lastGnameLen = 0; static size_t lastGnameLen = 0;
static size_t lastGnameAlloced; static size_t lastGnameAlloced;
static gid_t lastGid; static gid_t lastGid;
@ -76,9 +69,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
lastGnameLen = 0; lastGnameLen = 0;
return -1; return -1;
} else if (strcmp(thisGname, "root") == 0) { } else if (strcmp(thisGname, "root") == 0) {
/*@-boundswrite@*/
*gid = 0; *gid = 0;
/*@=boundswrite@*/
return 0; return 0;
} }
@ -90,28 +81,21 @@ int gnameToGid(const char * thisGname, gid_t * gid)
lastGnameAlloced = thisGnameLen + 10; lastGnameAlloced = thisGnameLen + 10;
lastGname = xrealloc(lastGname, lastGnameAlloced); /* XXX memory leak */ lastGname = xrealloc(lastGname, lastGnameAlloced); /* XXX memory leak */
} }
/*@-boundswrite@*/
strcpy(lastGname, thisGname); strcpy(lastGname, thisGname);
/*@=boundswrite@*/
grent = getgrnam(thisGname); grent = getgrnam(thisGname);
if (grent == NULL) { if (grent == NULL) {
/*@-internalglobs@*/ /* FIX: shrug */ /* FIX: shrug */
endgrent(); endgrent();
/*@=internalglobs@*/
grent = getgrnam(thisGname); grent = getgrnam(thisGname);
if (grent == NULL) { if (grent == NULL) {
/* XXX The filesystem package needs group/lock w/o getgrnam. */ /* XXX The filesystem package needs group/lock w/o getgrnam. */
if (strcmp(thisGname, "lock") == 0) { if (strcmp(thisGname, "lock") == 0) {
/*@-boundswrite@*/
*gid = lastGid = 54; *gid = lastGid = 54;
/*@=boundswrite@*/
return 0; return 0;
} else } else
if (strcmp(thisGname, "mail") == 0) { if (strcmp(thisGname, "mail") == 0) {
/*@-boundswrite@*/
*gid = lastGid = 12; *gid = lastGid = 12;
/*@=boundswrite@*/
return 0; return 0;
} else } else
return -1; return -1;
@ -120,9 +104,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
lastGid = grent->gr_gid; lastGid = grent->gr_gid;
} }
/*@-boundswrite@*/
*gid = lastGid; *gid = lastGid;
/*@=boundswrite@*/
return 0; return 0;
} }
@ -130,7 +112,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
char * uidToUname(uid_t uid) char * uidToUname(uid_t uid)
{ {
static uid_t lastUid = (uid_t) -1; static uid_t lastUid = (uid_t) -1;
/*@only@*/ static char * lastUname = NULL; static char * lastUname = NULL;
static size_t lastUnameLen = 0; static size_t lastUnameLen = 0;
if (uid == (uid_t) -1) { if (uid == (uid_t) -1) {
@ -152,9 +134,7 @@ char * uidToUname(uid_t uid)
lastUnameLen = len + 20; lastUnameLen = len + 20;
lastUname = xrealloc(lastUname, lastUnameLen); lastUname = xrealloc(lastUname, lastUnameLen);
} }
/*@-boundswrite@*/
strcpy(lastUname, pwent->pw_name); strcpy(lastUname, pwent->pw_name);
/*@=boundswrite@*/
return lastUname; return lastUname;
} }
@ -163,7 +143,7 @@ char * uidToUname(uid_t uid)
char * gidToGname(gid_t gid) char * gidToGname(gid_t gid)
{ {
static gid_t lastGid = (gid_t) -1; static gid_t lastGid = (gid_t) -1;
/*@only@*/ static char * lastGname = NULL; static char * lastGname = NULL;
static size_t lastGnameLen = 0; static size_t lastGnameLen = 0;
if (gid == (gid_t) -1) { if (gid == (gid_t) -1) {
@ -185,9 +165,7 @@ char * gidToGname(gid_t gid)
lastGnameLen = len + 20; lastGnameLen = len + 20;
lastGname = xrealloc(lastGname, lastGnameLen); lastGname = xrealloc(lastGname, lastGnameLen);
} }
/*@-boundswrite@*/
strcpy(lastGname, grent->gr_name); strcpy(lastGname, grent->gr_name);
/*@=boundswrite@*/
return lastGname; return lastGname;
} }

View File

@ -13,19 +13,14 @@ extern "C" {
* These may be called w/ a NULL argument to flush the cache -- they return * These may be called w/ a NULL argument to flush the cache -- they return
* -1 if the user can't be found. * -1 if the user can't be found.
*/ */
int unameToUid(const char * thisUname, /*@out@*/ uid_t * uid) int unameToUid(const char * thisUname, uid_t * uid);
/*@modifies *uid @*/; int gnameToGid(const char * thisGname, gid_t * gid);
int gnameToGid(const char * thisGname, /*@out@*/ gid_t * gid)
/*@modifies *gid @*/;
/* /*
* Call w/ -1 to flush the cache, returns NULL if the user can't be found. * Call w/ -1 to flush the cache, returns NULL if the user can't be found.
*/ */
/*@observer@*/ /*@null@*/ char * uidToUname(uid_t uid) char * uidToUname(uid_t uid);
/*@*/; char * gidToGname(gid_t gid);
/*@unused@*/
/*@observer@*/ /*@null@*/ char * gidToGname(gid_t gid)
/*@*/;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -13,7 +13,6 @@
#include "debug.h" #include "debug.h"
/*@access FD_t@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */
/*@access urlinfo@*/
#ifndef IPPORT_FTP #ifndef IPPORT_FTP
#define IPPORT_FTP 21 #define IPPORT_FTP 21
@ -30,12 +29,10 @@
/** /**
*/ */
/*@unchecked@*/
int _url_iobuf_size = RPMURL_IOBUF_SIZE; int _url_iobuf_size = RPMURL_IOBUF_SIZE;
/** /**
*/ */
/*@unchecked@*/
int _url_debug = 0; int _url_debug = 0;
#define URLDBG(_f, _m, _x) if ((_url_debug | (_f)) & (_m)) fprintf _x #define URLDBG(_f, _m, _x) if ((_url_debug | (_f)) & (_m)) fprintf _x
@ -45,13 +42,10 @@ int _url_debug = 0;
/** /**
*/ */
/*@unchecked@*/
/*@only@*/ /*@null@*/
urlinfo *_url_cache = NULL; urlinfo *_url_cache = NULL;
/** /**
*/ */
/*@unchecked@*/
int _url_count = 0; int _url_count = 0;
/** /**
@ -59,8 +53,8 @@ int _url_count = 0;
* @param p memory to free * @param p memory to free
* @retval NULL always * @retval NULL always
*/ */
/*@unused@*/ static inline /*@null@*/ void * static inline void *
_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ _free(const void * p)
{ {
if (p != NULL) free((void *)p); if (p != NULL) free((void *)p);
return NULL; return NULL;
@ -70,10 +64,8 @@ urlinfo XurlLink(urlinfo u, const char *msg, const char *file, unsigned line)
{ {
URLSANE(u); URLSANE(u);
u->nrefs++; u->nrefs++;
/*@-modfilesys@*/
URLDBGREFS(0, (stderr, "--> url %p ++ %d %s at %s:%u\n", u, u->nrefs, msg, file, line)); URLDBGREFS(0, (stderr, "--> url %p ++ %d %s at %s:%u\n", u, u->nrefs, msg, file, line));
/*@=modfilesys@*/ return u;
/*@-refcounttrans@*/ return u; /*@=refcounttrans@*/
} }
urlinfo XurlNew(const char *msg, const char *file, unsigned line) urlinfo XurlNew(const char *msg, const char *file, unsigned line)
@ -103,28 +95,24 @@ urlinfo XurlFree(urlinfo u, const char *msg, const char *file, unsigned line)
URLSANE(u); URLSANE(u);
URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, line)); URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, line));
if (--u->nrefs > 0) if (--u->nrefs > 0)
/*@-refcounttrans -retalias@*/ return u; /*@=refcounttrans =retalias@*/ return u;
if (u->ctrl) { if (u->ctrl) {
#ifndef NOTYET #ifndef NOTYET
void * fp = fdGetFp(u->ctrl); void * fp = fdGetFp(u->ctrl);
/*@-branchstate@*/
if (fp) { if (fp) {
fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */ fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */
(void) Fclose(u->ctrl); (void) Fclose(u->ctrl);
} else if (fdio->_fileno(u->ctrl) >= 0) } else if (fdio->_fileno(u->ctrl) >= 0)
xx = fdio->close(u->ctrl); xx = fdio->close(u->ctrl);
/*@=branchstate@*/
#else #else
(void) Fclose(u->ctrl); (void) Fclose(u->ctrl);
#endif #endif
u->ctrl = fdio->_fdderef(u->ctrl, "persist ctrl (urlFree)", file, line); u->ctrl = fdio->_fdderef(u->ctrl, "persist ctrl (urlFree)", file, line);
/*@-usereleased@*/
if (u->ctrl) if (u->ctrl)
fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"), fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"),
u, u->ctrl, (u->host ? u->host : ""), u, u->ctrl, (u->host ? u->host : ""),
(u->scheme ? u->scheme : "")); (u->scheme ? u->scheme : ""));
/*@=usereleased@*/
} }
if (u->data) { if (u->data) {
#ifndef NOTYET #ifndef NOTYET
@ -139,12 +127,10 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
#endif #endif
u->data = fdio->_fdderef(u->data, "persist data (urlFree)", file, line); u->data = fdio->_fdderef(u->data, "persist data (urlFree)", file, line);
/*@-usereleased@*/
if (u->data) if (u->data)
fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"), fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"),
u, u->data, (u->host ? u->host : ""), u, u->data, (u->host ? u->host : ""),
(u->scheme ? u->scheme : "")); (u->scheme ? u->scheme : ""));
/*@=usereleased@*/
} }
if (u->sess != NULL) { if (u->sess != NULL) {
#ifdef WITH_NEON #ifdef WITH_NEON
@ -163,11 +149,10 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
u->proxyu = _free((void *)u->proxyu); u->proxyu = _free((void *)u->proxyu);
u->proxyh = _free((void *)u->proxyh); u->proxyh = _free((void *)u->proxyh);
/*@-refcounttrans@*/ u = _free(u); /*@-refcounttrans@*/ u = _free(u);
return NULL; return NULL;
} }
/*@-boundswrite@*/
void urlFreeCache(void) void urlFreeCache(void)
{ {
if (_url_cache) { if (_url_cache) {
@ -186,10 +171,8 @@ void urlFreeCache(void)
_url_cache = _free(_url_cache); _url_cache = _free(_url_cache);
_url_count = 0; _url_count = 0;
} }
/*@=boundswrite@*/
static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2) static int urlStrcmp(const char * str1, const char * str2)
/*@*/
{ {
if (str1) if (str1)
if (str2) if (str2)
@ -199,11 +182,7 @@ static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2)
return 0; return 0;
} }
/*@-boundswrite@*/ static void urlFind(urlinfo * uret, int mustAsk)
/*@-mods@*/
static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies *uret, rpmGlobalMacroContext, fileSystem, internalState @*/
{ {
urlinfo u; urlinfo u;
int ucx; int ucx;
@ -257,9 +236,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
if (_url_cache) /* XXX always true */ if (_url_cache) /* XXX always true */
u = urlLink(_url_cache[ucx], "_url_cache"); u = urlLink(_url_cache[ucx], "_url_cache");
*uret = u; *uret = u;
/*@-usereleased@*/
u = urlFree(u, "_url_cache (urlFind)"); u = urlFree(u, "_url_cache (urlFind)");
/*@=usereleased@*/
/* Zap proxy host and port in case they have been reset */ /* Zap proxy host and port in case they have been reset */
u->proxyp = -1; u->proxyp = -1;
@ -275,9 +252,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
prompt = alloca(strlen(host) + strlen(user) + 256); prompt = alloca(strlen(host) + strlen(user) + 256);
sprintf(prompt, _("Password for %s@%s: "), user, host); sprintf(prompt, _("Password for %s@%s: "), user, host);
u->password = _free(u->password); u->password = _free(u->password);
/*@-dependenttrans -moduncon @*/ u->password = getpass(prompt);
u->password = /*@-unrecog@*/ getpass(prompt) /*@=unrecog@*/;
/*@=dependenttrans =moduncon @*/
if (u->password) if (u->password)
u->password = xstrdup(u->password); u->password = xstrdup(u->password);
} }
@ -285,7 +260,6 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
if (u->proxyh == NULL) { if (u->proxyh == NULL) {
const char *proxy = rpmExpand("%{_ftpproxy}", NULL); const char *proxy = rpmExpand("%{_ftpproxy}", NULL);
if (proxy && *proxy != '%') { if (proxy && *proxy != '%') {
/*@observer@*/
const char * host = (u->host ? u->host : ""); const char * host = (u->host ? u->host : "");
const char *uu = (u->user ? u->user : "anonymous"); const char *uu = (u->user ? u->user : "anonymous");
char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(host)); char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(host));
@ -341,14 +315,10 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
return; return;
} }
/*@=mods@*/
/*@=boundswrite@*/
/** /**
*/ */
/*@observer@*/ /*@unchecked@*/
static struct urlstring { static struct urlstring {
/*@observer@*/ /*@null@*/
const char * leadin; const char * leadin;
urltype ret; urltype ret;
} urlstrings[] = { } urlstrings[] = {
@ -365,7 +335,6 @@ urltype urlIsURL(const char * url)
{ {
struct urlstring *us; struct urlstring *us;
/*@-boundsread@*/
if (url && *url) { if (url && *url) {
for (us = urlstrings; us->leadin != NULL; us++) { for (us = urlstrings; us->leadin != NULL; us++) {
if (strncmp(url, us->leadin, strlen(us->leadin))) if (strncmp(url, us->leadin, strlen(us->leadin)))
@ -373,12 +342,10 @@ urltype urlIsURL(const char * url)
return us->ret; return us->ret;
} }
} }
/*@=boundsread@*/
return URL_IS_UNKNOWN; return URL_IS_UNKNOWN;
} }
/*@-boundswrite@*/
/* Return path portion of url (or pointer to NUL if url == NULL) */ /* Return path portion of url (or pointer to NUL if url == NULL) */
urltype urlPath(const char * url, const char ** pathp) urltype urlPath(const char * url, const char ** pathp)
{ {
@ -387,7 +354,6 @@ urltype urlPath(const char * url, const char ** pathp)
path = url; path = url;
urltype = urlIsURL(url); urltype = urlIsURL(url);
/*@-branchstate@*/
switch (urltype) { switch (urltype) {
case URL_IS_FTP: case URL_IS_FTP:
url += sizeof("ftp://") - 1; url += sizeof("ftp://") - 1;
@ -421,14 +387,10 @@ urltype urlPath(const char * url, const char ** pathp)
path = ""; path = "";
break; break;
} }
/*@=branchstate@*/
if (pathp) if (pathp)
/*@-observertrans@*/
*pathp = path; *pathp = path;
/*@=observertrans@*/
return urltype; return urltype;
} }
/*@=boundswrite@*/
/* /*
* Split URL into components. The URL can look like * Split URL into components. The URL can look like
@ -436,8 +398,6 @@ urltype urlPath(const char * url, const char ** pathp)
* or as in RFC2732 for IPv6 address * or as in RFC2732 for IPv6 address
* service://user:password@[ip:v6:ad:dr:es:s]:port/path * service://user:password@[ip:v6:ad:dr:es:s]:port/path
*/ */
/*@-bounds@*/
/*@-modfilesys@*/
int urlSplit(const char * url, urlinfo *uret) int urlSplit(const char * url, urlinfo *uret)
{ {
urlinfo u; urlinfo u;
@ -477,7 +437,6 @@ int urlSplit(const char * url, urlinfo *uret)
/* Look for ...@host... */ /* Look for ...@host... */
fe = f = s; fe = f = s;
while (*fe && *fe != '@') fe++; while (*fe && *fe != '@') fe++;
/*@-branchstate@*/
if (*fe == '@') { if (*fe == '@') {
s = fe + 1; s = fe + 1;
*fe = '\0'; *fe = '\0';
@ -489,7 +448,6 @@ int urlSplit(const char * url, urlinfo *uret)
} }
u->user = xstrdup(f); u->user = xstrdup(f);
} }
/*@=branchstate@*/
/* Look for ...host:port or [v6addr]:port*/ /* Look for ...host:port or [v6addr]:port*/
fe = f = s; fe = f = s;
@ -518,10 +476,8 @@ int urlSplit(const char * url, urlinfo *uret)
if (u->port < 0 && u->scheme != NULL) { if (u->port < 0 && u->scheme != NULL) {
struct servent *serv; struct servent *serv;
/*@-multithreaded -moduncon @*/
/* HACK hkp:// might lookup "pgpkeyserver" */ /* HACK hkp:// might lookup "pgpkeyserver" */
serv = getservbyname(u->scheme, "tcp"); serv = getservbyname(u->scheme, "tcp");
/*@=multithreaded =moduncon @*/
if (serv != NULL) if (serv != NULL)
u->port = ntohs(serv->s_port); u->port = ntohs(serv->s_port);
else if (u->urltype == URL_IS_FTP) else if (u->urltype == URL_IS_FTP)
@ -537,14 +493,11 @@ int urlSplit(const char * url, urlinfo *uret)
myurl = _free(myurl); myurl = _free(myurl);
if (uret) { if (uret) {
*uret = u; *uret = u;
/*@-globs -mods @*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
urlFind(uret, 0); urlFind(uret, 0);
/*@=globs =mods @*/
} }
return 0; return 0;
} }
/*@=modfilesys@*/
/*@=bounds@*/
int urlGetFile(const char * url, const char * dest) int urlGetFile(const char * url, const char * dest)
{ {
@ -595,7 +548,7 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : N
if ((rc = ufdGetFile(sfd, tfd))) { if ((rc = ufdGetFile(sfd, tfd))) {
(void) Unlink(dest); (void) Unlink(dest);
/* XXX FIXME: sfd possibly closed by copyData */ /* XXX FIXME: sfd possibly closed by copyData */
/*@-usereleased@*/ (void) Fclose(sfd) /*@=usereleased@*/ ; (void) Fclose(sfd) ;
} }
sfd = NULL; /* XXX Fclose(sfd) done by ufdGetFile */ sfd = NULL; /* XXX Fclose(sfd) done by ufdGetFile */
break; break;