diff options
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/digest.c | 9 | ||||
-rw-r--r-- | rpmio/macro.c | 1015 | ||||
-rw-r--r-- | rpmio/rpmio.c | 211 | ||||
-rw-r--r-- | rpmio/rpmio.h | 7 | ||||
-rw-r--r-- | rpmio/rpmio_internal.h | 33 | ||||
-rw-r--r-- | rpmio/rpmlog.c | 7 | ||||
-rw-r--r-- | rpmio/rpmrpc.c | 89 | ||||
-rw-r--r-- | rpmio/rpmurl.h | 30 | ||||
-rw-r--r-- | rpmio/ugid.h | 22 | ||||
-rw-r--r-- | rpmio/url.c | 16 |
10 files changed, 833 insertions, 606 deletions
diff --git a/rpmio/digest.c b/rpmio/digest.c index c463d1509..60bb9ae84 100644 --- a/rpmio/digest.c +++ b/rpmio/digest.c @@ -377,6 +377,7 @@ static union _mendian { /*@-shadow@*/ static void byteReverse(byte *buf, unsigned nbytes) + /*@modifies *buf @*/ { unsigned nlongs = nbytes / sizeof(uint32); uint32 t; @@ -455,7 +456,9 @@ rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) memcpy(p, buf, t); if (ctx->doByteReverse) byteReverse(ctx->in, ctx->datalen); + /*@-moduncon@*/ ctx->transform(ctx); + /*@=moduncon@*/ buf += t; len -= t; } @@ -467,7 +470,9 @@ rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) /*@=mayaliasunique@*/ if (ctx->doByteReverse) byteReverse(ctx->in, ctx->datalen); + /*@-moduncon@*/ ctx->transform(ctx); + /*@=moduncon@*/ } /* Handle any remaining bytes of data. */ @@ -495,7 +500,9 @@ rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap, memset(p, 0, count); if (ctx->doByteReverse) byteReverse(ctx->in, ctx->datalen); + /*@-moduncon@*/ ctx->transform(ctx); + /*@=moduncon@*/ p = ctx->in; count = ctx->datalen; } @@ -506,7 +513,9 @@ rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap, byteReverse(ctx->in, ctx->datalen - sizeof(ctx->bits)); ((uint32 *) ctx->in)[14] = ctx->bits[0]; ((uint32 *) ctx->in)[15] = ctx->bits[1]; + /*@-moduncon@*/ ctx->transform(ctx); + /*@=moduncon@*/ /* Return final digest. */ if (ctx->doByteReverse) diff --git a/rpmio/macro.c b/rpmio/macro.c index 1edbd66c1..8324bce50 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -2,7 +2,7 @@ * \file rpmio/macro.c */ -static int _debug = 0; +/*@unused@*/ static int _debug = 0; #include "system.h" #include <stdarg.h> @@ -61,20 +61,21 @@ struct MacroContext_s rpmCLIMacroContext; /** * Macro expansion state. */ -typedef struct MacroBuf { -/*@shared@*/ const char * s; /*!< Text to expand. */ -/*@shared@*/ char * t; /*!< Expansion buffer. */ - size_t nb; /*!< No. bytes remaining in expansion buffer. */ - int depth; /*!< Current expansion depth. */ - int macro_trace; /*!< Pre-print macro to expand? */ - int expand_trace; /*!< Post-print macro expansion? */ +typedef /*@abstract@*/ struct MacroBuf_s { +/*@shared@*/ const char * s; /*!< Text to expand. */ +/*@shared@*/ char * t; /*!< Expansion buffer. */ + size_t nb; /*!< No. bytes remaining in expansion buffer. */ + int depth; /*!< Current expansion depth. */ + int macro_trace; /*!< Pre-print macro to expand? */ + int expand_trace; /*!< Post-print macro expansion? */ /*@shared@*/ /*@null@*/ void * spec; /*!< (future) %file expansion info?. */ /*@dependent@*/ MacroContext mc; -} MacroBuf; +} * MacroBuf; #define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; } -static int expandMacro(MacroBuf *mb); +static int expandMacro(MacroBuf mb) + /*@modifies mb @*/; /*@-exportlocal -exportheadervar@*/ #define MAX_MACRO_DEPTH 16 @@ -97,7 +98,8 @@ int print_expand_trace = 0; * @retval NULL always */ /*@unused@*/ static inline /*@null@*/ void * -_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +_free(/*@only@*/ /*@null@*/ const void * p) + /*@modifies p@*/ { if (p != NULL) free((void *)p); return NULL; @@ -112,18 +114,19 @@ _free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ * @return result of comparison */ static int -compareMacroName(const void *ap, const void *bp) +compareMacroName(const void * ap, const void * bp) + /*@*/ { - MacroEntry ame = *((MacroEntry *)ap); - MacroEntry bme = *((MacroEntry *)bp); - - if (ame == NULL && bme == NULL) - return 0; - if (ame == NULL) - return 1; - if (bme == NULL) - return -1; - return strcmp(ame->name, bme->name); + MacroEntry ame = *((MacroEntry *)ap); + MacroEntry bme = *((MacroEntry *)bp); + + if (ame == NULL && bme == NULL) + return 0; + if (ame == NULL) + return 1; + if (bme == NULL) + return -1; + return strcmp(ame->name, bme->name); } /** @@ -132,19 +135,20 @@ compareMacroName(const void *ap, const void *bp) */ static void expandMacroTable(MacroContext mc) + /*@modifies mc @*/ { - if (mc->macroTable == NULL) { - mc->macrosAllocated = MACRO_CHUNK_SIZE; - mc->macroTable = (MacroEntry *) - xmalloc(sizeof(*(mc->macroTable)) * mc->macrosAllocated); - mc->firstFree = 0; - } else { - mc->macrosAllocated += MACRO_CHUNK_SIZE; - mc->macroTable = (MacroEntry *) - xrealloc(mc->macroTable, sizeof(*(mc->macroTable)) * - mc->macrosAllocated); - } - memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable))); + if (mc->macroTable == NULL) { + mc->macrosAllocated = MACRO_CHUNK_SIZE; + mc->macroTable = (MacroEntry *) + xmalloc(sizeof(*(mc->macroTable)) * mc->macrosAllocated); + mc->firstFree = 0; + } else { + mc->macrosAllocated += MACRO_CHUNK_SIZE; + mc->macroTable = (MacroEntry *) + xrealloc(mc->macroTable, sizeof(*(mc->macroTable)) * + mc->macrosAllocated); + } + memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable))); } /** @@ -153,6 +157,7 @@ expandMacroTable(MacroContext mc) */ static void sortMacroTable(MacroContext mc) + /*@modifies mc @*/ { int i; @@ -212,7 +217,8 @@ rpmDumpMacroTable(MacroContext mc, FILE * fp) * @return address of slot in macro table with name (or NULL) */ /*@dependent@*/ /*@null@*/ static MacroEntry * -findEntry(MacroContext mc, const char *name, size_t namelen) +findEntry(MacroContext mc, const char * name, size_t namelen) + /*@*/ { MacroEntry key, *ret; struct MacroEntry_s keybuf; @@ -230,9 +236,9 @@ findEntry(MacroContext mc, const char *name, size_t namelen) key = &keybuf; memset(key, 0, sizeof(*key)); - /*@-temptrans@*/ + /*@-temptrans -assignexpose@*/ key->name = (char *)name; - /*@=temptrans@*/ + /*@=temptrans =assignexpose@*/ ret = (MacroEntry *) bsearch(&key, mc->macroTable, mc->firstFree, sizeof(*(mc->macroTable)), compareMacroName); /* XXX TODO: find 1st empty slot and return that */ @@ -245,7 +251,8 @@ findEntry(MacroContext mc, const char *name, size_t namelen) * fgets(3) analogue that reads \ continuations. Last newline always trimmed. */ /*@dependent@*/ static char * -rdcl(char *buf, size_t size, FD_t fd, int escapes) +rdcl(char * buf, size_t size, FD_t fd, int escapes) + /*@modifies buf, fileSystem @*/ { char *q = buf; size_t nb = 0; @@ -275,7 +282,7 @@ rdcl(char *buf, size_t size, FD_t fd, int escapes) *q = '\n'; *(++q) = '\0'; /* next char in buf */ } while (size > 0); - return (nread > 0 ? buf : NULL); + /*@-retalias@*/ return (nread > 0 ? buf : NULL); /*@=retalias@*/ } /** @@ -286,22 +293,23 @@ rdcl(char *buf, size_t size, FD_t fd, int escapes) * @return address of last char before pr (or NULL) */ static const char * -matchchar(const char *p, char pl, char pr) +matchchar(const char * p, char pl, char pr) + /*@*/ { - int lvl = 0; - char c; + int lvl = 0; + char c; - while ((c = *p++) != '\0') { - if (c == '\\') { /* Ignore escaped chars */ - p++; - continue; - } - if (c == pr) { - if (--lvl <= 0) return --p; - } else if (c == pl) - lvl++; + while ((c = *p++) != '\0') { + if (c == '\\') { /* Ignore escaped chars */ + p++; + continue; } - return (const char *)NULL; + if (c == pr) { + if (--lvl <= 0) return --p; + } else if (c == pl) + lvl++; + } + return (const char *)NULL; } /** @@ -311,39 +319,40 @@ matchchar(const char *p, char pl, char pr) * @param se end of string */ static void -printMacro(MacroBuf *mb, const char *s, const char *se) +printMacro(MacroBuf mb, const char * s, const char * se) + /*@modifies fileSystem @*/ { - const char *senl; - const char *ellipsis; - int choplen; - - if (s >= se) { /* XXX just in case */ - fprintf(stderr, _("%3d>%*s(empty)"), mb->depth, - (2 * mb->depth + 1), ""); - return; - } + const char *senl; + const char *ellipsis; + int choplen; - if (s[-1] == '{') - s--; + if (s >= se) { /* XXX just in case */ + fprintf(stderr, _("%3d>%*s(empty)"), mb->depth, + (2 * mb->depth + 1), ""); + return; + } - /* Print only to first end-of-line (or end-of-string). */ - for (senl = se; *senl && !iseol(*senl); senl++) - ; + if (s[-1] == '{') + s--; - /* Limit trailing non-trace output */ - choplen = 61 - (2 * mb->depth); - if ((senl - s) > choplen) { - senl = s + choplen; - ellipsis = "..."; - } else - ellipsis = ""; - - /* Substitute caret at end-of-macro position */ - fprintf(stderr, "%3d>%*s%%%.*s^", mb->depth, - (2 * mb->depth + 1), "", (int)(se - s), s); - if (se[1] != '\0' && (senl - (se+1)) > 0) - fprintf(stderr, "%-.*s%s", (int)(senl - (se+1)), se+1, ellipsis); - fprintf(stderr, "\n"); + /* Print only to first end-of-line (or end-of-string). */ + for (senl = se; *senl && !iseol(*senl); senl++) + {}; + + /* Limit trailing non-trace output */ + choplen = 61 - (2 * mb->depth); + if ((senl - s) > choplen) { + senl = s + choplen; + ellipsis = "..."; + } else + ellipsis = ""; + + /* Substitute caret at end-of-macro position */ + fprintf(stderr, "%3d>%*s%%%.*s^", mb->depth, + (2 * mb->depth + 1), "", (int)(se - s), s); + if (se[1] != '\0' && (senl - (se+1)) > 0) + fprintf(stderr, "%-.*s%s", (int)(senl - (se+1)), se+1, ellipsis); + fprintf(stderr, "\n"); } /** @@ -353,39 +362,40 @@ printMacro(MacroBuf *mb, const char *s, const char *se) * @param te end of string */ static void -printExpansion(MacroBuf *mb, const char *t, const char *te) +printExpansion(MacroBuf mb, const char * t, const char * te) + /*@modifies fileSystem @*/ { - const char *ellipsis; - int choplen; + const char *ellipsis; + int choplen; - if (!(te > t)) { - fprintf(stderr, _("%3d<%*s(empty)\n"), mb->depth, (2 * mb->depth + 1), ""); - return; - } + if (!(te > t)) { + fprintf(stderr, _("%3d<%*s(empty)\n"), mb->depth, (2 * mb->depth + 1), ""); + return; + } - /* Shorten output which contains newlines */ - while (te > t && iseol(te[-1])) - te--; - ellipsis = ""; - if (mb->depth > 0) { - const char *tenl; - - /* Skip to last line of expansion */ - while ((tenl = strchr(t, '\n')) && tenl < te) - t = ++tenl; - - /* Limit expand output */ - choplen = 61 - (2 * mb->depth); - if ((te - t) > choplen) { - te = t + choplen; - ellipsis = "..."; - } + /* Shorten output which contains newlines */ + while (te > t && iseol(te[-1])) + te--; + ellipsis = ""; + if (mb->depth > 0) { + const char *tenl; + + /* Skip to last line of expansion */ + while ((tenl = strchr(t, '\n')) && tenl < te) + t = ++tenl; + + /* Limit expand output */ + choplen = 61 - (2 * mb->depth); + if ((te - t) > choplen) { + te = t + choplen; + ellipsis = "..."; } + } - fprintf(stderr, "%3d<%*s", mb->depth, (2 * mb->depth + 1), ""); - if (te > t) - fprintf(stderr, "%.*s%s", (int)(te - t), t, ellipsis); - fprintf(stderr, "\n"); + fprintf(stderr, "%3d<%*s", mb->depth, (2 * mb->depth + 1), ""); + if (te > t) + fprintf(stderr, "%.*s%s", (int)(te - t), t, ellipsis); + fprintf(stderr, "\n"); } #define SKIPBLANK(_s, _c) \ @@ -426,21 +436,22 @@ printExpansion(MacroBuf *mb, const char *t, const char *te) * @return result of expansion */ static int -expandT(MacroBuf *mb, const char *f, size_t flen) +expandT(MacroBuf mb, const char * f, size_t flen) + /*@modifies mb @*/ { - char *sbuf; - const char *s = mb->s; - int rc; - - sbuf = alloca(flen + 1); - memset(sbuf, 0, (flen + 1)); - - strncpy(sbuf, f, flen); - sbuf[flen] = '\0'; - mb->s = sbuf; - rc = expandMacro(mb); - mb->s = s; - return rc; + char *sbuf; + const char *s = mb->s; + int rc; + + sbuf = alloca(flen + 1); + memset(sbuf, 0, (flen + 1)); + + strncpy(sbuf, f, flen); + sbuf[flen] = '\0'; + mb->s = sbuf; + rc = expandMacro(mb); + mb->s = s; + return rc; } #if 0 @@ -452,18 +463,19 @@ expandT(MacroBuf *mb, const char *f, size_t flen) * @return result of expansion */ static int -expandS(MacroBuf *mb, char *tbuf, size_t tbuflen) +expandS(MacroBuf mb, char * tbuf, size_t tbuflen) + /*@modifies mb, *tbuf @*/ { - const char *t = mb->t; - size_t nb = mb->nb; - int rc; - - mb->t = tbuf; - mb->nb = tbuflen; - rc = expandMacro(mb); - mb->t = t; - mb->nb = nb; - return rc; + const char *t = mb->t; + size_t nb = mb->nb; + int rc; + + mb->t = tbuf; + mb->nb = tbuflen; + rc = expandMacro(mb); + mb->t = t; + mb->nb = nb; + return rc; } #endif @@ -475,33 +487,34 @@ expandS(MacroBuf *mb, char *tbuf, size_t tbuflen) * @return result of expansion */ static int -expandU(MacroBuf *mb, char *u, size_t ulen) +expandU(MacroBuf mb, char * u, size_t ulen) + /*@modifies mb, *u @*/ { - const char *s = mb->s; - char *t = mb->t; - size_t nb = mb->nb; - char *tbuf; - int rc; - - tbuf = alloca(ulen + 1); - memset(tbuf, 0, (ulen + 1)); - - /*@-temptrans@*/ - mb->s = u; - /*@=temptrans@*/ - mb->t = tbuf; - mb->nb = ulen; - rc = expandMacro(mb); - - tbuf[ulen] = '\0'; /* XXX just in case */ - if (ulen > mb->nb) - strncpy(u, tbuf, (ulen - mb->nb + 1)); - - mb->s = s; - mb->t = t; - mb->nb = nb; + const char *s = mb->s; + char *t = mb->t; + size_t nb = mb->nb; + char *tbuf; + int rc; - return rc; + tbuf = alloca(ulen + 1); + memset(tbuf, 0, (ulen + 1)); + + /*@-temptrans -assignexpose@*/ + mb->s = u; + /*@=temptrans =assignexpose@*/ + mb->t = tbuf; + mb->nb = ulen; + rc = expandMacro(mb); + + tbuf[ulen] = '\0'; /* XXX just in case */ + if (ulen > mb->nb) + strncpy(u, tbuf, (ulen - mb->nb + 1)); + + mb->s = s; + mb->t = t; + mb->nb = nb; + + return rc; } /** @@ -512,31 +525,32 @@ expandU(MacroBuf *mb, char *u, size_t ulen) * @return result of expansion */ static int -doShellEscape(MacroBuf *mb, const char *cmd, size_t clen) +doShellEscape(MacroBuf mb, const char * cmd, size_t clen) + /*@modifies mb, fileSystem @*/ { - char pcmd[BUFSIZ]; - FILE *shf; - int rc; - int c; - - strncpy(pcmd, cmd, clen); - pcmd[clen] = '\0'; - rc = expandU(mb, pcmd, sizeof(pcmd)); - if (rc) - return rc; - - if ((shf = popen(pcmd, "r")) == NULL) - return 1; - while(mb->nb > 0 && (c = fgetc(shf)) != EOF) - SAVECHAR(mb, c); - (void) pclose(shf); + char pcmd[BUFSIZ]; + FILE *shf; + int rc; + int c; - /* XXX delete trailing \r \n */ - while (iseol(mb->t[-1])) { - *(mb->t--) = '\0'; - mb->nb++; - } - return 0; + strncpy(pcmd, cmd, clen); + pcmd[clen] = '\0'; + rc = expandU(mb, pcmd, sizeof(pcmd)); + if (rc) + return rc; + + if ((shf = popen(pcmd, "r")) == NULL) + return 1; + while(mb->nb > 0 && (c = fgetc(shf)) != EOF) + SAVECHAR(mb, c); + (void) pclose(shf); + + /* XXX delete trailing \r \n */ + while (iseol(mb->t[-1])) { + *(mb->t--) = '\0'; + mb->nb++; + } + return 0; } /** @@ -548,84 +562,84 @@ doShellEscape(MacroBuf *mb, const char *cmd, size_t clen) * @return address to continue parsing */ /*@dependent@*/ static const char * -doDefine(MacroBuf *mb, const char *se, int level, int expandbody) +doDefine(MacroBuf mb, const char * se, int level, int expandbody) + /*@modifies mb @*/ { - const char *s = se; - char buf[BUFSIZ], *n = buf, *ne = n; - char *o = NULL, *oe; - char *b, *be; - int c; - int oc = ')'; - - /* Copy name */ - COPYNAME(ne, s, c); - - /* Copy opts (if present) */ - oe = ne + 1; - if (*s == '(') { - s++; /* skip ( */ - o = oe; - COPYOPTS(oe, s, oc); - s++; /* skip ) */ - } + const char *s = se; + char buf[BUFSIZ], *n = buf, *ne = n; + char *o = NULL, *oe; + char *b, *be; + int c; + int oc = ')'; + + /* Copy name */ + COPYNAME(ne, s, c); + + /* Copy opts (if present) */ + oe = ne + 1; + if (*s == '(') { + s++; /* skip ( */ + o = oe; + COPYOPTS(oe, s, oc); + s++; /* skip ) */ + } - /* Copy body, skipping over escaped newlines */ - b = be = oe + 1; - SKIPBLANK(s, c); - if (c == '{') { /* XXX permit silent {...} grouping */ - if ((se = matchchar(s, c, '}')) == NULL) { - rpmError(RPMERR_BADSPEC, - _("Macro %%%s has unterminated body\n"), n); - se = s; /* XXX W2DO? */ - return se; - } - s++; /* XXX skip { */ - strncpy(b, s, (se - s)); - b[se - s] = '\0'; - be += strlen(b); - se++; /* XXX skip } */ - s = se; /* move scan forward */ - } else { /* otherwise free-field */ - COPYBODY(be, s, c); - - /* Trim trailing blanks/newlines */ - while (--be >= b && (c = *be) && (isblank(c) || iseol(c))) - ; - *(++be) = '\0'; /* one too far */ + /* Copy body, skipping over escaped newlines */ + b = be = oe + 1; + SKIPBLANK(s, c); + if (c == '{') { /* XXX permit silent {...} grouping */ + if ((se = matchchar(s, c, '}')) == NULL) { + rpmError(RPMERR_BADSPEC, + _("Macro %%%s has unterminated body\n"), n); + se = s; /* XXX W2DO? */ + /*@-retalias@*/ return se; /*@=retalias@*/ } + s++; /* XXX skip { */ + strncpy(b, s, (se - s)); + b[se - s] = '\0'; + be += strlen(b); + se++; /* XXX skip } */ + s = se; /* move scan forward */ + } else { /* otherwise free-field */ + COPYBODY(be, s, c); + + /* Trim trailing blanks/newlines */ + while (--be >= b && (c = *be) && (isblank(c) || iseol(c))) + {}; + *(++be) = '\0'; /* one too far */ + } - /* Move scan over body */ - while (iseol(*s)) - s++; - se = s; + /* Move scan over body */ + while (iseol(*s)) + s++; + se = s; - /* Names must start with alphabetic or _ and be at least 3 chars */ - if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) { - rpmError(RPMERR_BADSPEC, - _("Macro %%%s has illegal name (%%define)\n"), n); - return se; - } + /* Names must start with alphabetic or _ and be at least 3 chars */ + if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) { + rpmError(RPMERR_BADSPEC, + _("Macro %%%s has illegal name (%%define)\n"), n); + /*@-retalias@*/ return se; /*@=retalias@*/ + } - /* Options must be terminated with ')' */ - if (o && oc != ')') { - rpmError(RPMERR_BADSPEC, - _("Macro %%%s has unterminated opts\n"), n); - return se; - } + /* Options must be terminated with ')' */ + if (o && oc != ')') { + rpmError(RPMERR_BADSPEC, _("Macro %%%s has unterminated opts\n"), n); + /*@-retalias@*/ return se; /*@=retalias@*/ + } - if ((be - b) < 1) { - rpmError(RPMERR_BADSPEC, _("Macro %%%s has empty body\n"), n); - return se; - } + if ((be - b) < 1) { + rpmError(RPMERR_BADSPEC, _("Macro %%%s has empty body\n"), n); + /*@-retalias@*/ return se; /*@=retalias@*/ + } - if (expandbody && expandU(mb, b, (&buf[sizeof(buf)] - b))) { - rpmError(RPMERR_BADSPEC, _("Macro %%%s failed to expand\n"), n); - return se; - } + if (expandbody && expandU(mb, b, (&buf[sizeof(buf)] - b))) { + rpmError(RPMERR_BADSPEC, _("Macro %%%s failed to expand\n"), n); + /*@-retalias@*/ return se; /*@=retalias@*/ + } - addMacro(mb->mc, n, o, b, (level - 1)); + addMacro(mb->mc, n, o, b, (level - 1)); - return se; + /*@-retalias@*/ return se; /*@=retalias@*/ } /** @@ -635,42 +649,44 @@ doDefine(MacroBuf *mb, const char *se, int level, int expandbody) * @return address to continue parsing */ /*@dependent@*/ static const char * -doUndefine(MacroContext mc, const char *se) +doUndefine(MacroContext mc, const char * se) + /*@modifies mc @*/ { - const char *s = se; - char buf[BUFSIZ], *n = buf, *ne = n; - int c; + const char *s = se; + char buf[BUFSIZ], *n = buf, *ne = n; + int c; - COPYNAME(ne, s, c); + COPYNAME(ne, s, c); - /* Move scan over body */ - while (iseol(*s)) - s++; - se = s; + /* Move scan over body */ + while (iseol(*s)) + s++; + se = s; - /* Names must start with alphabetic or _ and be at least 3 chars */ - if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) { - rpmError(RPMERR_BADSPEC, - _("Macro %%%s has illegal name (%%undefine)\n"), n); - return se; - } + /* Names must start with alphabetic or _ and be at least 3 chars */ + if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) { + rpmError(RPMERR_BADSPEC, + _("Macro %%%s has illegal name (%%undefine)\n"), n); + /*@-retalias@*/ return se; /*@=retalias@*/ + } - delMacro(mc, n); + delMacro(mc, n); - return se; + /*@-retalias@*/ return se; /*@=retalias@*/ } #ifdef DYING static void -dumpME(const char *msg, MacroEntry me) +dumpME(const char * msg, MacroEntry me) + /*@modifies fileSystem @*/ { - if (msg) - fprintf(stderr, "%s", msg); - fprintf(stderr, "\tme %p", me); - if (me) - fprintf(stderr,"\tname %p(%s) prev %p", - me->name, me->name, me->prev); - fprintf(stderr, "\n"); + if (msg) + fprintf(stderr, "%s", msg); + fprintf(stderr, "\tme %p", me); + if (me) + fprintf(stderr,"\tname %p(%s) prev %p", + me->name, me->name, me->prev); + fprintf(stderr, "\n"); } #endif @@ -683,16 +699,19 @@ dumpME(const char *msg, MacroEntry me) * @param level macro recursion level */ static void -pushMacro(/*@out@*/ MacroEntry *mep, - const char *n, /*@null@*/ const char *o, - /*@null@*/ const char *b, int level) +pushMacro(/*@out@*/ MacroEntry * mep, + const char * n, /*@null@*/ const char * o, + /*@null@*/ const char * b, int level) + /*@modifies *mep @*/ { /*@-usedef@*/ MacroEntry prev = (mep && *mep ? *mep : NULL); /*@=usedef@*/ MacroEntry me = (MacroEntry) xmalloc(sizeof(*me)); + /*@-assignexpose@*/ me->prev = prev; + /*@=assignexpose@*/ me->name = (prev ? prev->name : xstrdup(n)); me->opts = (o ? xstrdup(o) : NULL); me->body = xstrdup(b ? b : ""); @@ -709,7 +728,8 @@ pushMacro(/*@out@*/ MacroEntry *mep, * @param mep address of macro entry slot */ static void -popMacro(MacroEntry *mep) +popMacro(MacroEntry * mep) + /*@modifies *mep @*/ { MacroEntry me = (*mep ? *mep : NULL); @@ -730,7 +750,8 @@ popMacro(MacroEntry *mep) * @param mb macro expansion state */ static void -freeArgs(MacroBuf *mb) +freeArgs(MacroBuf mb) + /*@modifies mb @*/ { MacroContext mc = mb->mc; int ndeleted = 0; @@ -779,7 +800,8 @@ freeArgs(MacroBuf *mb) * @return address to continue parsing */ /*@dependent@*/ static const char * -grabArgs(MacroBuf *mb, const MacroEntry me, const char *se, char lastc) +grabArgs(MacroBuf mb, const MacroEntry me, const char * se, char lastc) + /*@modifies mb @*/ { char buf[BUFSIZ], *b, *be; char aname[16]; @@ -852,7 +874,7 @@ grabArgs(MacroBuf *mb, const MacroEntry me, const char *se, char lastc) if (c == '?' || (o = strchr(opts, c)) == NULL) { rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"), (char)c, me->name, opts); - return se; + /*@-retalias@*/ return se; /*@=retalias@*/ } *be++ = '-'; *be++ = c; @@ -890,7 +912,7 @@ grabArgs(MacroBuf *mb, const MacroEntry me, const char *se, char lastc) /* Add unexpanded args as macro. */ addMacro(mb->mc, "*", NULL, b, mb->depth); - return se; + /*@-retalias@*/ return se; /*@=retalias@*/ } /** @@ -901,17 +923,18 @@ grabArgs(MacroBuf *mb, const MacroEntry me, const char *se, char lastc) * @param msglen no. of bytes in message */ static void -doOutput(MacroBuf *mb, int waserror, const char *msg, size_t msglen) +doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen) + /*@modifies mb, fileSystem @*/ { - char buf[BUFSIZ]; + char buf[BUFSIZ]; - strncpy(buf, msg, msglen); - buf[msglen] = '\0'; - (void) expandU(mb, buf, sizeof(buf)); - if (waserror) - rpmError(RPMERR_BADSPEC, "%s\n", buf); - else - fprintf(stderr, "%s", buf); + strncpy(buf, msg, msglen); + buf[msglen] = '\0'; + (void) expandU(mb, buf, sizeof(buf)); + if (waserror) + rpmError(RPMERR_BADSPEC, "%s\n", buf); + else + fprintf(stderr, "%s", buf); } /** @@ -924,90 +947,92 @@ doOutput(MacroBuf *mb, int waserror, const char *msg, size_t msglen) * @param gn length of field g */ static void -doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t glen) +doFoo(MacroBuf mb, int negate, const char * f, size_t fn, + const char * g, size_t glen) + /*@modifies mb @*/ { - char buf[BUFSIZ], *b = NULL, *be; - int c; + char buf[BUFSIZ], *b = NULL, *be; + int c; - buf[0] = '\0'; - if (g) { - strncpy(buf, g, glen); - buf[glen] = '\0'; - (void) expandU(mb, buf, sizeof(buf)); - } - if (STREQ("basename", f, fn)) { - if ((b = strrchr(buf, '/')) == NULL) - b = buf; + buf[0] = '\0'; + if (g) { + strncpy(buf, g, glen); + buf[glen] = '\0'; + (void) expandU(mb, buf, sizeof(buf)); + } + if (STREQ("basename", f, fn)) { + if ((b = strrchr(buf, '/')) == NULL) + b = buf; #if NOTYET - /* XXX watchout for conflict with %dir */ - } else if (STREQ("dirname", f, fn)) { - if ((b = strrchr(buf, '/')) != NULL) - *b = '\0'; - b = buf; + /* XXX watchout for conflict with %dir */ + } else if (STREQ("dirname", f, fn)) { + if ((b = strrchr(buf, '/')) != NULL) + *b = '\0'; + b = buf; #endif - } else if (STREQ("suffix", f, fn)) { - if ((b = strrchr(buf, '.')) != NULL) - b++; - } else if (STREQ("expand", f, fn)) { - b = buf; - } else if (STREQ("verbose", f, fn)) { - if (negate) - b = (rpmIsVerbose() ? NULL : buf); - else - b = (rpmIsVerbose() ? buf : NULL); - } else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) { - (void)urlPath(buf, (const char **)&b); - if (*b == '\0') b = "/"; - } else if (STREQ("uncompress", f, fn)) { - rpmCompressedMagic compressed = COMPRESSED_OTHER; - for (b = buf; (c = *b) && isblank(c);) - b++; - for (be = b; (c = *be) && !isblank(c);) - be++; - *be++ = '\0'; + } else if (STREQ("suffix", f, fn)) { + if ((b = strrchr(buf, '.')) != NULL) + b++; + } else if (STREQ("expand", f, fn)) { + b = buf; + } else if (STREQ("verbose", f, fn)) { + if (negate) + b = (rpmIsVerbose() ? NULL : buf); + else + b = (rpmIsVerbose() ? buf : NULL); + } else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) { + (void)urlPath(buf, (const char **)&b); + if (*b == '\0') b = "/"; + } else if (STREQ("uncompress", f, fn)) { + rpmCompressedMagic compressed = COMPRESSED_OTHER; + for (b = buf; (c = *b) && isblank(c);) + b++; + for (be = b; (c = *be) && !isblank(c);) + be++; + *be++ = '\0'; #ifndef DEBUG_MACROS - (void) isCompressed(b, &compressed); + (void) isCompressed(b, &compressed); #endif - switch(compressed) { - default: - case 0: /* COMPRESSED_NOT */ - sprintf(be, "%%_cat %s", b); - break; - case 1: /* COMPRESSED_OTHER */ - sprintf(be, "%%_gzip -dc %s", b); - break; - case 2: /* COMPRESSED_BZIP2 */ - sprintf(be, "%%_bzip2 %s", b); - break; - case 3: /* COMPRESSED_ZIP */ - sprintf(be, "%%_unzip %s", b); - break; - } - b = be; - } else if (STREQ("S", f, fn)) { - for (b = buf; (c = *b) && xisdigit(c);) - b++; - if (!c) { /* digit index */ - b++; - sprintf(b, "%%SOURCE%s", buf); - } else - b = buf; - } else if (STREQ("P", f, fn)) { - for (b = buf; (c = *b) && xisdigit(c);) - b++; - if (!c) { /* digit index */ - b++; - sprintf(b, "%%PATCH%s", buf); - } else - b = buf; - } else if (STREQ("F", f, fn)) { - b = buf + strlen(buf) + 1; - sprintf(b, "file%s.file", buf); + switch(compressed) { + default: + case 0: /* COMPRESSED_NOT */ + sprintf(be, "%%_cat %s", b); + break; + case 1: /* COMPRESSED_OTHER */ + sprintf(be, "%%_gzip -dc %s", b); + break; + case 2: /* COMPRESSED_BZIP2 */ + sprintf(be, "%%_bzip2 %s", b); + break; + case 3: /* COMPRESSED_ZIP */ + sprintf(be, "%%_unzip %s", b); + break; } + b = be; + } else if (STREQ("S", f, fn)) { + for (b = buf; (c = *b) && xisdigit(c);) + b++; + if (!c) { /* digit index */ + b++; + sprintf(b, "%%SOURCE%s", buf); + } else + b = buf; + } else if (STREQ("P", f, fn)) { + for (b = buf; (c = *b) && xisdigit(c);) + b++; + if (!c) { /* digit index */ + b++; + sprintf(b, "%%PATCH%s", buf); + } else + b = buf; + } else if (STREQ("F", f, fn)) { + b = buf + strlen(buf) + 1; + sprintf(b, "file%s.file", buf); + } - if (b) { - (void) expandT(mb, b, strlen(b)); - } + if (b) { + (void) expandT(mb, b, strlen(b)); + } } /** @@ -1017,7 +1042,8 @@ doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t * @return 0 on success, 1 on failure */ static int -expandMacro(MacroBuf *mb) +expandMacro(MacroBuf mb) + /*@modifies mb @*/ { MacroEntry *mep; MacroEntry me; @@ -1332,93 +1358,97 @@ expandMacro(MacroBuf *mb) /* =============================================================== */ int -expandMacros(void *spec, MacroContext mc, char *s, size_t slen) +expandMacros(void * spec, MacroContext mc, char * s, size_t slen) { - MacroBuf macrobuf, *mb = ¯obuf; - char *tbuf; - int rc; + MacroBuf mb = alloca(sizeof(*mb)); + char *tbuf; + int rc; - if (s == NULL || slen <= 0) - return 0; - if (mc == NULL) mc = &rpmGlobalMacroContext; + if (s == NULL || slen <= 0) + return 0; + if (mc == NULL) mc = &rpmGlobalMacroContext; - tbuf = alloca(slen + 1); - memset(tbuf, 0, (slen + 1)); + tbuf = alloca(slen + 1); + memset(tbuf, 0, (slen + 1)); - /*@-temptrans@*/ - mb->s = s; - /*@=temptrans@*/ - mb->t = tbuf; - mb->nb = slen; - mb->depth = 0; - mb->macro_trace = print_macro_trace; - mb->expand_trace = print_expand_trace; + /*@-temptrans -assignexpose@*/ + mb->s = s; + /*@=temptrans =assignexpose@*/ + mb->t = tbuf; + mb->nb = slen; + mb->depth = 0; + mb->macro_trace = print_macro_trace; + mb->expand_trace = print_expand_trace; - /*@-temptrans@*/ - mb->spec = spec; /* (future) %file expansion info */ - mb->mc = mc; - /*@=temptrans@*/ + /*@-temptrans -assignexpose@*/ + mb->spec = spec; /* (future) %file expansion info */ + mb->mc = mc; + /*@=temptrans =assignexpose@*/ - rc = expandMacro(mb); + rc = expandMacro(mb); - if (mb->nb <= 0) - rpmError(RPMERR_BADSPEC, _("Target buffer overflow\n")); + if (mb->nb <= 0) + rpmError(RPMERR_BADSPEC, _("Target buffer overflow\n")); - tbuf[slen] = '\0'; /* XXX just in case */ - strncpy(s, tbuf, (slen - mb->nb + 1)); + tbuf[slen] = '\0'; /* XXX just in case */ + strncpy(s, tbuf, (slen - mb->nb + 1)); - return rc; + return rc; } void -addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level) +addMacro(MacroContext mc, + const char * n, const char * o, const char * b, int level) { - MacroEntry *mep; + MacroEntry * mep; - if (mc == NULL) mc = &rpmGlobalMacroContext; + if (mc == NULL) mc = &rpmGlobalMacroContext; - /* If new name, expand macro table */ - if ((mep = findEntry(mc, n, 0)) == NULL) { - if (mc->firstFree == mc->macrosAllocated) - expandMacroTable(mc); - mep = mc->macroTable + mc->firstFree++; - } + /* If new name, expand macro table */ + if ((mep = findEntry(mc, n, 0)) == NULL) { + if (mc->firstFree == mc->macrosAllocated) + expandMacroTable(mc); + if (mc->macroTable != NULL) + mep = mc->macroTable + mc->firstFree++; + } + if (mep != NULL) { /* Push macro over previous definition */ pushMacro(mep, n, o, b, level); /* If new name, sort macro table */ if ((*mep)->prev == NULL) - sortMacroTable(mc); + sortMacroTable(mc); + } } void -delMacro(MacroContext mc, const char *n) +delMacro(MacroContext mc, const char * n) { - MacroEntry *mep; - - if (mc == NULL) mc = &rpmGlobalMacroContext; - /* If name exists, pop entry */ - if ((mep = findEntry(mc, n, 0)) != NULL) { - popMacro(mep); - /* If deleted name, sort macro table */ - if (!(mep && *mep)) - sortMacroTable(mc); - } + MacroEntry * mep; + + if (mc == NULL) mc = &rpmGlobalMacroContext; + /* If name exists, pop entry */ + if ((mep = findEntry(mc, n, 0)) != NULL) { + popMacro(mep); + /* If deleted name, sort macro table */ + if (!(mep && *mep)) + sortMacroTable(mc); + } } int -rpmDefineMacro(MacroContext mc, const char *macro, int level) +rpmDefineMacro(MacroContext mc, const char * macro, int level) { - MacroBuf macrobuf, *mb = ¯obuf; - - memset(mb, 0, sizeof(*mb)); - /* XXX just enough to get by */ - /*@-temptrans@*/ - mb->mc = (mc ? mc : &rpmGlobalMacroContext); - /*@=temptrans@*/ - (void)doDefine(mb, macro, level, 0); - return 0; + MacroBuf mb = alloca(sizeof(*mb)); + + memset(mb, 0, sizeof(*mb)); + /* XXX just enough to get by */ + /*@-temptrans -assignexpose@*/ + mb->mc = (mc ? mc : &rpmGlobalMacroContext); + /*@=temptrans =assignexpose@*/ + (void)doDefine(mb, macro, level, 0); + return 0; } void @@ -1457,7 +1487,7 @@ rpmInitMacros(MacroContext mc, const char *macrofiles) for (me = mfile; (me = strchr(me, ':')) != NULL; me++) { if (!(me[1] == '/' && me[2] == '/')) - break; + /*@innerbreak@*/ break; } if (me && *me == ':') @@ -1535,7 +1565,7 @@ rpmFreeMacros(MacroContext mc) /*@=globstate@*/ /* =============================================================== */ -int isCompressed(const char *file, rpmCompressedMagic *compressed) +int isCompressed(const char * file, rpmCompressedMagic * compressed) { FD_t fd; ssize_t nb; @@ -1660,7 +1690,7 @@ char *rpmCleanPath(char * path) case '/': /* Move parent dir forward */ for (se = te + 1; se < t && *se != '/'; se++) - ; + {}; if (se < t && *se == '/') { te = se; /*fprintf(stderr, "*** next pdir \"%.*s\"\n", (te-path), path); */ @@ -1692,7 +1722,7 @@ char *rpmCleanPath(char * path) /* Move parent dir forward */ if (te > path) for (--te; te > path && *te != '/'; te--) - ; + {}; /*fprintf(stderr, "*** prev pdir \"%.*s\"\n", (te-path), path); */ s++; s++; @@ -1712,7 +1742,7 @@ char *rpmCleanPath(char * path) *t = '\0'; /*fprintf(stderr, "\t%s\n", path); */ - /*@-temptrans@*/ return path; /*@=temptrans@*/ + /*@-temptrans -retalias@*/ return path; /*@=temptrans =retalias@*/ } /* Return concatenated and expanded canonical path. */ @@ -1761,14 +1791,16 @@ const char * rpmGenPath(const char * urlroot, const char * urlmdir, int nurl = 0; int ut; -if (_debug) -fprintf(stderr, "*** RGP xroot %s xmdir %s xfile %s\n", xroot, xmdir, xfile); +#if 0 +if (_debug) fprintf(stderr, "*** RGP xroot %s xmdir %s xfile %s\n", xroot, xmdir, xfile); +#endif ut = urlPath(xroot, &root); if (url == NULL && ut > URL_IS_DASH) { url = xroot; nurl = root - xroot; -if (_debug) -fprintf(stderr, "*** RGP ut %d root %s nurl %d\n", ut, root, nurl); +#if 0 +if (_debug) fprintf(stderr, "*** RGP ut %d root %s nurl %d\n", ut, root, nurl); +#endif } if (root == NULL || *root == '\0') root = "/"; @@ -1776,8 +1808,9 @@ fprintf(stderr, "*** RGP ut %d root %s nurl %d\n", ut, root, nurl); if (url == NULL && ut > URL_IS_DASH) { url = xmdir; nurl = mdir - xmdir; -if (_debug) -fprintf(stderr, "*** RGP ut %d mdir %s nurl %d\n", ut, mdir, nurl); +#if 0 +if (_debug) fprintf(stderr, "*** RGP ut %d mdir %s nurl %d\n", ut, mdir, nurl); +#endif } if (mdir == NULL || *mdir == '\0') mdir = "/"; @@ -1785,8 +1818,9 @@ fprintf(stderr, "*** RGP ut %d mdir %s nurl %d\n", ut, mdir, nurl); if (url == NULL && ut > URL_IS_DASH) { url = xfile; nurl = file - xfile; -if (_debug) -fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl); +#if 0 +if (_debug) fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl); +#endif } if (url && nurl > 0) { @@ -1801,8 +1835,9 @@ fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl); xroot = _free(xroot); xmdir = _free(xmdir); xfile = _free(xfile); -if (_debug) -fprintf(stderr, "*** RGP result %s\n", result); +#if 0 +if (_debug) fprintf(stderr, "*** RGP result %s\n", result); +#endif return result; } @@ -1817,39 +1852,39 @@ char *macrofiles = "/usr/lib/rpm/macros:/etc/rpm/macros:~/.rpmmacros"; int main(int argc, char *argv[]) { - int c; - int errflg = 0; - extern char *optarg; - extern int optind; - - while ((c = getopt(argc, argv, "f:")) != EOF ) { - switch (c) { - case 'f': - macrofiles = optarg; - break; - case '?': - default: - errflg++; - break; - } - } - if (errflg || optind >= argc) { - fprintf(stderr, "Usage: %s [-f macropath ] macro ...\n", argv[0]); - exit(1); + int c; + int errflg = 0; + extern char *optarg; + extern int optind; + + while ((c = getopt(argc, argv, "f:")) != EOF ) { + switch (c) { + case 'f': + macrofiles = optarg; + break; + case '?': + default: + errflg++; + break; } + } + if (errflg || optind >= argc) { + fprintf(stderr, "Usage: %s [-f macropath ] macro ...\n", argv[0]); + exit(1); + } - rpmInitMacros(NULL, macrofiles); - for ( ; optind < argc; optind++) { - const char *val; + rpmInitMacros(NULL, macrofiles); + for ( ; optind < argc; optind++) { + const char *val; - val = rpmGetPath(argv[optind], NULL); - if (val) { - fprintf(stdout, "%s:\t%s\n", argv[optind], val); - val = _free(val); - } + val = rpmGetPath(argv[optind], NULL); + if (val) { + fprintf(stdout, "%s:\t%s\n", argv[optind], val); + val = _free(val); } - rpmFreeMacros(NULL); - return 0; + } + rpmFreeMacros(NULL); + return 0; } #else /* !EVAL_MACROS */ @@ -1860,30 +1895,30 @@ char *testfile = "./test"; int main(int argc, char *argv[]) { - char buf[BUFSIZ]; - FILE *fp; - int x; + char buf[BUFSIZ]; + FILE *fp; + int x; - rpmInitMacros(NULL, macrofiles); - rpmDumpMacroTable(NULL, NULL); + rpmInitMacros(NULL, macrofiles); + rpmDumpMacroTable(NULL, NULL); - if ((fp = fopen(testfile, "r")) != NULL) { - while(rdcl(buf, sizeof(buf), fp, 1)) { - x = expandMacros(NULL, NULL, buf, sizeof(buf)); - fprintf(stderr, "%d->%s\n", x, buf); - memset(buf, 0, sizeof(buf)); - } - fclose(fp); + if ((fp = fopen(testfile, "r")) != NULL) { + while(rdcl(buf, sizeof(buf), fp, 1)) { + x = expandMacros(NULL, NULL, buf, sizeof(buf)); + fprintf(stderr, "%d->%s\n", x, buf); + memset(buf, 0, sizeof(buf)); } + fclose(fp); + } - while(rdcl(buf, sizeof(buf), stdin, 1)) { - x = expandMacros(NULL, NULL, buf, sizeof(buf)); - fprintf(stderr, "%d->%s\n <-\n", x, buf); - memset(buf, 0, sizeof(buf)); - } - rpmFreeMacros(NULL); + while(rdcl(buf, sizeof(buf), stdin, 1)) { + x = expandMacros(NULL, NULL, buf, sizeof(buf)); + fprintf(stderr, "%d->%s\n <-\n", x, buf); + memset(buf, 0, sizeof(buf)); + } + rpmFreeMacros(NULL); - return 0; + return 0; } #endif /* EVAL_MACROS */ #endif /* DEBUG_MACROS */ diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 657b40de7..16fdc8ef1 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -99,7 +99,8 @@ int _rpmio_debug = 0; * @retval NULL always */ /*@unused@*/ static inline /*@null@*/ void * -_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +_free(/*@only@*/ /*@null@*/ const void * p) + /*@modifies p@*/ { if (p != NULL) free((void *)p); return NULL; @@ -108,6 +109,7 @@ _free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ /* =============================================================== */ static /*@observer@*/ const char * fdbg(/*@null@*/ FD_t fd) + /*@modifies fileSystem @*/ { static char buf[BUFSIZ]; char *be = buf; @@ -168,7 +170,8 @@ static /*@observer@*/ const char * fdbg(/*@null@*/ FD_t fd) } /* =============================================================== */ -off_t fdSize(FD_t fd) { +off_t fdSize(FD_t fd) +{ struct stat sb; off_t rc = -1; @@ -192,7 +195,8 @@ DBGIO(0, (stderr, "==>\tfdSize(%p) rc %ld\n", fd, (long)rc)); return rc; } -FD_t fdDup(int fdno) { +FD_t fdDup(int fdno) +{ FD_t fd; int nfdno; @@ -204,14 +208,18 @@ DBGIO(fd, (stderr, "==> fdDup(%d) fd %p %s\n", fdno, (fd ? fd : NULL), fdbg(fd)) /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ } -static inline /*@unused@*/ int fdSeekNot(void * cookie, /*@unused@*/ _libio_pos_t pos, /*@unused@*/ int whence) { +static inline /*@unused@*/ int fdSeekNot(void * cookie, + /*@unused@*/ _libio_pos_t pos, /*@unused@*/ int whence) + /*@*/ +{ FD_t fd = c2f(cookie); FDSANE(fd); /* XXX keep gcc quiet */ return -2; } #ifdef UNUSED -FILE *fdFdopen(void * cookie, const char *fmode) { +FILE *fdFdopen(void * cookie, const char *fmode) +{ FD_t fd = c2f(cookie); int fdno; FILE * fp; @@ -233,10 +241,15 @@ DBGIO(fd, (stderr, "==> fdFdopen(%p,\"%s\") fdno %d -> fp %p fdno %d\n", cookie, #endif /* =============================================================== */ -static inline /*@null@*/ FD_t XfdLink(void * cookie, const char *msg, const char *file, unsigned line) { +static inline /*@null@*/ FD_t XfdLink(void * cookie, const char * msg, + const char * file, unsigned line) + /*@modifies internalState @*/ +{ FD_t fd; if (cookie == NULL) + /*@-castexpose@*/ DBGREFS(0, (stderr, "--> fd %p ++ %d %s at %s:%u\n", cookie, FDNREFS(cookie)+1, msg, file, line)); + /*@=castexpose@*/ fd = c2f(cookie); if (fd) { fd->nrefs++; @@ -245,14 +258,17 @@ DBGREFS(fd, (stderr, "--> fd %p ++ %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi return fd; } -static inline /*@null@*/ FD_t XfdFree( /*@killref@*/ FD_t fd, const char *msg, const char *file, unsigned line) { +static inline /*@null@*/ FD_t XfdFree( /*@killref@*/ FD_t fd, const char *msg, + const char *file, unsigned line) + /*@modifies fd @*/ +{ if (fd == NULL) DBGREFS(0, (stderr, "--> fd %p -- %d %s at %s:%u\n", fd, FDNREFS(fd), msg, file, line)); FDSANE(fd); if (fd) { DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, file, line, fdbg(fd))); if (--fd->nrefs > 0) - /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ fd->stats = _free(fd->stats); fd->digest = _free(fd->digest); /*@-refcounttrans@*/ free(fd); /*@=refcounttrans@*/ @@ -260,7 +276,10 @@ DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi return NULL; } -static inline /*@null@*/ FD_t XfdNew(const char *msg, const char *file, unsigned line) { +static inline /*@null@*/ FD_t XfdNew(const char * msg, + const char * file, unsigned line) + /*@*/ +{ FD_t fd = (FD_t) xmalloc(sizeof(struct _FD_s)); if (fd == NULL) /* XXX xmalloc never returns NULL */ return NULL; @@ -272,7 +291,9 @@ static inline /*@null@*/ FD_t XfdNew(const char *msg, const char *file, unsigned fd->nfps = 0; memset(fd->fps, 0, sizeof(fd->fps)); + /*@-assignexpose@*/ fd->fps[0].io = fdio; + /*@=assignexpose@*/ fd->fps[0].fp = NULL; fd->fps[0].fdno = -1; @@ -295,7 +316,8 @@ static inline /*@null@*/ FD_t XfdNew(const char *msg, const char *file, unsigned return XfdLink(fd, msg, file, line); } -ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count) { +ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count) +{ FD_t fd = c2f(cookie); ssize_t rc; @@ -312,7 +334,8 @@ DBGIO(fd, (stderr, "==>\tfdRead(%p,%p,%ld) rc %ld %s\n", cookie, buf, (long)coun return rc; } -ssize_t fdWrite(void * cookie, const char * buf, size_t count) { +ssize_t fdWrite(void * cookie, const char * buf, size_t count) +{ FD_t fd = c2f(cookie); int fdno = fdFileno(fd); ssize_t rc; @@ -344,7 +367,9 @@ DBGIO(fd, (stderr, "==>\tfdWrite(%p,%p,%ld) rc %ld %s\n", cookie, buf, (long)cou return rc; } -static inline int fdSeek(void * cookie, _libio_pos_t pos, int whence) { +static inline int fdSeek(void * cookie, _libio_pos_t pos, int whence) + /*@modifies internalState, fileSystem @*/ +{ #ifdef USE_COOKIE_SEEK_POINTER _IO_off64_t p = *pos; #else @@ -363,7 +388,8 @@ DBGIO(fd, (stderr, "==>\tfdSeek(%p,%ld,%d) rc %lx %s\n", cookie, (long)p, whence return rc; } -int fdClose( /*@only@*/ void * cookie) { +int fdClose( /*@only@*/ void * cookie) +{ FD_t fd; int fdno; int rc; @@ -384,7 +410,8 @@ DBGIO(fd, (stderr, "==>\tfdClose(%p) rc %lx %s\n", (fd ? fd : NULL), (unsigned l return rc; } -/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode) { +/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode) +{ FD_t fd; int fdno; @@ -616,7 +643,9 @@ const char *urlStrerror(const char *url) } #if !defined(USE_ALT_DNS) || !USE_ALT_DNS -static int mygethostbyname(const char * host, struct in_addr * address) +static int mygethostbyname(const char * host, + /*@out@*/ struct in_addr * address) + /*@modifies *address, fileSystem @*/ { struct hostent * hostinfo; @@ -630,7 +659,8 @@ static int mygethostbyname(const char * host, struct in_addr * address) } #endif -static int getHostAddress(const char * host, struct in_addr * address) +static int getHostAddress(const char * host, /*@out@*/ struct in_addr * address) + /*@modifies *address, fileSystem @*/ { if (xisdigit(host[0])) { if (! /*@-unrecog@*/ inet_aton(host, address) /*@=unrecog@*/ ) @@ -646,6 +676,7 @@ static int getHostAddress(const char * host, struct in_addr * address) } static int tcpConnect(FD_t ctrl, const char * host, int port) + /*@modifies ctrl, fileSystem @*/ { struct sockaddr_in sin; int fdno = -1; @@ -691,7 +722,9 @@ errxit: return rc; } -static int checkResponse(void * uu, FD_t ctrl, /*@out@*/ int *ecp, /*@out@*/ char ** str) +static int checkResponse(void * uu, FD_t ctrl, + /*@out@*/ int *ecp, /*@out@*/ char ** str) + /*@modifies ctrl, *ecp, *str, fileSystem @*/ { urlinfo u = uu; char *buf; @@ -740,7 +773,7 @@ static int checkResponse(void * uu, FD_t ctrl, /*@out@*/ int *ecp, /*@out@*/ cha if (se > s && se[-1] == '\r') se[-1] = '\0'; if (*se == '\0') - break; + /*@innerbreak@*/ break; if (_ftp_debug) fprintf(stderr, "<- %s\n", s); @@ -748,7 +781,7 @@ fprintf(stderr, "<- %s\n", s); /* HTTP: header termination on empty line */ if (*s == '\0') { moretodo = 0; - break; + /*@innerbreak@*/ break; } *se++ = '\0'; @@ -774,7 +807,7 @@ fprintf(stderr, "<- %s\n", s); /* HTTP: look for "token: ..." */ for (e = s; *e && !(*e == ' ' || *e == ':'); e++) - ; + {}; if (e > s && *e++ == ':') { size_t ne = (e - s); while (*e && *e == ' ') e++; @@ -852,6 +885,7 @@ fprintf(stderr, "<- %s\n", s); } static int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str) + /*@modifies u, *str, fileSystem @*/ { int ec = 0; int rc; @@ -876,6 +910,7 @@ static int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str) } static int ftpCommand(urlinfo u, char ** str, ...) + /*@modifies u, *str, fileSystem @*/ { va_list ap; int len = 0; @@ -912,6 +947,7 @@ fprintf(stderr, "-> %s", t); } static int ftpLogin(urlinfo u) + /*@modifies u, fileSystem @*/ { const char * host; const char * user; @@ -1180,6 +1216,7 @@ int ufdCopy(FD_t sfd, FD_t tfd) } static int urlConnect(const char * url, /*@out@*/ urlinfo * uret) + /*@modifies *uret, fileSystem @*/ { urlinfo u; int rc = 0; @@ -1234,7 +1271,8 @@ int ufdGetFile(FD_t sfd, FD_t tfd) return rc; } -int ftpCmd(const char * cmd, const char * url, const char * arg2) { +int ftpCmd(const char * cmd, const char * url, const char * arg2) +{ urlinfo u; int rc; const char * path; @@ -1263,7 +1301,9 @@ int ftpCmd(const char * cmd, const char * url, const char * arg2) { #define SHUT_RDWR 1+1 #endif -static int ftpAbort(urlinfo u, FD_t data) { +static int ftpAbort(urlinfo u, FD_t data) + /*@modifies u, data, fileSystem @*/ +{ static unsigned char ipbuf[3] = { IAC, IP, IAC }; FD_t ctrl; int rc; @@ -1299,7 +1339,7 @@ static int ftpAbort(urlinfo u, FD_t data) { data->rd_timeoutsecs = 10; if (fdReadable(data, data->rd_timeoutsecs) > 0) { while (timedRead(data, u->buf, u->bufAlloced) > 0) - ; + u->buf[0] = '\0'; } data->rd_timeoutsecs = tosecs; /* XXX ftp abort needs to close the data channel to receive status */ @@ -1322,6 +1362,7 @@ static int ftpAbort(urlinfo u, FD_t data) { } static int ftpFileDone(urlinfo u, FD_t data) + /*@modifies u, data, fileSystem @*/ { int rc = 0; @@ -1338,6 +1379,7 @@ static int ftpFileDone(urlinfo u, FD_t data) } static int httpResp(urlinfo u, FD_t ctrl, /*@out@*/ char ** str) + /*@modifies ctrl, *str, fileSystem @*/ { int ec = 0; int rc; @@ -1360,6 +1402,7 @@ fprintf(stderr, "*** httpResp: rc %d ec %d\n", rc, ec); } static int httpReq(FD_t ctrl, const char * httpCmd, const char * httpArg) + /*@modifies ctrl, fileSystem @*/ { urlinfo u = ctrl->url; const char * host; @@ -1464,7 +1507,8 @@ errxit2: } /* XXX DYING: unused */ -void * ufdGetUrlinfo(FD_t fd) { +void * ufdGetUrlinfo(FD_t fd) +{ FDSANE(fd); if (fd->url == NULL) return NULL; @@ -1472,7 +1516,9 @@ void * ufdGetUrlinfo(FD_t fd) { } /* =============================================================== */ -static ssize_t ufdRead(void * cookie, /*@out@*/ char * buf, size_t count) { +static ssize_t ufdRead(void * cookie, /*@out@*/ char * buf, size_t count) + /*@modifies internalState, *buf, fileSystem @*/ +{ FD_t fd = c2f(cookie); int bytesRead; int total; @@ -1534,6 +1580,7 @@ fprintf(stderr, "*** read: rc %d errno %d %s \"%s\"\n", rc, errno, strerror(errn } static ssize_t ufdWrite(void * cookie, const char * buf, size_t count) + /*@modifies internalState, fileSystem @*/ { FD_t fd = c2f(cookie); int bytesWritten; @@ -1596,7 +1643,9 @@ fprintf(stderr, "*** write: rc %d errno %d %s \"%s\"\n", rc, errno, strerror(err return count; } -static inline int ufdSeek(void * cookie, _libio_pos_t pos, int whence) { +static inline int ufdSeek(void * cookie, _libio_pos_t pos, int whence) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); switch (fd->urlType) { @@ -1731,6 +1780,7 @@ fprintf(stderr, "-> \r\n"); /*@-nullstate@*/ /* FIX: u->{ctrl,data}->url undef after XurlLink. */ /*@null@*/ FD_t ftpOpen(const char *url, /*@unused@*/ int flags, /*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret) + /*@modifies *uret, fileSystem @*/ { urlinfo u = NULL; FD_t fd = NULL; @@ -1768,6 +1818,7 @@ exit: /*@-nullstate@*/ /* FIX: u->{ctrl,data}->url undef after XurlLink. */ static /*@null@*/ FD_t httpOpen(const char * url, /*@unused@*/ int flags, /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret) + /*@modifies *uret, fileSystem @*/ { urlinfo u = NULL; FD_t fd = NULL; @@ -1807,7 +1858,8 @@ exit: } /*@=nullstate@*/ -static /*@null@*/ FD_t ufdOpen(const char *url, int flags, mode_t mode) +static /*@null@*/ FD_t ufdOpen(const char * url, int flags, mode_t mode) + /*@modifies fileSystem @*/ { FD_t fd = NULL; const char * cmd; @@ -1904,7 +1956,9 @@ FDIO_t ufdio = /*@-compmempass@*/ &ufdio_s /*@=compmempass@*/ ; #include <zlib.h> -static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd) { +static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd) + /*@*/ +{ void * rc = NULL; int i; @@ -1920,7 +1974,9 @@ static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd) { return rc; } -static /*@null@*/ FD_t gzdOpen(const char *path, const char *fmode) { +static /*@null@*/ FD_t gzdOpen(const char * path, const char * fmode) + /*@modifies fileSystem @*/ +{ FD_t fd; gzFile *gzfile; if ((gzfile = gzopen(path, fmode)) == NULL) @@ -1932,7 +1988,9 @@ DBGIO(fd, (stderr, "==>\tgzdOpen(\"%s\", \"%s\") fd %p %s\n", path, fmode, (fd ? return fdLink(fd, "gzdOpen"); } -static /*@null@*/ FD_t gzdFdopen(void * cookie, const char *fmode) { +static /*@null@*/ FD_t gzdFdopen(void * cookie, const char *fmode) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); int fdno; gzFile *gzfile; @@ -1949,12 +2007,17 @@ static /*@null@*/ FD_t gzdFdopen(void * cookie, const char *fmode) { return fdLink(fd, "gzdFdopen"); } -static int gzdFlush(FD_t fd) { +static int gzdFlush(FD_t fd) + /*@modifies fileSystem @*/ +{ return gzflush(gzdFileno(fd), Z_SYNC_FLUSH); /* XXX W2DO? */ } /* =============================================================== */ -static ssize_t gzdRead(void * cookie, /*@out@*/ char * buf, size_t count) { +/*@-mustmod@*/ /* LCL: *buf is modified */ +static ssize_t gzdRead(void * cookie, /*@out@*/ char * buf, size_t count) + /*@modifies internalState, *buf, fileSystem @*/ +{ FD_t fd = c2f(cookie); gzFile *gzfile; ssize_t rc; @@ -1981,8 +2044,11 @@ DBGIO(fd, (stderr, "==>\tgzdRead(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned) } return rc; } +/*@=mustmod@*/ -static ssize_t gzdWrite(void * cookie, const char * buf, size_t count) { +static ssize_t gzdWrite(void * cookie, const char * buf, size_t count) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); gzFile *gzfile; ssize_t rc; @@ -2009,7 +2075,9 @@ DBGIO(fd, (stderr, "==>\tgzdWrite(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned } /* XXX zlib-1.0.4 has not */ -static inline int gzdSeek(void * cookie, _libio_pos_t pos, int whence) { +static inline int gzdSeek(void * cookie, _libio_pos_t pos, int whence) + /*@modifies internalState, fileSystem @*/ +{ #ifdef USE_COOKIE_SEEK_POINTER _IO_off64_t p = *pos; #else @@ -2042,7 +2110,9 @@ DBGIO(fd, (stderr, "==>\tgzdSeek(%p,%ld,%d) rc %lx %s\n", cookie, (long)p, whenc return rc; } -static int gzdClose( /*@only@*/ void * cookie) { +static int gzdClose( /*@only@*/ void * cookie) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); gzFile *gzfile; int rc; @@ -2101,7 +2171,9 @@ FDIO_t gzdio = /*@-compmempass@*/ &gzdio_s /*@=compmempass@*/ ; # define bzwrite BZ2_bzwrite #endif /* HAVE_BZ2_1_0 */ -static inline /*@dependent@*/ void * bzdFileno(FD_t fd) { +static inline /*@dependent@*/ void * bzdFileno(FD_t fd) + /*@*/ +{ void * rc = NULL; int i; @@ -2117,7 +2189,9 @@ static inline /*@dependent@*/ void * bzdFileno(FD_t fd) { return rc; } -static /*@null@*/ FD_t bzdOpen(const char *path, const char *mode) { +static /*@null@*/ FD_t bzdOpen(const char * path, const char * mode) + /*@modifies fileSystem @*/ +{ FD_t fd; BZFILE *bzfile;; if ((bzfile = bzopen(path, mode)) == NULL) @@ -2127,7 +2201,9 @@ static /*@null@*/ FD_t bzdOpen(const char *path, const char *mode) { return fdLink(fd, "bzdOpen"); } -static /*@null@*/ FD_t bzdFdopen(void * cookie, const char * fmode) { +static /*@null@*/ FD_t bzdFdopen(void * cookie, const char * fmode) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); int fdno; BZFILE *bzfile; @@ -2144,12 +2220,17 @@ static /*@null@*/ FD_t bzdFdopen(void * cookie, const char * fmode) { return fdLink(fd, "bzdFdopen"); } -static int bzdFlush(FD_t fd) { +static int bzdFlush(FD_t fd) + /*@modifies fileSystem @*/ +{ return bzflush(bzdFileno(fd)); } /* =============================================================== */ -static ssize_t bzdRead(void * cookie, /*@out@*/ char * buf, size_t count) { +/*@-mustmod@*/ /* LCL: *buf is modified */ +static ssize_t bzdRead(void * cookie, /*@out@*/ char * buf, size_t count) + /*@modifies internalState, *buf, fileSystem @*/ +{ FD_t fd = c2f(cookie); BZFILE *bzfile; ssize_t rc = 0; @@ -2173,8 +2254,11 @@ static ssize_t bzdRead(void * cookie, /*@out@*/ char * buf, size_t count) { } return rc; } +/*@=mustmod@*/ -static ssize_t bzdWrite(void * cookie, const char * buf, size_t count) { +static ssize_t bzdWrite(void * cookie, const char * buf, size_t count) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); BZFILE *bzfile; ssize_t rc; @@ -2196,14 +2280,18 @@ static ssize_t bzdWrite(void * cookie, const char * buf, size_t count) { } static inline int bzdSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, - /*@unused@*/ int whence) { + /*@unused@*/ int whence) + /*@*/ +{ FD_t fd = c2f(cookie); BZDONLY(fd); return -2; } -static int bzdClose( /*@only@*/ void * cookie) { +static int bzdClose( /*@only@*/ void * cookie) + /*@modifies internalState, fileSystem @*/ +{ FD_t fd = c2f(cookie); BZFILE *bzfile; int rc; @@ -2243,7 +2331,9 @@ FDIO_t bzdio = /*@-compmempass@*/ &bzdio_s /*@=compmempass@*/ ; #endif /* HAVE_BZLIB_H */ /* =============================================================== */ -/*@observer@*/ static const char * getFdErrstr (FD_t fd) { +/*@observer@*/ static const char * getFdErrstr (FD_t fd) + /*@*/ +{ const char *errstr = NULL; #ifdef HAVE_ZLIB_H @@ -2267,7 +2357,8 @@ FDIO_t bzdio = /*@-compmempass@*/ &bzdio_s /*@=compmempass@*/ ; /* =============================================================== */ -const char *Fstrerror(FD_t fd) { +const char *Fstrerror(FD_t fd) +{ if (fd == NULL) return strerror(errno); FDSANE(fd); @@ -2302,7 +2393,8 @@ DBGIO(fd, (stderr, "==> Fread(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned return rc; } -size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd) { +size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd) +{ fdio_write_function_t *_write; int rc; @@ -2356,7 +2448,8 @@ DBGIO(fd, (stderr, "==> Fseek(%p,%ld,%d) %s\n", fd, (long)offset, whence, fdbg(f return rc; } -int Fclose(FD_t fd) { +int Fclose(FD_t fd) +{ int rc = 0, ec = 0; FDSANE(fd); @@ -2436,6 +2529,7 @@ static inline void cvtfmode (const char *m, /*@out@*/ char *stdio, size_t nstdio, /*@out@*/ char *other, size_t nother, /*@out@*/ const char **end, /*@out@*/ int * f) + /*@modifies *stdio, *other, *end, *f @*/ { int flags = 0; char c; @@ -2519,7 +2613,7 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n", fd, fmode, fdbg(fd)); strncat(zstdio, other, sizeof(zstdio) - strlen(zstdio)); if (end == NULL && other[0] == '\0') - /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ if (end && *end) { if (!strcmp(end, "fdio")) { @@ -2557,14 +2651,14 @@ fprintf(stderr, "*** Fdopen fpio fp %p\n", (void *)fp); } } else if (other[0] != '\0') { for (end = other; *end && strchr("0123456789fh", *end); end++) - ; + {}; if (*end == '\0') { iof = gzdio; fd = gzdFdopen(fd, zstdio); } } if (iof == NULL) - /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ if (!noLibio) { FILE * fp = NULL; @@ -2592,7 +2686,7 @@ DBGIO(fd, (stderr, "==> fopencookie(%p,\"%s\",*%p) returns fp %p\n", fd, stdio, } DBGIO(fd, (stderr, "==> Fdopen(%p,\"%s\") returns fd %p %s\n", ofd, fmode, (fd ? fd : NULL), fdbg(fd))); - /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ } FD_t Fopen(const char *path, const char *fmode) @@ -2688,7 +2782,8 @@ int Fflush(FD_t fd) return 0; } -int Ferror(FD_t fd) { +int Ferror(FD_t fd) +{ int i, rc = 0; if (fd == NULL) return -1; @@ -2718,7 +2813,8 @@ DBGIO(fd, (stderr, "==> Ferror(%p) rc %d %s\n", fd, rc, fdbg(fd))); return rc; } -int Fileno(FD_t fd) { +int Fileno(FD_t fd) +{ int i, rc = -1; for (i = fd->nfps ; rc == -1 && i >= 0; i--) { @@ -2729,7 +2825,8 @@ DBGIO(fd, (stderr, "==> Fileno(%p) rc %d %s\n", (fd ? fd : NULL), rc, fdbg(fd))) } /* XXX this is naive */ -int Fcntl(FD_t fd, int op, void *lip) { +int Fcntl(FD_t fd, int op, void *lip) +{ return fcntl(Fileno(fd), op, lip); } @@ -2738,13 +2835,15 @@ int Fcntl(FD_t fd, int op, void *lip) { */ /* XXX falloc.c: analogues to pread(3)/pwrite(3). */ -ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset) { +ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset) +{ if (Fseek(fd, offset, SEEK_SET) < 0) return -1; return Fread(buf, sizeof(char), count, fd); } -ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset) { +ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset) +{ if (Fseek(fd, offset, SEEK_SET) < 0) return -1; return Fwrite(buf, sizeof(char), count, fd); diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index 53737a983..468f0fa03 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -309,13 +309,13 @@ int Access(const char * path, int amode) int Glob(const char * pattern, int flags, int errfunc(const char * epath, int eerrno), /*@out@*/ glob_t * pglob) - /*@modifies *pglob @*/; + /*@modifies *pglob, fileSystem @*/; /** \ingroup rpmrpc * globfree(3) clone. */ void Globfree( /*@only@*/ glob_t * pglob) - /*@modifies *pglob @*/; + /*@modifies *pglob, fileSystem @*/; /** \ingroup rpmrpc @@ -435,7 +435,8 @@ typedef enum ftperrCode_e { /** \ingroup rpmio */ /*@unused@*/ -/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd) /*@*/; +/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd) + /*@modifies fd @*/; /** \ingroup rpmio */ diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h index 98103d1ff..05cae0515 100644 --- a/rpmio/rpmio_internal.h +++ b/rpmio/rpmio_internal.h @@ -142,14 +142,19 @@ extern int _rpmio_debug; extern "C" { #endif -int fdFgets(FD_t fd, char * buf, size_t len); +int fdFgets(FD_t fd, char * buf, size_t len) + /*@modifies *buf, fd, fileSystem @*/; /*@null@*/ FD_t ftpOpen(const char *url, /*@unused@*/ int flags, - /*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret); -int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg); -int ftpCmd(const char * cmd, const char * url, const char * arg2); + /*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret) + /*@modifies *uret, fileSystem @*/; +int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg) + /*@modifies data, fileSystem @*/; +int ftpCmd(const char * cmd, const char * url, const char * arg2) + /*@modifies fileSystem @*/; -int ufdClose( /*@only@*/ void * cookie); +int ufdClose( /*@only@*/ void * cookie) + /*@modified cookie, fileSystem @*/; /** \ingroup rpmio */ @@ -168,7 +173,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) /*@modifies fd @*/ { FDSANE(fd); + /*@-assignexpose@*/ fd->fps[fd->nfps].io = io; + /*@=assignexpose@*/ } /** \ingroup rpmio @@ -178,9 +185,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) /*@*/ { FDSANE(fd); - /*@+voidabstract@*/ + /*@+voidabstract -retexpose@*/ return ((FILE *)fd->fps[fd->nfps].fp); - /*@=voidabstract@*/ + /*@=voidabstract =retexpose@*/ } /** \ingroup rpmio @@ -190,7 +197,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) /*@*/ { FDSANE(fd); + /*@-retexpose@*/ return fd->fps[fd->nfps].fp; + /*@=retexpose@*/ } /** \ingroup rpmio @@ -200,7 +209,9 @@ void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) /*@modifies fd @*/ { FDSANE(fd); + /*@-assignexpose@*/ fd->fps[fd->nfps].fp = fp; + /*@=assignexpose@*/ } /** \ingroup rpmio @@ -316,7 +327,7 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc) */ /*@unused@*/ static inline void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp) - /*@modifies *fp @*/ + /*@modifies *fp, fileSystem @*/ { int opx; if (fd == NULL || fd->stats == NULL) return; @@ -352,7 +363,9 @@ void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) { FDSANE(fd); fd->syserrno = syserrno; + /*@-assignexpose@*/ fd->errcookie = errcookie; + /*@=assignexpose@*/ } /** \ingroup rpmio @@ -391,9 +404,11 @@ void fdSetCpioPos(FD_t fd, long int cpioPos) FD_t c2f(/*@null@*/ void * cookie) /*@*/ { + /*@-castexpose@*/ FD_t fd = (FD_t) cookie; + /*@=castexpose@*/ FDSANE(fd); - /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/ } /** \ingroup rpmio diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c index 65c48fba1..088448868 100644 --- a/rpmio/rpmlog.c +++ b/rpmio/rpmlog.c @@ -51,6 +51,7 @@ void rpmlogPrint(FILE *f) if (f == NULL) f = stderr; + if (recs) for (i = 0; i < nrecs; i++) { rpmlogRec rec = recs + i; if (rec->message && *rec->message) @@ -62,6 +63,7 @@ void rpmlogClose (void) { int i; + if (recs) for (i = 0; i < nrecs; i++) { rpmlogRec rec = recs + i; rec->message = _free(rec->message); @@ -95,7 +97,8 @@ rpmlogCallback rpmlogSetCallback(rpmlogCallback cb) return ocb; } -static char *rpmlogMsgPrefix[] = { +/*@-readonlytrans@*/ /* FIX: double indeirection. */ +/*@observer@*/ static char *rpmlogMsgPrefix[] = { N_("fatal error: "),/*!< RPMLOG_EMERG */ N_("fatal error: "),/*!< RPMLOG_ALERT */ N_("fatal error: "),/*!< RPMLOG_CRIT */ @@ -105,6 +108,7 @@ static char *rpmlogMsgPrefix[] = { "", /*!< RPMLOG_INFO */ "D: ", /*!< RPMLOG_DEBUG */ }; +/*@=readonlytrans@*/ #if !defined(HAVE_VSNPRINTF) static inline int vsnprintf(char * buf, /*@unused@*/ int nb, @@ -115,6 +119,7 @@ static inline int vsnprintf(char * buf, /*@unused@*/ int nb, #endif static void vrpmlog (unsigned code, const char *fmt, va_list ap) + /*@modifies internalState @*/ { int pri = RPMLOG_PRI(code); int mask = RPMLOG_MASK(pri); diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c index 21eed127e..f3d67a769 100644 --- a/rpmio/rpmrpc.c +++ b/rpmio/rpmrpc.c @@ -16,7 +16,9 @@ extern int _rpmio_debug; /*@=redecl@*/ /* =============================================================== */ -static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode) { +static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode) + /*@modifies fileSystem @*/ +{ int rc; if ((rc = ftpCmd("MKD", path, NULL)) != 0) return rc; @@ -29,28 +31,37 @@ static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode) { return rc; } -static int ftpChdir(const char * path) { +static int ftpChdir(const char * path) + /*@modifies fileSystem @*/ +{ return ftpCmd("CWD", path, NULL); } -static int ftpRmdir(const char * path) { +static int ftpRmdir(const char * path) + /*@modifies fileSystem @*/ +{ return ftpCmd("RMD", path, NULL); } -static int ftpRename(const char * oldpath, const char * newpath) { +static int ftpRename(const char * oldpath, const char * newpath) + /*@modifies fileSystem @*/ +{ int rc; if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0) return rc; return ftpCmd("RNTO", newpath, NULL); } -static int ftpUnlink(const char * path) { +static int ftpUnlink(const char * path) + /*@modifies fileSystem @*/ +{ return ftpCmd("DELE", path, NULL); } /* =============================================================== */ /* XXX rebuilddb.c: analogues to mkdir(2)/rmdir(2). */ -int Mkdir (const char *path, mode_t mode) { +int Mkdir (const char * path, mode_t mode) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -72,7 +83,8 @@ int Mkdir (const char *path, mode_t mode) { return mkdir(path, mode); } -int Chdir (const char *path) { +int Chdir (const char * path) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -94,7 +106,8 @@ int Chdir (const char *path) { return chdir(path); } -int Rmdir (const char *path) { +int Rmdir (const char * path) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -118,7 +131,8 @@ int Rmdir (const char *path) { /* XXX rpmdb.c: analogue to rename(2). */ -int Rename (const char *oldpath, const char * newpath) { +int Rename (const char * oldpath, const char * newpath) +{ const char *oe = NULL; const char *ne = NULL; int oldut, newut; @@ -164,7 +178,8 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i return rename(oldpath, newpath); } -int Link (const char *oldpath, const char * newpath) { +int Link (const char * oldpath, const char * newpath) +{ const char *oe = NULL; const char *ne = NULL; int oldut, newut; @@ -249,6 +264,7 @@ static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of static int vfs_split_text (char *p) + /*@modifies *p, columns, column_ptr @*/ { char *original = p; int numcols; @@ -269,6 +285,7 @@ vfs_split_text (char *p) static int is_num (int idx) + /*@*/ { if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9') return 0; @@ -277,6 +294,7 @@ is_num (int idx) static int is_dos_date(/*@null@*/ const char *str) + /*@*/ { if (str != NULL && strlen(str) == 8 && str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL) @@ -286,6 +304,7 @@ is_dos_date(/*@null@*/ const char *str) static int is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) + /*@modifies *tim @*/ { /*@observer@*/ static const char * week = "SunMonTueWedThuFriSat"; const char * pos; @@ -302,6 +321,7 @@ is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) static int is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) + /*@modifies *tim @*/ { /*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec"; const char * pos; @@ -318,6 +338,7 @@ is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) static int is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) + /*@modifies *tim @*/ { const char * p, * p2; @@ -336,6 +357,7 @@ is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) } static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim) + /*@modifies *tim @*/ { long year; @@ -367,6 +389,7 @@ static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim) static int vfs_parse_filetype (char c) + /*@*/ { switch (c) { case 'd': return S_IFDIR; @@ -385,6 +408,7 @@ vfs_parse_filetype (char c) } static int vfs_parse_filemode (const char *p) + /*@*/ { /* converts rw-rw-rw- into 0666 */ int res = 0; switch (*(p++)) { @@ -443,6 +467,7 @@ static int vfs_parse_filemode (const char *p) } static int vfs_parse_filedate(int idx, time_t *t) + /*@modifies *t @*/ { /* This thing parses from idx in columns[] array */ char *p; @@ -551,6 +576,7 @@ static int vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st, /*@out@*/ const char ** filename, /*@out@*/ const char ** linkname) + /*@modifies *st, *filename, *linkname @*/ { int idx, idx2, num_cols; int i; @@ -763,7 +789,8 @@ static /*@only@*/ char * ftpBuf = NULL; #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall, - /*@out@*/ struct stat * st, char * rlbuf, size_t rlbufsiz) + /*@out@*/ struct stat * st, char * rlbuf, size_t rlbufsiz) + /*@modifies *st, *rlbuf, fileSystem @*/ { FD_t fd; const char * path; @@ -858,7 +885,8 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall, while (*se && *se != '\n') se++; if (se > s && se[-1] == '\r') se[-1] = '\0'; - if (*se == '\0') break; + if (*se == '\0') + /*@innerbreak@*/ break; *se++ = '\0'; if (!strncmp(s, "total ", sizeof("total ")-1)) continue; @@ -871,25 +899,28 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall, break; case ' ': if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) { - while (*(++n) == ' '); + while (*(++n) == ' ') + {}; bingo++; break; } - for (o = n + 1; *o == ' '; o++); + for (o = n + 1; *o == ' '; o++) + {}; n -= 3; ne = n; break; default: break; } - if (bingo) break; + if (bingo) + /*@innerbreak@*/ break; } if (nbn != (ne - n)) continue; /* Same name length? */ if (strncmp(n, bn, nbn)) continue; /* Same name? */ moretodo = 0; - break; + /*@innerbreak@*/ break; } if (moretodo && se > s) { @@ -940,11 +971,14 @@ exit: } static int ftpStat(const char * path, /*@out@*/ struct stat *st) + /*@modifies *st @*/ { return ftpNLST(path, DO_FTP_STAT, st, NULL, 0); } -static int ftpLstat(const char * path, /*@out@*/ struct stat *st) { +static int ftpLstat(const char * path, /*@out@*/ struct stat *st) + /*@modifies *st @*/ +{ int rc; rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0); if (_rpmio_debug) @@ -952,13 +986,16 @@ fprintf(stderr, "*** ftpLstat(%s) rc %d\n", path, rc); return rc; } -static int ftpReadlink(const char * path, char * buf, size_t bufsiz) { +static int ftpReadlink(const char * path, char * buf, size_t bufsiz) + /*@modifies *buf @*/ +{ return ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz); } static int ftpGlob(const char * path, int flags, int errfunc(const char * epath, int eerno), /*@out@*/ glob_t * pglob) + /*@modifies *pglob, fileSystem @*/ { int rc; @@ -976,7 +1013,9 @@ fprintf(stderr, "*** ftpGlob(%s,0x%x,%p,%p) ftpNLST rc %d\n", path, (unsigned)fl return rc; } -static void ftpGlobfree(glob_t * pglob) { +static void ftpGlobfree(glob_t * pglob) + /*@modifies *pglob @*/ +{ if (_rpmio_debug) fprintf(stderr, "*** ftpGlobfree(%p)\n", pglob); if (pglob->gl_offs == -1) { /* XXX HACK HACK HACK */ @@ -985,7 +1024,8 @@ fprintf(stderr, "*** ftpGlobfree(%p)\n", pglob); } } -int Stat(const char * path, struct stat * st) { +int Stat(const char * path, struct stat * st) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -1009,7 +1049,8 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st); return stat(path, st); } -int Lstat(const char * path, struct stat * st) { +int Lstat(const char * path, struct stat * st) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -1033,7 +1074,8 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st); return lstat(path, st); } -int Readlink(const char * path, char * buf, size_t bufsiz) { +int Readlink(const char * path, char * buf, size_t bufsiz) +{ const char * lpath; int ut = urlPath(path, &lpath); @@ -1055,7 +1097,8 @@ int Readlink(const char * path, char * buf, size_t bufsiz) { return readlink(path, buf, bufsiz); } -int Access(const char * path, int amode) { +int Access(const char * path, int amode) +{ const char * lpath; int ut = urlPath(path, &lpath); diff --git a/rpmio/rpmurl.h b/rpmio/rpmurl.h index f862de5aa..a08b565db 100644 --- a/rpmio/rpmurl.h +++ b/rpmio/rpmurl.h @@ -58,8 +58,8 @@ extern int url_iobuf_size; * @param msg debugging identifier (unused) * @return new instance */ -urlinfo urlNew(const char * msg); -urlinfo XurlNew(const char * msg, const char * file, unsigned line); +urlinfo urlNew(const char * msg) /*@*/; +urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/; #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__) /** @@ -68,8 +68,10 @@ urlinfo XurlNew(const char * msg, const char * file, unsigned line); * @param msg debugging identifier (unused) * @return referenced instance */ -urlinfo urlLink(urlinfo u, const char * msg); -urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line); +urlinfo urlLink(urlinfo u, const char * msg) + /*@modifies u @*/; +urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line) + /*@modifies u @*/; #define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__) /** @@ -78,21 +80,26 @@ urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line); * @param msg debugging identifier (unused) * @return dereferenced instance (NULL if freed) */ -urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg); -urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg, const char * file, unsigned line); +urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg) + /*@modifies u @*/; +urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg, + const char * file, unsigned line) + /*@modifies u @*/; #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__) /** * Free cached URL control structures. */ -void urlFreeCache(void); +void urlFreeCache(void) + /*@modifies internalState @*/; /** * Return type of URL. * @param url url string * @return type of url */ -urltype urlIsURL(const char * url) /*@*/; +urltype urlIsURL(const char * url) + /*@*/; /** * Return path component of URL. @@ -109,8 +116,8 @@ urltype urlPath(const char * url, /*@out@*/ const char ** pathp) * @retval u address of new control instance pointer * @return 0 on success, -1 on error */ -int urlSplit(const char * url, /*@out@*/ urlinfo * u) - /*@modifies *u @*/; +int urlSplit(const char * url, /*@out@*/ urlinfo * u) + /*@modifies *u @*/; /** * Copy data from URL to local file. @@ -118,7 +125,8 @@ int urlSplit(const char * url, /*@out@*/ urlinfo * u) * @param dest file name of destination * @return 0 on success, otherwise FTPERR_* code */ -int urlGetFile(const char * url, /*@null@*/ const char * dest); +int urlGetFile(const char * url, /*@null@*/ const char * dest) + /*@modifies fileSystem @*/; #ifdef __cplusplus } diff --git a/rpmio/ugid.h b/rpmio/ugid.h index 9c5ea46bd..b0b07ffec 100644 --- a/rpmio/ugid.h +++ b/rpmio/ugid.h @@ -9,15 +9,23 @@ extern "C" { #endif -/* These may be called w/ a NULL argument to flush the cache -- they return - -1 if the user can't be found */ -int unameToUid(const char * thisUname, /*@out@*/ uid_t * uid); -int gnameToGid(const char * thisGname, /*@out@*/ gid_t * gid); +/* + * These may be called w/ a NULL argument to flush the cache -- they return + * -1 if the user can't be found. + */ +int unameToUid(const char * thisUname, /*@out@*/ uid_t * uid) + /*@modifies *uid @*/; +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 */ -/*@observer@*/ /*@null@*/ char * uidToUname(uid_t uid); +/* + * Call w/ -1 to flush the cache, returns NULL if the user can't be found. + */ +/*@observer@*/ /*@null@*/ char * uidToUname(uid_t uid) + /*@*/; /*@unused@*/ -/*@observer@*/ /*@null@*/ char * gidToGname(gid_t gid); +/*@observer@*/ /*@null@*/ char * gidToGname(gid_t gid) + /*@*/; #ifdef __cplusplus } diff --git a/rpmio/url.c b/rpmio/url.c index 72af1a048..d7d040b74 100644 --- a/rpmio/url.c +++ b/rpmio/url.c @@ -56,7 +56,7 @@ urlinfo XurlLink(urlinfo u, const char *msg, const char *file, unsigned line) URLSANE(u); u->nrefs++; URLDBGREFS(0, (stderr, "--> url %p ++ %d %s at %s:%u\n", u, u->nrefs, msg, file, line)); - return u; + /*@-refcounttrans@*/ return u; /*@=refcounttrans@*/ } urlinfo XurlNew(const char *msg, const char *file, unsigned line) @@ -84,7 +84,7 @@ urlinfo XurlFree(urlinfo u, const char *msg, const char *file, unsigned line) URLSANE(u); URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, line)); if (--u->nrefs > 0) - /*@-refcounttrans@*/ return u; /*@=refcounttrans@*/ + /*@-refcounttrans -retalias@*/ return u; /*@=refcounttrans =retalias@*/ if (u->ctrl) { #ifndef NOTYET void * fp = fdGetFp(u->ctrl); @@ -159,6 +159,7 @@ void urlFreeCache(void) } static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2) + /*@*/ { if (str1 && str2) /*@-nullpass@*/ /* LCL: 2nd arg claims to be NULL */ @@ -169,7 +170,8 @@ static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2) return 0; } -static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo *uret, int mustAsk) +static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk) + /*@modifies *uret @*/ { urlinfo u; int ucx; @@ -305,7 +307,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo *uret, int mustAsk) } static struct urlstring { - const char *leadin; +/*@observer@*/ /*@null@*/ const char * leadin; urltype ret; } urlstrings[] = { { "file://", URL_IS_PATH }, @@ -315,7 +317,8 @@ static struct urlstring { { NULL, URL_IS_UNKNOWN } }; -urltype urlIsURL(const char * url) { +urltype urlIsURL(const char * url) +{ struct urlstring *us; if (url && *url) { @@ -456,7 +459,8 @@ int urlSplit(const char * url, urlinfo *uret) return 0; } -int urlGetFile(const char * url, const char * dest) { +int urlGetFile(const char * url, const char * dest) +{ int rc; FD_t sfd = NULL; FD_t tfd = NULL; |