diff options
author | jbj <devnull@localhost> | 2001-04-29 01:05:43 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-04-29 01:05:43 +0000 |
commit | 3b5820c4205e440d9aad5c5d626721ee30b12292 (patch) | |
tree | b1f0a694903aef1dd937539e1b06c8b0947fb67c /build | |
parent | 6a0524ed57548de92daa4b6cf8ee9d2ab39d7a42 (diff) | |
download | librpm-tizen-3b5820c4205e440d9aad5c5d626721ee30b12292.tar.gz librpm-tizen-3b5820c4205e440d9aad5c5d626721ee30b12292.tar.bz2 librpm-tizen-3b5820c4205e440d9aad5c5d626721ee30b12292.zip |
- globalize _free(3) wrapper in rpmlib.h, consistent usage throughout.
- internalize locale insensitive ctype(3) in rpmio.h
- boring lclint annotations and fiddles.
CVS patchset: 4721
CVS date: 2001/04/29 01:05:43
Diffstat (limited to 'build')
-rw-r--r-- | build/build.c | 24 | ||||
-rw-r--r-- | build/expression.c | 27 | ||||
-rw-r--r-- | build/files.c | 327 | ||||
-rw-r--r-- | build/names.c | 71 | ||||
-rw-r--r-- | build/pack.c | 40 | ||||
-rw-r--r-- | build/parseChangelog.c | 4 | ||||
-rw-r--r-- | build/parseDescription.c | 10 | ||||
-rw-r--r-- | build/parseFiles.c | 3 | ||||
-rw-r--r-- | build/parsePreamble.c | 69 | ||||
-rw-r--r-- | build/parsePrep.c | 54 | ||||
-rw-r--r-- | build/parseReqs.c | 20 | ||||
-rw-r--r-- | build/parseScript.c | 8 | ||||
-rw-r--r-- | build/parseSpec.c | 30 | ||||
-rw-r--r-- | build/reqprov.c | 25 | ||||
-rw-r--r-- | build/rpmbuild.h | 11 | ||||
-rw-r--r-- | build/spec.c | 90 |
16 files changed, 400 insertions, 413 deletions
diff --git a/build/build.c b/build/build.c index 403e0c8e7..ecda494ae 100644 --- a/build/build.c +++ b/build/build.c @@ -23,14 +23,14 @@ static void doRmSource(Spec spec) Package pkg; #if 0 - unlink(spec->specFile); + Unlink(spec->specFile); #endif for (p = spec->sources; p != NULL; p = p->next) { if (! (p->flags & RPMBUILD_ISNO)) { const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL); - unlink(fn); - free((void *)fn); + Unlink(fn); + fn = _free(fn); } } @@ -38,8 +38,8 @@ static void doRmSource(Spec spec) for (p = pkg->icon; p != NULL; p = p->next) { if (! (p->flags & RPMBUILD_ISNO)) { const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL); - unlink(fn); - free((void *)fn); + Unlink(fn); + fn = _free(fn); } } } @@ -218,7 +218,7 @@ exit: if (scriptName) { if (!rc) Unlink(scriptName); - free((void *)scriptName); + scriptName = _free(scriptName); } if (u) { switch (u->urltype) { @@ -235,11 +235,11 @@ fprintf(stderr, "*** delMacros\n"); break; } } - FREE(argv); - FREE(buildCmd); - FREE(buildTemplate); - FREE(buildPost); - FREE(buildDirURL); + argv = _free(argv); + buildCmd = _free(buildCmd); + buildTemplate = _free(buildTemplate); + buildPost = _free(buildPost); + buildDirURL = _free(buildDirURL); return rc; } @@ -303,7 +303,7 @@ int buildSpec(Spec spec, int what, int test) doRmSource(spec); if (what & RPMBUILD_RMSPEC) - unlink(spec->specFile); + Unlink(spec->specFile); exit: if (rc && rpmlogGetNrecs() > 0) { diff --git a/build/expression.c b/build/expression.c index b8e34072f..abdfb3e2c 100644 --- a/build/expression.c +++ b/build/expression.c @@ -67,8 +67,9 @@ static Value valueMakeString(/*@only@*/ const char *s) static void valueFree( /*@only@*/ Value v) { if (v) { - if (v->type == VALUE_TYPE_STRING) free((void *)v->data.s); - free(v); + if (v->type == VALUE_TYPE_STRING) + v->data.s = _free(v->data.s); + v = _free(v); } } @@ -182,7 +183,7 @@ static int rdToken(ParseState state) char *p = state->p; /* Skip whitespace before the next token. */ - while (*p && isspace(*p)) p++; + while (*p && xisspace(*p)) p++; switch (*p) { case '\0': @@ -257,10 +258,10 @@ static int rdToken(ParseState state) break; default: - if (isdigit(*p)) { + if (xisdigit(*p)) { char temp[EXPRBUFSIZ], *t = temp; - while (*p && isdigit(*p)) + while (*p && xisdigit(*p)) *t++ = *p++; *t++ = '\0'; p--; @@ -268,10 +269,10 @@ static int rdToken(ParseState state) token = TOK_INTEGER; v = valueMakeInteger(atoi(temp)); - } else if (isalpha(*p)) { + } else if (xisalpha(*p)) { char temp[EXPRBUFSIZ], *t = temp; - while (*p && (isalnum(*p) || *p == '_')) + while (*p && (xisalnum(*p) || *p == '_')) *t++ = *p++; *t++ = '\0'; p--; @@ -649,14 +650,14 @@ int parseExpressionBoolean(Spec spec, const char *expr) /* Parse the expression. */ v = doLogical(&state); if (!v) { - free(state.str); + state.str = _free(state.str); return -1; } /* If the next token is not TOK_EOF, we have a syntax error. */ if (state.nextToken != TOK_EOF) { rpmError(RPMERR_BADSPEC, _("syntax error in expression\n")); - free(state.str); + state.str = _free(state.str); return -1; } @@ -673,7 +674,7 @@ int parseExpressionBoolean(Spec spec, const char *expr) break; } - free(state.str); + state.str = _free(state.str); valueFree(v); return result; } @@ -696,14 +697,14 @@ char * parseExpressionString(Spec spec, const char *expr) /* Parse the expression. */ v = doLogical(&state); if (!v) { - free(state.str); + state.str = _free(state.str); return NULL; } /* If the next token is not TOK_EOF, we have a syntax error. */ if (state.nextToken != TOK_EOF) { rpmError(RPMERR_BADSPEC, _("syntax error in expression\n")); - free(state.str); + state.str = _free(state.str); return NULL; } @@ -722,7 +723,7 @@ char * parseExpressionString(Spec spec, const char *expr) break; } - free(state.str); + state.str = _free(state.str); valueFree(v); return result; } diff --git a/build/files.c b/build/files.c index d6084babc..1b8fa9a3d 100644 --- a/build/files.c +++ b/build/files.c @@ -26,28 +26,32 @@ /*@access TFI_t @*/ /*@access FD_t @*/ -#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;} -#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;} #define MAXDOCDIR 1024 extern int _noDirTokens; -#define SPECD_DEFFILEMODE (1<<0) -#define SPECD_DEFDIRMODE (1<<1) -#define SPECD_DEFUID (1<<2) -#define SPECD_DEFGID (1<<3) -#define SPECD_DEFVERIFY (1<<4) - -#define SPECD_FILEMODE (1<<8) -#define SPECD_DIRMODE (1<<9) -#define SPECD_UID (1<<10) -#define SPECD_GID (1<<11) -#define SPECD_VERIFY (1<<12) +/** + */ +typedef enum specdFlags_e { + SPECD_DEFFILEMODE = (1 << 0), + SPECD_DEFDIRMODE = (1 << 1), + SPECD_DEFUID = (1 << 2), + SPECD_DEFGID = (1 << 3), + SPECD_DEFVERIFY = (1 << 4), + + SPECD_FILEMODE = (1 << 8), + SPECD_DIRMODE = (1 << 9), + SPECD_UID = (1 << 10), + SPECD_GID = (1 << 11), + SPECD_VERIFY = (1 << 12) +} specdFlags; /** */ -typedef struct { +typedef struct FileListRec_s { struct stat fl_st; #define fl_dev fl_st.st_dev #define fl_ino fl_st.st_ino @@ -59,26 +63,26 @@ typedef struct { #define fl_size fl_st.st_size #define fl_mtime fl_st.st_mtime - const char *diskURL; /* get file from here */ - const char *fileURL; /* filename in cpio archive */ - /*@observer@*/ const char *uname; - /*@observer@*/ const char *gname; +/*@only@*/ const char * diskURL; /* get file from here */ +/*@only@*/ const char * fileURL; /* filename in cpio archive */ +/*@observer@*/ const char * uname; +/*@observer@*/ const char * gname; int flags; - int specdFlags; /* which attributes have been explicitly specified. */ + specdFlags specdFlags; /* which attributes have been explicitly specified. */ int verifyFlags; - const char *langs; /* XXX locales separated with | */ -} FileListRec; +/*@only@*/ const char *langs; /* XXX locales separated with | */ +} * FileListRec; /** */ -typedef struct { - const char *ar_fmodestr; - const char *ar_dmodestr; - const char *ar_user; - const char *ar_group; +typedef struct AttrRec_s { + const char * ar_fmodestr; + const char * ar_dmodestr; + const char * ar_user; + const char * ar_group; mode_t ar_fmode; mode_t ar_dmode; -} AttrRec; +} * AttrRec; /** */ @@ -87,9 +91,9 @@ static int multiLib = 0; /* MULTILIB */ /** * Package file tree walk data. */ -struct FileList { - const char *buildRootURL; - const char *prefix; +typedef struct FileList_s { +/*@only@*/ const char * buildRootURL; +/*@only@*/ const char * prefix; int fileCount; int totalFileSize; @@ -101,28 +105,28 @@ struct FileList { int isDir; int inFtw; int currentFlags; - int currentSpecdFlags; + specdFlags currentSpecdFlags; int currentVerifyFlags; - AttrRec cur_ar; - AttrRec def_ar; - int defSpecdFlags; + struct AttrRec_s cur_ar; + struct AttrRec_s def_ar; + specdFlags defSpecdFlags; int defVerifyFlags; int nLangs; - /*@only@*/ const char **currentLangs; +/*@only@*/ const char ** currentLangs; /* Hard coded limit of MAXDOCDIR docdirs. */ /* If you break it you are doing something wrong. */ - const char *docDirs[MAXDOCDIR]; + const char * docDirs[MAXDOCDIR]; int docDirCount; - FileListRec *fileList; +/*@only@*/ FileListRec fileList; int fileListRecsAlloced; int fileListRecsUsed; -}; +} * FileList; /** */ -static void nullAttrRec(/*@out@*/AttrRec *ar) +static void nullAttrRec(/*@out@*/ AttrRec ar) { ar->ar_fmodestr = NULL; ar->ar_dmodestr = NULL; @@ -134,20 +138,20 @@ static void nullAttrRec(/*@out@*/AttrRec *ar) /** */ -static void freeAttrRec(AttrRec *ar) +static void freeAttrRec(AttrRec ar) { - FREE(ar->ar_fmodestr); - FREE(ar->ar_dmodestr); - FREE(ar->ar_user); - FREE(ar->ar_group); + ar->ar_fmodestr = _free(ar->ar_fmodestr); + ar->ar_dmodestr = _free(ar->ar_dmodestr); + ar->ar_user = _free(ar->ar_user); + ar->ar_group = _free(ar->ar_group); /* XXX doesn't free ar (yet) */ } /** */ -static void dupAttrRec(AttrRec *oar, /*@out@*/ AttrRec *nar) +static void dupAttrRec(const AttrRec oar, /*@in@*/ /*@out@*/ AttrRec nar) { - if (oar == nar) /* XXX pathological paranoia */ + if (oar == nar) return; freeAttrRec(nar); nar->ar_fmodestr = (oar->ar_fmodestr ? xstrdup(oar->ar_fmodestr) : NULL); @@ -161,7 +165,7 @@ static void dupAttrRec(AttrRec *oar, /*@out@*/ AttrRec *nar) #if 0 /** */ -static void dumpAttrRec(const char *msg, AttrRec *ar) { +static void dumpAttrRec(const char *msg, AttrRec ar) { if (msg) fprintf(stderr, "%s:\t", msg); fprintf(stderr, "(%s, %s, %s, %s)\n", @@ -235,21 +239,22 @@ static char *strtokWithQuotes(char *s, char *delim) */ static void timeCheck(int tc, Header h) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; int *mtime; - char **files; - int count, x, currentTime; - - headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &files, &count); - headerGetEntry(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL); + const char ** files; + int fnt; + int count, x; + time_t currentTime = time(NULL); - currentTime = time(NULL); + hge(h, RPMTAG_OLDFILENAMES, &fnt, (void **) &files, &count); + hge(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL); for (x = 0; x < count; x++) { - if (currentTime - mtime[x] > tc) { + if ((currentTime - mtime[x]) > tc) rpmMessage(RPMMESS_WARNING, _("TIMECHECK failure: %s\n"), files[x]); - } } - FREE(files); + files = hfd(files, fnt); } /** @@ -276,14 +281,14 @@ VFA_t verifyAttrs[] = { /** * @param fl package file tree walk data */ -static int parseForVerify(char *buf, struct FileList *fl) +static int parseForVerify(char *buf, FileList fl) { char *p, *pe, *q; const char *name; int *resultVerify; int not; int verifyFlags; - int *specdFlags; + specdFlags * specdFlags; if ((p = strstr(buf, (name = "%verify"))) != NULL) { resultVerify = &(fl->currentVerifyFlags); @@ -366,13 +371,14 @@ static int parseForVerify(char *buf, struct FileList *fl) /** * @param fl package file tree walk data */ -static int parseForAttr(char *buf, struct FileList *fl) +static int parseForAttr(char *buf, FileList fl) { char *p, *pe, *q; const char *name; int x; - AttrRec arbuf, *ar = &arbuf, *ret_ar; - int *specdFlags = NULL; + struct AttrRec_s arbuf; + AttrRec ar = &arbuf, ret_ar; + specdFlags * specdFlags; if ((p = strstr(buf, (name = "%attr"))) != NULL) { ret_ar = &(fl->cur_ar); @@ -490,7 +496,7 @@ static int parseForAttr(char *buf, struct FileList *fl) /** * @param fl package file tree walk data */ -static int parseForConfig(char *buf, struct FileList *fl) +static int parseForConfig(char *buf, FileList fl) { char *p, *pe, *q; const char *name; @@ -555,7 +561,7 @@ static int langCmp(const void * ap, const void *bp) { /** * @param fl package file tree walk data */ -static int parseForLang(char *buf, struct FileList *fl) +static int parseForLang(char *buf, FileList fl) { char *p, *pe, *q; const char *name; @@ -642,7 +648,7 @@ static int parseForLang(char *buf, struct FileList *fl) /** */ -static int parseForRegexLang(const char *fileName, /*@out@*/char **lang) +static int parseForRegexLang(const char * fileName, /*@out@*/ char ** lang) { static int initialized = 0; static int hasRegex = 0; @@ -659,13 +665,14 @@ static int parseForRegexLang(const char *fileName, /*@out@*/char **lang) rc = 1; else if (regcomp(&compiledPatt, patt, REG_EXTENDED)) rc = -1; - free((void *)patt); + patt = _free(patt); if (rc) return rc; hasRegex = 1; initialized = 1; } + memset(matches, 0, sizeof(matches)); if (! hasRegex || regexec(&compiledPatt, fileName, 2, matches, REG_NOTEOL)) return 1; @@ -699,7 +706,7 @@ static int parseForRegexMultiLib(const char *fileName) rc = 1; else if (regcomp(&compiledPatt, patt, REG_EXTENDED | REG_NOSUB)) rc = -1; - free((void *)patt); + patt = _free(patt); if (rc) return rc; hasRegex = 1; @@ -737,7 +744,7 @@ VFA_t virtualFileAttributes[] = { * @param fl package file tree walk data */ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf, - struct FileList *fl, const char **fileName) + FileList fl, const char ** fileName) { char *s, *t; int res, specialDoc = 0; @@ -825,7 +832,7 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf, ddir = rpmGetPath("%{_docdir}/", n, "-", v, NULL); strcpy(buf, ddir); - free((void *)ddir); + ddir = _free(ddir); } /* XXX FIXME: this is easy to do as macro expansion */ @@ -856,15 +863,15 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf, */ static int compareFileListRecs(const void *ap, const void *bp) { - const char *a = ((FileListRec *)ap)->fileURL; - const char *b = ((FileListRec *)bp)->fileURL; + const char *a = ((FileListRec)ap)->fileURL; + const char *b = ((FileListRec)bp)->fileURL; return strcmp(a, b); } /** * @param fl package file tree walk data */ -static int isDoc(struct FileList *fl, const char *fileName) +static int isDoc(FileList fl, const char * fileName) { int x = fl->docDirCount; @@ -880,10 +887,10 @@ static int isDoc(struct FileList *fl, const char *fileName) * @todo only %lang for now, finish other attributes later. * @param fl package file tree walk data */ -static void checkHardLinks(struct FileList *fl) +static void checkHardLinks(FileList fl) { char nlangs[BUFSIZ]; - FileListRec *ilp, *jlp; + FileListRec ilp, jlp; int i, j; for (i = 0; i < fl->fileListRecsUsed; i++) { @@ -921,7 +928,7 @@ static void checkHardLinks(struct FileList *fl) if (te == nlangs) continue; - free((void *)ilp->langs); + ilp->langs = _free(ilp->langs); ilp->langs = xstrdup(nlangs); for (j = i + 1; j < fl->fileListRecsUsed; j++) { jlp = fl->fileList + j; @@ -934,7 +941,7 @@ static void checkHardLinks(struct FileList *fl) if (ilp->fl_dev != jlp->fl_dev) continue; jlp->flags |= RPMFILE_SPECFILE; - free((void *)jlp->langs); + jlp->langs = _free(jlp->langs); jlp->langs = xstrdup(nlangs); } } @@ -950,15 +957,15 @@ static void checkHardLinks(struct FileList *fl) * @todo Remove RPMTAG_OLDFILENAMES, add dirname/basename instead. * @param fl package file tree walk data */ -static void genCpioListAndHeader(struct FileList *fl, TFI_t *cpioList, - Header h, int isSrc) +static void genCpioListAndHeader(/*@partial@*/ FileList fl, + TFI_t *cpioList, Header h, int isSrc) { int _addDotSlash = !(isSrc || rpmExpandNumeric("%{_noPayloadPrefix}")); uint_32 multiLibMask = 0; int apathlen = 0; int dpathlen = 0; int skipLen = 0; - FileListRec *flp; + FileListRec flp; char buf[BUFSIZ]; int i; @@ -1043,7 +1050,7 @@ static void genCpioListAndHeader(struct FileList *fl, TFI_t *cpioList, if (flp->flags & RPMFILE_MULTILIB_MASK) multiLibMask |= - (1 << ((flp->flags & RPMFILE_MULTILIB_MASK)) + (1u << ((flp->flags & RPMFILE_MULTILIB_MASK)) >> RPMFILE_MULTILIB_SHIFT); /* @@ -1177,12 +1184,8 @@ static void genCpioListAndHeader(struct FileList *fl, TFI_t *cpioList, fi->type = TR_ADDED; loadFi(h, fi); - if (fi->dnl) { - free((void *)fi->dnl); fi->dnl = NULL; - } - if (fi->bnl) { - free((void *)fi->bnl); fi->bnl = NULL; - } + fi->dnl = _free(fi->dnl); + fi->bnl = _free(fi->bnl); fi->dnl = xmalloc(fi->fc * sizeof(*fi->dnl) + dpathlen); d = (char *)(fi->dnl + fi->fc); @@ -1247,26 +1250,27 @@ static void genCpioListAndHeader(struct FileList *fl, TFI_t *cpioList, if (cpioList) *cpioList = fi; else - free(fi); + fi = _free(fi); } } /** */ -static void freeFileList(FileListRec *fileList, int count) +static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList, int count) { while (count--) { - FREE(fileList[count].diskURL); - FREE(fileList[count].fileURL); - FREE(fileList[count].langs); + fileList[count].diskURL = _free(fileList[count].diskURL); + fileList[count].fileURL = _free(fileList[count].fileURL); + fileList[count].langs = _free(fileList[count].langs); } - FREE(fileList); + fileList = _free(fileList); + return NULL; } /** * @param fl package file tree walk data */ -static int addFile(struct FileList *fl, const char * diskURL, struct stat *statp) +static int addFile(FileList fl, const char * diskURL, struct stat *statp) { const char *fileURL = diskURL; struct stat statbuf; @@ -1384,7 +1388,7 @@ static int addFile(struct FileList *fl, const char * diskURL, struct stat *statp fl->fileListRecsAlloced * sizeof(*(fl->fileList))); } - { FileListRec * flp = &fl->fileList[fl->fileListRecsUsed]; + { FileListRec flp = &fl->fileList[fl->fileListRecsUsed]; flp->fl_st = *statp; /* structure assignment */ flp->fl_mode = fileMode; @@ -1439,7 +1443,7 @@ static int addFile(struct FileList *fl, const char * diskURL, struct stat *statp /** * @param fl package file tree walk data */ -static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl, +static int processBinaryFile(/*@unused@*/Package pkg, FileList fl, const char *fileURL) { int doGlob; @@ -1478,9 +1482,9 @@ static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl, if (rc == 0 && argc >= 1 && !myGlobPatternP(argv[0])) { for (i = 0; i < argc; i++) { rc = addFile(fl, argv[i], NULL); - free((void *)argv[i]); + argv[i] = _free(argv[i]); } - free((void *)argv); + argv = _free(argv); } else { rpmError(RPMERR_BADSPEC, _("File not found by glob: %s\n"), diskURL); @@ -1491,8 +1495,7 @@ static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl, } exit: - if (diskURL) - free((void *)diskURL); + diskURL = _free(diskURL); if (rc) fl->processingFailed = 1; return rc; @@ -1503,11 +1506,13 @@ exit: static int processPackageFiles(Spec spec, Package pkg, int installSpecialDoc, int test) { - struct FileList fl; + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + struct FileList_s fl; char *s, **files, **fp; const char *fileName; char buf[BUFSIZ]; - AttrRec specialDocAttrRec; + struct AttrRec_s arbuf; + AttrRec specialDocAttrRec = &arbuf; char *specialDoc = NULL; #ifdef MULTILIB @@ -1516,11 +1521,12 @@ static int processPackageFiles(Spec spec, Package pkg, multiLib = RPMFILE_MULTILIB(multiLib); #endif /* MULTILIB */ - nullAttrRec(&specialDocAttrRec); + nullAttrRec(specialDocAttrRec); pkg->cpioList = NULL; if (pkg->fileFile) { const char *ffn; + FILE * f; FD_t fd; /* XXX W2DO? urlPath might be useful here. */ @@ -1540,9 +1546,10 @@ static int processPackageFiles(Spec spec, Package pkg, ffn, Fstrerror(fd)); return RPMERR_BADFILENAME; } - free((void *)ffn); + ffn = _free(ffn); - while (fgets(buf, sizeof(buf), (FILE *)fdGetFp(fd))) { + /*@+voidabstract@*/ f = fdGetFp(fd); /*@=voidabstract@*/ + while (fgets(buf, sizeof(buf), f)) { handleComments(buf); if (expandMacros(spec, spec->macros, buf, sizeof(buf))) { rpmError(RPMERR_BADSPEC, _("line: %s\n"), buf); @@ -1558,12 +1565,10 @@ static int processPackageFiles(Spec spec, Package pkg, /* XXX spec->buildRootURL == NULL, then xstrdup("") is returned */ fl.buildRootURL = rpmGenPath(spec->rootURL, spec->buildRootURL, NULL); - if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX, - NULL, (void **)&fl.prefix, NULL)) { + if (hge(pkg->header, RPMTAG_DEFAULTPREFIX, NULL, (void **)&fl.prefix, NULL)) fl.prefix = xstrdup(fl.prefix); - } else { + else fl.prefix = NULL; - } fl.fileCount = 0; fl.totalFileSize = 0; @@ -1619,7 +1624,7 @@ static int processPackageFiles(Spec spec, Package pkg, fl.inFtw = 0; fl.currentFlags = 0; /* turn explicit flags into %def'd ones (gosh this is hacky...) */ - fl.currentSpecdFlags = fl.defSpecdFlags>>8; + fl.currentSpecdFlags = ((unsigned)fl.defSpecdFlags) >> 8; fl.currentVerifyFlags = fl.defVerifyFlags; fl.isSpecialDoc = 0; @@ -1627,8 +1632,8 @@ static int processPackageFiles(Spec spec, Package pkg, if (fl.currentLangs) { int i; for (i = 0; i < fl.nLangs; i++) - free((void *)fl.currentLangs[i]); - FREE(fl.currentLangs); + fl.currentLangs[i] = _free(fl.currentLangs[i]); + fl.currentLangs = _free(fl.currentLangs); } fl.nLangs = 0; @@ -1649,9 +1654,9 @@ static int processPackageFiles(Spec spec, Package pkg, if (fl.isSpecialDoc) { /* Save this stuff for last */ - FREE(specialDoc); + specialDoc = _free(specialDoc); specialDoc = xstrdup(fileName); - dupAttrRec(&fl.cur_ar, &specialDocAttrRec); + dupAttrRec(&fl.cur_ar, specialDocAttrRec); } else { processBinaryFile(pkg, &fl, fileName); } @@ -1673,17 +1678,17 @@ static int processPackageFiles(Spec spec, Package pkg, if (fl.currentLangs) { int i; for (i = 0; i < fl.nLangs; i++) - free((void *)fl.currentLangs[i]); - FREE(fl.currentLangs); + fl.currentLangs[i] = _free(fl.currentLangs[i]); + fl.currentLangs = _free(fl.currentLangs); } fl.nLangs = 0; - dupAttrRec(&specialDocAttrRec, &fl.cur_ar); - freeAttrRec(&specialDocAttrRec); + dupAttrRec(specialDocAttrRec, &fl.cur_ar); + freeAttrRec(specialDocAttrRec); processBinaryFile(pkg, &fl, specialDoc); - FREE(specialDoc); + specialDoc = _free(specialDoc); } freeSplitString(files); @@ -1700,8 +1705,8 @@ static int processPackageFiles(Spec spec, Package pkg, timeCheck(spec->timeCheck, pkg->header); exit: - FREE(fl.buildRootURL); - FREE(fl.prefix); + fl.buildRootURL = _free(fl.buildRootURL); + fl.prefix = _free(fl.prefix); freeAttrRec(&fl.cur_ar); freeAttrRec(&fl.def_ar); @@ -1709,14 +1714,13 @@ exit: if (fl.currentLangs) { int i; for (i = 0; i < fl.nLangs; i++) - free((void *)fl.currentLangs[i]); - FREE(fl.currentLangs); + fl.currentLangs[i] = _free(fl.currentLangs[i]); + fl.currentLangs = _free(fl.currentLangs); } - freeFileList(fl.fileList, fl.fileListRecsUsed); - while (fl.docDirCount--) { - FREE(fl.docDirs[fl.docDirCount]); - } + fl.fileList = freeFileList(fl.fileList, fl.fileListRecsUsed); + while (fl.docDirCount--) + fl.docDirs[fl.docDirCount] = _free(fl.docDirs[fl.docDirCount]); return fl.processingFailed; } @@ -1782,7 +1786,7 @@ int processSourceFiles(Spec spec) struct Source *srcPtr; StringBuf sourceFiles; int x, isSpec = 1; - struct FileList fl; + struct FileList_s fl; char *s, **files, **fp; Package pkg; @@ -1815,27 +1819,27 @@ int processSourceFiles(Spec spec) } } - { const char *s; - s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""), + { const char * sfn; + sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""), "%{_sourcedir}/", srcPtr->source, NULL); - appendLineStringBuf(sourceFiles, s); - free((void *)s); + appendLineStringBuf(sourceFiles, sfn); + sfn = _free(sfn); } } for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) { - const char *s; - s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""), + const char * sfn; + sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""), "%{_sourcedir}/", srcPtr->source, NULL); - appendLineStringBuf(sourceFiles, s); - free((void *)s); + appendLineStringBuf(sourceFiles, sfn); + sfn = _free(sfn); } } spec->sourceCpioList = NULL; - fl.fileList = xmalloc((spec->numSources + 1) * sizeof(FileListRec)); + fl.fileList = xmalloc((spec->numSources + 1) * sizeof(*fl.fileList)); fl.processingFailed = 0; fl.fileListRecsUsed = 0; fl.totalFileSize = 0; @@ -1848,7 +1852,7 @@ int processSourceFiles(Spec spec) x = 0; for (fp = files; *fp != NULL; fp++) { const char * diskURL, *diskPath; - FileListRec *flp; + FileListRec flp; diskURL = *fp; SKIPSPACE(diskURL); @@ -1864,7 +1868,7 @@ int processSourceFiles(Spec spec) diskURL++; } - urlPath(diskURL, &diskPath); + (void) urlPath(diskURL, &diskPath); flp->diskURL = xstrdup(diskURL); diskPath = strrchr(diskPath, '/'); @@ -1904,7 +1908,7 @@ int processSourceFiles(Spec spec) } freeStringBuf(sourceFiles); - freeFileList(fl.fileList, fl.fileListRecsUsed); + fl.fileList = freeFileList(fl.fileList, fl.fileListRecsUsed); return fl.processingFailed; } @@ -2159,7 +2163,7 @@ static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib) myargv[0] = (dm->argv[0] ? rpmExpand(dm->argv[0], NULL) : NULL); if (!(myargv[0] && *myargv[0] != '%')) { - free(myargv[0]); + myargv[0] = _free(myargv[0]); continue; } @@ -2168,8 +2172,7 @@ static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib) #if 0 if (*myargv[0] != '/') { /* XXX FIXME: stat script here */ - free(myargv[0]); - myargv[0] = NULL; + myargv[0] = _free(myargv[0]); continue; } #endif @@ -2183,11 +2186,8 @@ static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib) getStringBuf(writeBuf), writeBytes, failnonzero); /* Free expanded args */ - for (i = 0; i < 4; i++) { - if (myargv[i] == NULL) continue; - free(myargv[i]); - myargv[i] = NULL; - } + for (i = 0; i < 4; i++) + myargv[i] = _free(myargv[i]); if (readBuf == NULL) { rc = RPMERR_EXEC; @@ -2259,34 +2259,38 @@ static void printDepMsg(DepMsg_t *dm, int count, const char **names, */ static void printDeps(Header h) { - const char **names = NULL; - const char **versions = NULL; - int *flags = NULL; - DepMsg_t *dm; - int type, count; + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; + const char ** names = NULL; + int dnt = -1; + const char ** versions = NULL; + int dvt = -1; + int * flags = NULL; + DepMsg_t * dm; + int count; for (dm = depMsgs; dm->msg != NULL; dm++) { switch (dm->ntag) { case 0: - FREE(names); + names = hfd(names, dnt); break; case -1: break; default: - FREE(names); - if (!headerGetEntry(h, dm->ntag, &type, (void **) &names, &count)) + names = hfd(names, dnt); + if (!hge(h, dm->ntag, &dnt, (void **) &names, &count)) continue; break; } switch (dm->vtag) { case 0: - FREE(versions); + versions = hfd(versions, dvt); break; case -1: break; default: - FREE(versions); - headerGetEntry(h, dm->vtag, NULL, (void **) &versions, NULL); + versions = hfd(versions, dvt); + hge(h, dm->vtag, &dvt, (void **) &versions, NULL); break; } switch (dm->ftag) { @@ -2296,13 +2300,13 @@ static void printDeps(Header h) case -1: break; default: - headerGetEntry(h, dm->ftag, NULL, (void **) &flags, NULL); + hge(h, dm->ftag, NULL, (void **) &flags, NULL); break; } printDepMsg(dm, count, names, versions, flags); } - FREE(names); - FREE(versions); + names = hfd(names, dnt); + versions = hfd(versions, dvt); } int processBinaryFiles(Spec spec, int installSpecialDoc, int test) @@ -2327,13 +2331,12 @@ int processBinaryFiles(Spec spec, int installSpecialDoc, int test) * XXX However, there is logic in files.c/depends.c that checks for * XXX existence (rather than value) that will need to change as well. */ - if (headerGetEntry(pkg->header, RPMTAG_MULTILIBS, NULL, NULL, NULL)) { + if (headerIsEntry(pkg->header, RPMTAG_MULTILIBS)) { generateDepends(spec, pkg, pkg->cpioList, 1); generateDepends(spec, pkg, pkg->cpioList, 2); } else generateDepends(spec, pkg, pkg->cpioList, 0); printDeps(pkg->header); - } return res; diff --git a/build/names.c b/build/names.c index 6cdbee988..da2787ac5 100644 --- a/build/names.c +++ b/build/names.c @@ -21,9 +21,9 @@ void freeNames(void) { int x; for (x = 0; x < uid_used; x++) - free((void *)unames[x]); + unames[x] = _free(unames[x]); for (x = 0; x < gid_used; x++) - free((void *)gnames[x]); + gnames[x] = _free(gnames[x]); } const char *getUname(uid_t uid) @@ -32,23 +32,18 @@ const char *getUname(uid_t uid) int x; for (x = 0; x < uid_used; x++) { - if (uids[x] == uid) { + if (uids[x] == uid) return unames[x]; - } } /* XXX - This is the other hard coded limit */ if (x == 1024) rpmlog(RPMLOG_CRIT, _("getUname: too many uid's\n")); + uid_used++; pw = getpwuid(uid); uids[x] = uid; - uid_used++; - if (pw) { - unames[x] = xstrdup(pw->pw_name); - } else { - unames[x] = NULL; - } + unames[x] = (pw ? xstrdup(pw->pw_name) : NULL); return unames[x]; } @@ -58,24 +53,18 @@ const char *getUnameS(const char *uname) int x; for (x = 0; x < uid_used; x++) { - if (!strcmp(unames[x],uname)) { + if (!strcmp(unames[x],uname)) return unames[x]; - } } /* XXX - This is the other hard coded limit */ if (x == 1024) rpmlog(RPMLOG_CRIT, _("getUnameS: too many uid's\n")); + uid_used++; pw = getpwnam(uname); - uid_used++; - if (pw) { - uids[x] = pw->pw_uid; - unames[x] = xstrdup(pw->pw_name); - } else { - uids[x] = -1; - unames[x] = xstrdup(uname); - } + uids[x] = (pw ? pw->pw_uid : -1); + unames[x] = (pw ? xstrdup(pw->pw_name) : xstrdup(uname)); return unames[x]; } @@ -85,23 +74,18 @@ const char *getGname(gid_t gid) int x; for (x = 0; x < gid_used; x++) { - if (gids[x] == gid) { + if (gids[x] == gid) return gnames[x]; - } } /* XXX - This is the other hard coded limit */ if (x == 1024) rpmlog(RPMLOG_CRIT, _("getGname: too many gid's\n")); + gid_used++; gr = getgrgid(gid); gids[x] = gid; - gid_used++; - if (gr) { - gnames[x] = xstrdup(gr->gr_name); - } else { - gnames[x] = NULL; - } + gnames[x] = (gr ? xstrdup(gr->gr_name) : NULL); return gnames[x]; } @@ -111,34 +95,28 @@ const char *getGnameS(const char *gname) int x; for (x = 0; x < gid_used; x++) { - if (!strcmp(gnames[x], gname)) { + if (!strcmp(gnames[x], gname)) return gnames[x]; - } } /* XXX - This is the other hard coded limit */ if (x == 1024) rpmlog(RPMLOG_CRIT, _("getGnameS: too many gid's\n")); + gid_used++; gr = getgrnam(gname); - gid_used++; - if (gr) { - gids[x] = gr->gr_gid; - gnames[x] = xstrdup(gr->gr_name); - } else { - gids[x] = -1; - gnames[x] = xstrdup(gname); - } + gids[x] = (gr ? gr->gr_gid : -1); + gnames[x] = (gr ? xstrdup(gr->gr_name) : xstrdup(gname)); return gnames[x]; } time_t *const getBuildTime(void) { - static time_t buildTime = 0; + static time_t buildTime[1]; - if (! buildTime) - buildTime = time(NULL); - return &buildTime; + if (buildTime[0] == 0) + buildTime[0] = time(NULL); + return buildTime; } const char *const buildHost(void) @@ -149,12 +127,11 @@ const char *const buildHost(void) if (! gotit) { gethostname(hostname, sizeof(hostname)); - if ((hbn = /*@-unrecog@*/ gethostbyname(hostname) /*@=unrecog@*/ )) { + if ((hbn = /*@-unrecog@*/ gethostbyname(hostname) /*@=unrecog@*/ )) strcpy(hostname, hbn->h_name); - } else { - rpmMessage(RPMMESS_WARNING, _("Could not canonicalize hostname: %s\n"), - hostname); - } + else + rpmMessage(RPMMESS_WARNING, + _("Could not canonicalize hostname: %s\n"), hostname); gotit = 1; } return(hostname); diff --git a/build/pack.c b/build/pack.c index f6dd4aa72..43fc29a23 100644 --- a/build/pack.c +++ b/build/pack.c @@ -41,7 +41,8 @@ static inline int genSourceRpmName(Spec spec) /** * @todo Create transaction set *much* earlier. */ -static int cpio_doio(FD_t fdo, Header h, CSA_t * csa, const char * fmodeMacro) +static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t * csa, + const char * fmodeMacro) { const char * rootDir = "/"; rpmdb rpmdb = NULL; @@ -68,9 +69,8 @@ static int cpio_doio(FD_t fdo, Header h, CSA_t * csa, const char * fmodeMacro) rc = 1; } - if (failedFile) - free((void *)failedFile); - free((void *)fmode); + failedFile = _free(failedFile); + fmode = _free(fmode); rpmtransFree(ts); return rc; @@ -111,7 +111,7 @@ static StringBuf addFileToTagAux(Spec spec, const char *file, StringBuf sb) fn = rpmGetPath("%{_builddir}/", spec->buildSubdir, "/", file, NULL); fd = Fopen(fn, "r.ufdio"); - if (fn != buf) free((void *)fn); + if (fn != buf) fn = _free(fn); if (fd == NULL || Ferror(fd)) { freeStringBuf(sb); return NULL; @@ -131,12 +131,13 @@ static StringBuf addFileToTagAux(Spec spec, const char *file, StringBuf sb) /** */ -static int addFileToTag(Spec spec, const char *file, Header h, int tag) +static int addFileToTag(Spec spec, const char * file, Header h, int tag) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; StringBuf sb = newStringBuf(); char *s; - if (headerGetEntry(h, tag, NULL, (void **)&s, NULL)) { + if (hge(h, tag, NULL, (void **)&s, NULL)) { appendLineStringBuf(sb, s); headerRemoveEntry(h, tag); } @@ -152,7 +153,7 @@ static int addFileToTag(Spec spec, const char *file, Header h, int tag) /** */ -static int addFileToArrayTag(Spec spec, char *file, Header h, int tag) +static int addFileToArrayTag(Spec spec, const char *file, Header h, int tag) { StringBuf sb = newStringBuf(); char *s; @@ -351,7 +352,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type, break; } if (!(rpmio_flags && *rpmio_flags)) { - if (rpmio_flags) free((void *)rpmio_flags); + rpmio_flags = _free(rpmio_flags); rpmio_flags = xstrdup("w9.gzdio"); } s = strchr(rpmio_flags, '.'); @@ -402,7 +403,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type, rc = RPMERR_BADARG; } } - if (rpmio_flags) free((void *)rpmio_flags); + rpmio_flags = _free(rpmio_flags); if (rc) goto exit; @@ -416,8 +417,9 @@ int writeRPM(Header *hdrp, const char *fileName, int type, * to memory not in the region. <shrug> */ if (Fileno(csa->cpioFdIn) < 0) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; int_32 * archiveSize; - if (headerGetEntry(h, RPMTAG_ARCHIVESIZE, NULL, (void *)&archiveSize, NULL)) + if (hge(h, RPMTAG_ARCHIVESIZE, NULL, (void *)&archiveSize, NULL)) *archiveSize = csa->cpioArchiveSize; } @@ -564,7 +566,7 @@ exit: } if (sigtarget) { Unlink(sigtarget); - free((void *)sigtarget); + sigtarget = _free(sigtarget); } if (rc == 0) @@ -618,7 +620,7 @@ int packageBinaries(Spec spec) { const char * optflags = rpmExpand("%{optflags}", NULL); headerAddEntry(pkg->header, RPMTAG_OPTFLAGS, RPM_STRING_TYPE, optflags, 1); - free((void *)optflags); + optflags = _free(optflags); } genSourceRpmName(spec); @@ -629,7 +631,7 @@ int packageBinaries(Spec spec) char *binRpm, *binDir; binRpm = headerSprintf(pkg->header, binFormat, rpmTagTable, rpmHeaderFormats, &errorString); - free((void *)binFormat); + binFormat = _free(binFormat); if (binRpm == NULL) { const char *name; headerNVR(pkg->header, &name, NULL, NULL); @@ -655,9 +657,9 @@ int packageBinaries(Spec spec) break; } } - free((void *)dn); + dn = _free(dn); } - free((void *)binRpm); + binRpm = _free(binRpm); } memset(csa, 0, sizeof(*csa)); @@ -668,7 +670,7 @@ int packageBinaries(Spec spec) rc = writeRPM(&pkg->header, fn, RPMLEAD_BINARY, csa, spec->passPhrase, NULL); csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageBinaries)"); - free((void *)fn); + fn = _free(fn); if (rc) return rc; } @@ -691,7 +693,7 @@ int packageSources(Spec spec) genSourceRpmName(spec); - FREE(spec->cookie); + spec->cookie = _free(spec->cookie); /* XXX this should be %_srpmdir */ { const char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL); @@ -704,7 +706,7 @@ int packageSources(Spec spec) rc = writeRPM(&spec->sourceHeader, fn, RPMLEAD_SOURCE, csa, spec->passPhrase, &(spec->cookie)); csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageSources)"); - free((void *)fn); + fn = _free(fn); } return rc; } diff --git a/build/parseChangelog.c b/build/parseChangelog.c index 0c81fcd49..19cb19e2c 100644 --- a/build/parseChangelog.c +++ b/build/parseChangelog.c @@ -161,7 +161,7 @@ static int addChangelog(Header h, StringBuf sb) /* name */ name = s; while (*s) s++; - while (s > name && isspace(*s)) { + while (s > name && xisspace(*s)) { *s-- = '\0'; } if (s == name) { @@ -185,7 +185,7 @@ static int addChangelog(Header h, StringBuf sb) s--; /* backup to end of description */ - while ((s > text) && isspace(*s)) { + while ((s > text) && xisspace(*s)) { *s-- = '\0'; } diff --git a/build/parseDescription.c b/build/parseDescription.c index 8cf5ae537..f7052e2df 100644 --- a/build/parseDescription.c +++ b/build/parseDescription.c @@ -53,7 +53,7 @@ int parseDescription(Spec spec) spec->lineNum, poptBadOption(optCon, POPT_BADOPTION_NOALIAS), spec->line); - FREE(argv); + argv = _free(argv); poptFreeContext(optCon); return RPMERR_BADSPEC; } @@ -65,7 +65,7 @@ int parseDescription(Spec spec) rpmError(RPMERR_BADSPEC, _("line %d: Too many names: %s\n"), spec->lineNum, spec->line); - FREE(argv); + argv = _free(argv); poptFreeContext(optCon); return RPMERR_BADSPEC; } @@ -74,7 +74,7 @@ int parseDescription(Spec spec) if (lookupPackage(spec, name, flag, &pkg)) { rpmError(RPMERR_BADSPEC, _("line %d: Package does not exist: %s\n"), spec->lineNum, spec->line); - FREE(argv); + argv = _free(argv); poptFreeContext(optCon); return RPMERR_BADSPEC; } @@ -86,7 +86,7 @@ int parseDescription(Spec spec) if (headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) { rpmError(RPMERR_BADSPEC, _("line %d: Second description\n"), spec->lineNum); - FREE(argv); + argv = _free(argv); poptFreeContext(optCon); return RPMERR_BADSPEC; } @@ -124,7 +124,7 @@ int parseDescription(Spec spec) freeStringBuf(sb); - FREE(argv); + argv = _free(argv); poptFreeContext(optCon); return nextPart; diff --git a/build/parseFiles.c b/build/parseFiles.c index b948ba205..df3e8d9ec 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -105,8 +105,7 @@ int parseFiles(Spec spec) rc = nextPart; exit: - if (argv) - FREE(argv); + argv = _free(argv); if (optCon) poptFreeContext(optCon); diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 19d272f5c..73b5de67a 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -53,7 +53,7 @@ static void addOrAppendListEntry(Header h, int_32 tag, char *line) poptParseArgvString(line, &argc, &argv); if (argc) headerAddOrAppendEntry(h, tag, RPM_STRING_ARRAY_TYPE, argv, argc); - FREE(argv); + argv = _free(argv); } /* Parse a simple part line that only take -n <pkg> or <pkg> */ @@ -99,14 +99,14 @@ static inline int parseYesNo(const char *s) ? 0 : 1); } -struct tokenBits { +typedef struct tokenBits_s { const char * name; - int bits; -}; + rpmsenseFlags bits; +} * tokenBits; /** */ -static struct tokenBits installScriptBits[] = { +static struct tokenBits_s installScriptBits[] = { { "interp", RPMSENSE_INTERP }, { "prereq", RPMSENSE_PREREQ }, { "preun", RPMSENSE_SCRIPT_PREUN }, @@ -120,7 +120,7 @@ static struct tokenBits installScriptBits[] = { /** */ -static struct tokenBits buildScriptBits[] = { +static struct tokenBits_s buildScriptBits[] = { { "prep", RPMSENSE_SCRIPT_PREP }, { "build", RPMSENSE_SCRIPT_BUILD }, { "install", RPMSENSE_SCRIPT_INSTALL }, @@ -130,18 +130,19 @@ static struct tokenBits buildScriptBits[] = { /** */ -static int parseBits(const char * s, struct tokenBits * tokbits, int * bp) +static int parseBits(const char * s, const tokenBits tokbits, + /*@out@*/ rpmsenseFlags * bp) { - struct tokenBits *tb; - const char *se; - int bits = 0; + tokenBits tb; + const char * se; + rpmsenseFlags bits = RPMSENSE_ANY; int c = 0; if (s) { while (*s) { - while ((c = *s) && isspace(c)) s++; + while ((c = *s) && xisspace(c)) s++; se = s; - while ((c = *se) && isalpha(c)) se++; + while ((c = *se) && xisalpha(c)) se++; if (s == se) break; for (tb = tokbits; tb->name; tb++) { @@ -151,7 +152,7 @@ static int parseBits(const char * s, struct tokenBits * tokbits, int * bp) if (tb->name == NULL) break; bits |= tb->bits; - while ((c = *se) && isspace(c)) se++; + while ((c = *se) && xisspace(c)) se++; if (c != ',') break; s = ++se; @@ -168,7 +169,7 @@ static inline char * findLastChar(char * s) char *res = s; while (*s) { - if (! isspace(*s)) + if (! xisspace(*s)) res = s; s++; } @@ -180,16 +181,18 @@ static inline char * findLastChar(char * s) */ static int isMemberInEntry(Header header, const char *name, int tag) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; const char ** names; - int count; + int type, count; - if (!headerGetEntry(header, tag, NULL, (void **)&names, &count)) + if (!hge(header, tag, &type, (void **)&names, &count)) return -1; while (count--) { if (!xstrcasecmp(names[count], name)) break; } - FREE(names); + names = hfd(names, type); return (count >= 0 ? 1 : 0); } @@ -302,7 +305,7 @@ static void fillOutMainPackage(Header h) const char *val = rpmExpand(ot->ot_mac, NULL); if (val && *val != '%') headerAddEntry(h, ot->ot_tag, RPM_STRING_TYPE, (void *)val, 1); - free((void *)val); + val = _free(val); } } } @@ -358,16 +361,17 @@ static int readIcon(Header h, const char *file) rc = RPMERR_BADSPEC; goto exit; } - free((void *)icon); + icon = _free(icon); exit: - FREE(fn); + fn = _free(fn); return rc; } struct spectag * stashSt(Spec spec, Header h, int tag, const char *lang) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; struct spectag *t = NULL; if (spec->st) { @@ -384,7 +388,7 @@ stashSt(Spec spec, Header h, int tag, const char *lang) t->t_msgid = NULL; if (!(t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))) { char *n; - if (headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &n, NULL)) { + if (hge(h, RPMTAG_NAME, NULL, (void **) &n, NULL)) { char buf[1024]; sprintf(buf, "%s(%s)", n, tagName(tag)); t->t_msgid = xstrdup(buf); @@ -408,11 +412,14 @@ extern int noLang; /* XXX FIXME: pass as arg */ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, const char *lang) { + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; char *field = spec->line; char *end; char **array; int multiToken = 0; - int tagflags; + rpmsenseFlags tagflags; + int type; int len; int num; int rc; @@ -499,7 +506,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, } else { const char * specURL = field; - free((void *)buildRootURL); + buildRootURL = _free(buildRootURL); (void) urlPath(specURL, (const char **)&field); if (*field == '\0') field = "/"; buildRootURL = rpmGenPath(spec->rootURL, field, NULL); @@ -516,25 +523,25 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, if (!strcmp(buildRoot, "/")) { rpmError(RPMERR_BADSPEC, _("BuildRoot can not be \"/\": %s\n"), spec->buildRootURL); - free((void *)buildRootURL); + buildRootURL = _free(buildRootURL); return RPMERR_BADSPEC; } - free((void *)buildRootURL); + buildRootURL = _free(buildRootURL); } break; case RPMTAG_PREFIXES: addOrAppendListEntry(pkg->header, tag, field); - headerGetEntry(pkg->header, tag, NULL, (void **)&array, &num); + hge(pkg->header, tag, &type, (void **)&array, &num); while (num--) { len = strlen(array[num]); if (array[num][len - 1] == '/' && len > 1) { rpmError(RPMERR_BADSPEC, _("line %d: Prefixes must not end with \"/\": %s\n"), spec->lineNum, spec->line); - FREE(array); + array = hfd(array, type); return RPMERR_BADSPEC; } } - FREE(array); + array = hfd(array, type); break; case RPMTAG_DOCDIR: SINGLE_TOKEN_ONLY; @@ -614,7 +621,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, case RPMTAG_CONFLICTFLAGS: case RPMTAG_OBSOLETEFLAGS: case RPMTAG_PROVIDEFLAGS: - tagflags = 0; + tagflags = RPMSENSE_ANY; if ((rc = parseRCPOT(spec, pkg, field, tag, 0, tagflags))) return rc; break; @@ -634,7 +641,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, return RPMERR_BADSPEC; } if (!spec->buildArchitectureCount) - FREE(spec->buildArchitectures); + spec->buildArchitectures = _free(spec->buildArchitectures); break; default: @@ -748,7 +755,7 @@ static int findPreambleTag(Spec spec, /*@out@*/int *tag, /*@out@*/char **macro, if (*s != '(') return 1; s++; SKIPSPACE(s); - while (!isspace(*s) && *s != ')') + while (!xisspace(*s) && *s != ')') *lang++ = *s++; *lang = '\0'; SKIPSPACE(s); diff --git a/build/parsePrep.c b/build/parsePrep.c index 63b113667..cd61a2f0c 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -14,8 +14,8 @@ /* These have to be global to make up for stupid compilers */ static int leaveDirs, skipDefaultAction; static int createDir, quietly; - /*@observer@*/ /*@null@*/ static const char * dirName = NULL; - static struct poptOption optionsTable[] = { +/*@observer@*/ /*@null@*/ static const char * dirName = NULL; +/*@observer@*/ static struct poptOption optionsTable[] = { { NULL, 'a', POPT_ARG_STRING, NULL, 'a', NULL, NULL}, { NULL, 'b', POPT_ARG_STRING, NULL, 'b', NULL, NULL}, { NULL, 'c', 0, &createDir, 0, NULL, NULL}, @@ -78,7 +78,7 @@ static int checkOwners(const char *urlfn) return NULL; } - fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL); + urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL); args[0] = '\0'; if (db) { @@ -97,10 +97,11 @@ static int checkOwners(const char *urlfn) /* XXX On non-build parse's, file cannot be stat'd or read */ if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) { - free((void *)urlfn); + urlfn = _free(urlfn); return NULL; } + fn = NULL; urltype = urlPath(urlfn, &fn); switch (urltype) { case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */ @@ -109,7 +110,7 @@ static int checkOwners(const char *urlfn) case URL_IS_UNKNOWN: break; case URL_IS_DASH: - free((void *)urlfn); + urlfn = _free(urlfn); return NULL; /*@notreached@*/ break; } @@ -126,10 +127,10 @@ static int checkOwners(const char *urlfn) "if [ $STATUS -ne 0 ]; then\n" " exit $STATUS\n" "fi", - c, (const char *) basename(fn), + c, /*@-unrecog@*/ (const char *) basename(fn), /*@=unrecog@*/ zipper, fn, strip, args); - free((void *)zipper); + zipper = _free(zipper); } else { sprintf(buf, "echo \"Patch #%d (%s):\"\n" @@ -137,7 +138,7 @@ static int checkOwners(const char *urlfn) strip, args, fn); } - free((void *)urlfn); + urlfn = _free(urlfn); return buf; } @@ -168,7 +169,7 @@ static int checkOwners(const char *urlfn) return NULL; } - fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL); + urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL); taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf"); @@ -194,10 +195,11 @@ static int checkOwners(const char *urlfn) /* XXX On non-build parse's, file cannot be stat'd or read */ if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) { - free((void *)urlfn); + urlfn = _free(urlfn); return NULL; } + fn = NULL; urltype = urlPath(urlfn, &fn); switch (urltype) { case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */ @@ -206,7 +208,7 @@ static int checkOwners(const char *urlfn) case URL_IS_UNKNOWN: break; case URL_IS_DASH: - free((void *)urlfn); + urlfn = _free(urlfn); return NULL; /*@notreached@*/ break; } @@ -231,7 +233,7 @@ static int checkOwners(const char *urlfn) zipper = rpmGetPath(t, NULL); buf[0] = '\0'; t = stpcpy(buf, zipper); - free((void *)zipper); + zipper = _free(zipper); *t++ = ' '; t = stpcpy(t, fn); if (needtar) @@ -249,7 +251,7 @@ static int checkOwners(const char *urlfn) t = stpcpy(t, fn); } - free((void *)urlfn); + urlfn = _free(urlfn); return buf; } @@ -295,10 +297,10 @@ static int doSetupMacro(Spec spec, char *line) if (parseNum(optArg, &num)) { rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%setup %c: %s\n"), spec->lineNum, num, optArg); - free(argv); freeStringBuf(before); freeStringBuf(after); poptFreeContext(optCon); + argv = _free(argv); return RPMERR_BADSPEC; } @@ -315,10 +317,10 @@ static int doSetupMacro(Spec spec, char *line) spec->lineNum, poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(arg)); - free(argv); freeStringBuf(before); freeStringBuf(after); poptFreeContext(optCon); + argv = _free(argv); return RPMERR_BADSPEC; } @@ -332,8 +334,8 @@ static int doSetupMacro(Spec spec, char *line) } addMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, RMIL_SPEC); - free(argv); poptFreeContext(optCon); + argv = _free(argv); /* cd to the build dir */ { const char * buildDirURL = rpmGenPath(spec->rootURL, "%{_builddir}", ""); @@ -342,7 +344,7 @@ static int doSetupMacro(Spec spec, char *line) (void) urlPath(buildDirURL, &buildDir); sprintf(buf, "cd %s", buildDir); appendLineStringBuf(spec->prep, buf); - free((void *)buildDirURL); + buildDirURL = _free(buildDirURL); } /* delete any old sources */ @@ -395,7 +397,7 @@ static int doSetupMacro(Spec spec, char *line) const char *fix = rpmExpand(*fm, " .", NULL); if (fix && *fix != '%') appendLineStringBuf(spec->prep, fix); - free((void *)fix); + fix = _free(fix); } } @@ -431,8 +433,8 @@ static int doPatchMacro(Spec spec, char *line) for (bp = buf; (s = strtok(bp, " \t\n")) != NULL;) { if (bp) { /* remove 1st token (%patch) */ - bp = NULL; - continue; + bp = NULL; + continue; } if (!strcmp(s, "-P")) { opt_P = 1; @@ -496,17 +498,15 @@ static int doPatchMacro(Spec spec, char *line) if (! opt_P) { s = doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E); - if (s == NULL) { + if (s == NULL) return RPMERR_BADSPEC; - } appendLineStringBuf(spec->prep, s); } for (x = 0; x < patch_index; x++) { s = doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E); - if (s == NULL) { + if (s == NULL) return RPMERR_BADSPEC; - } appendLineStringBuf(spec->prep, s); } @@ -530,9 +530,8 @@ int parsePrep(Spec spec) if ((rc = readLine(spec, STRIP_NOTHING)) > 0) { return PART_NONE; } - if (rc) { + if (rc) return rc; - } buf = newStringBuf(); @@ -544,9 +543,8 @@ int parsePrep(Spec spec) nextPart = PART_NONE; break; } - if (rc) { + if (rc) return rc; - } } saveLines = splitString(getStringBuf(buf), strlen(getStringBuf(buf)), '\n'); diff --git a/build/parseReqs.c b/build/parseReqs.c index 042f570b5..5e2f1ab1c 100644 --- a/build/parseReqs.c +++ b/build/parseReqs.c @@ -11,8 +11,8 @@ /** */ static struct ReqComp { - char *token; - int sense; + const char * token; + rpmsenseFlags sense; } ReqComparisons[] = { { "<=", RPMSENSE_LESS | RPMSENSE_EQUAL}, { "=<", RPMSENSE_LESS | RPMSENSE_EQUAL}, @@ -28,16 +28,16 @@ static struct ReqComp { { NULL, 0 }, }; -#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;} -#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;} int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, - int index, int tagflags) + int index, rpmsenseFlags tagflags) { const char *r, *re, *v, *ve; - char *req, *version; + char * req, * version; Header h; - int flags; + rpmsenseFlags flags; switch (tag) { case RPMTAG_PROVIDEFLAGS: @@ -95,7 +95,7 @@ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, flags = (tagflags & ~RPMSENSE_SENSEMASK); /* Tokens must begin with alphanumeric, _, or / */ - if (!(isalnum(r[0]) || r[0] == '_' || r[0] == '/')) { + if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/')) { rpmError(RPMERR_BADSPEC, _("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"), spec->lineNum, spec->line); @@ -183,8 +183,8 @@ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, addReqProv(spec, h, flags, req, version, index); - if (req) free(req); - if (version) free(version); + req = _free(req); + version = _free(version); } diff --git a/build/parseScript.c b/build/parseScript.c index 9abd7fb0e..6476f997c 100644 --- a/build/parseScript.c +++ b/build/parseScript.c @@ -293,12 +293,8 @@ int parseScript(Spec spec, int parsePart) exit: if (sb) freeStringBuf(sb); - if (progArgv) { - FREE(progArgv); - } - if (argv) { - FREE(argv); - } + progArgv = _free(progArgv); + argv = _free(argv); if (optCon) poptFreeContext(optCon); diff --git a/build/parseSpec.c b/build/parseSpec.c index 37428b9c5..d81d23222 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -60,7 +60,7 @@ rpmParseState isPart(const char *line) if (xstrncasecmp(line, p->token, p->len)) continue; c = *(line + p->len); - if (c == '\0' || isspace(c)) + if (c == '\0' || xisspace(c)) break; } @@ -147,7 +147,7 @@ static int copyNextLine(Spec spec, OFI_t *ofi, int strip) ch = ' '; while (*spec->nextline && ch != '\n') { ch = *spec->nextline++; - if (!isspace(ch)) + if (!xisspace(ch)) last = spec->nextline; } @@ -203,8 +203,8 @@ retry: /* remove this file from the stack */ spec->fileStack = ofi->next; Fclose(ofi->fd); - FREE(ofi->fileName); - free(ofi); + ofi->fileName = _free(ofi->fileName); + ofi = _free(ofi); /* only on last file do we signal EOF to caller */ ofi = spec->fileStack; @@ -247,22 +247,22 @@ retry: const char *arch = rpmExpand("%{_target_cpu}", NULL); s += 7; match = matchTok(arch, s); - free((void *)arch); + arch = _free(arch); } else if (! strncmp("%ifnarch", s, sizeof("%ifnarch")-1)) { const char *arch = rpmExpand("%{_target_cpu}", NULL); s += 8; match = !matchTok(arch, s); - free((void *)arch); + arch = _free(arch); } else if (! strncmp("%ifos", s, sizeof("%ifos")-1)) { const char *os = rpmExpand("%{_target_os}", NULL); s += 5; match = matchTok(os, s); - free((void *)os); + os = _free(os); } else if (! strncmp("%ifnos", s, sizeof("%ifnos")-1)) { const char *os = rpmExpand("%{_target_os}", NULL); s += 6; match = !matchTok(os, s); - free((void *)os); + os = _free(os); } else if (! strncmp("%if", s, sizeof("%if")-1)) { s += 3; match = parseExpressionBoolean(spec, s); @@ -302,7 +302,7 @@ retry: s += 8; fileName = s; - if (! isspace(*fileName)) { + if (! xisspace(*fileName)) { rpmError(RPMERR_BADSPEC, _("malformed %%include statement\n")); return RPMERR_BADSPEC; } @@ -346,8 +346,8 @@ void closeSpec(Spec spec) ofi = spec->fileStack; spec->fileStack = spec->fileStack->next; if (ofi->fd) Fclose(ofi->fd); - FREE(ofi->fileName); - free(ofi); + ofi->fileName = _free(ofi->fileName); + ofi = _free(ofi); } } @@ -482,7 +482,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU } #ifdef DYING rpmSetMachine(saveArch, NULL); - free((void *)saveArch); + saveArch = _free(saveArch); #else delMacro(NULL, "_target_cpu"); #endif @@ -557,10 +557,10 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, arch, 1); } #ifdef DYING - FREE(myos); + myos = _free(myos); #else - free((void *)arch); - free((void *)os); + arch = _free(arch); + os = _free(os); #endif } diff --git a/build/reqprov.c b/build/reqprov.c index 5ee4b96a9..6eeb80ec7 100644 --- a/build/reqprov.c +++ b/build/reqprov.c @@ -9,15 +9,19 @@ #include "debug.h" int addReqProv(/*@unused@*/ Spec spec, Header h, - int depFlags, const char *depName, const char *depEVR, int index) + rpmsenseFlags depFlags, const char *depName, const char *depEVR, + int index) { - const char **names; + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; + const char ** names; + int dnt; int nametag = 0; int versiontag = 0; int flagtag = 0; int indextag = 0; int len; - int extra = 0; + rpmsenseFlags extra = RPMSENSE_ANY; if (depFlags & RPMSENSE_PROVIDES) { nametag = RPMTAG_PROVIDENAME; @@ -56,18 +60,19 @@ int addReqProv(/*@unused@*/ Spec spec, Header h, depEVR = ""; /* Check for duplicate dependencies. */ - if (headerGetEntry(h, nametag, NULL, (void **) &names, &len)) { - const char **versions = NULL; + if (hge(h, nametag, &dnt, (void **) &names, &len)) { + const char ** versions = NULL; + int dvt; int *flags = NULL; int *indexes = NULL; int duplicate = 0; if (flagtag) { - headerGetEntry(h, versiontag, NULL, (void **) &versions, NULL); - headerGetEntry(h, flagtag, NULL, (void **) &flags, NULL); + hge(h, versiontag, &dvt, (void **) &versions, NULL); + hge(h, flagtag, NULL, (void **) &flags, NULL); } if (indextag) - headerGetEntry(h, indextag, NULL, (void **) &indexes, NULL); + hge(h, indextag, NULL, (void **) &indexes, NULL); while (len > 0) { len--; @@ -89,8 +94,8 @@ int addReqProv(/*@unused@*/ Spec spec, Header h, break; } - FREE(names); - FREE(versions); + names = hfd(names, dnt); + versions = hfd(versions, dvt); if (duplicate) return 0; } diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 724a420e1..34ce244e5 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -19,6 +19,7 @@ * Bit(s) to control buildSpec() operation. */ typedef enum rpmBuildFlags_e { + RPMBUILD_NONE = 0, RPMBUILD_PREP = (1 << 0), /*!< Execute %%prep. */ RPMBUILD_BUILD = (1 << 1), /*!< Execute %%build. */ RPMBUILD_INSTALL = (1 << 2), /*!< Execute %%install. */ @@ -34,9 +35,8 @@ typedef enum rpmBuildFlags_e { #include <ctype.h> -#define FREE(x) { if (x) free((void *)x); x = NULL; } -#define SKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; } -#define SKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; } +#define SKIPSPACE(s) { while (*(s) && xisspace(*(s))) (s)++; } +#define SKIPNONSPACE(s) { while (*(s) && !xisspace(*(s))) (s)++; } #define PART_SUBNAME 0 #define PART_NAME 1 @@ -222,7 +222,7 @@ int parsePrep(Spec spec); * @return 0 on success, RPMERR_BADSPEC on failure */ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index, - int flags); + rpmsenseFlags flags); /** \ingroup rpmbuild * Parse %%pre et al scriptlets from a spec file. @@ -310,7 +310,8 @@ void freePackage(/*@only@*/ Package pkg); * @return 0 always */ int addReqProv(/*@unused@*/Spec spec, Header h, - int flag, const char *depName, const char *depEVR, int index); + rpmsenseFlags flag, const char *depName, const char *depEVR, + int index); /** \ingroup rpmbuild * Add rpmlib feature dependency. diff --git a/build/spec.c b/build/spec.c index 037f85f04..153ad2e15 100644 --- a/build/spec.c +++ b/build/spec.c @@ -12,8 +12,8 @@ extern int specedit; extern MacroContext rpmGlobalMacroContext; -#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;} -#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;} +#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;} /*@access Header @*/ /* compared with NULL */ @@ -26,10 +26,10 @@ static inline void freeTriggerFiles(/*@only@*/ struct TriggerFileEntry *p) while (q != NULL) { o = q; q = q->next; - FREE(o->fileName); - FREE(o->script); - FREE(o->prog); - free(o); + o->fileName = _free(o->fileName); + o->script = _free(o->script); + o->prog = _free(o->prog); + o = _free(o); } } @@ -42,8 +42,8 @@ static inline void freeSources(/*@only@*/ struct Source *s) while (t != NULL) { r = t; t = t->next; - FREE(r->fullSource); - free(r); + r->fullSource = _free(r->fullSource); + r = _free(r); } } @@ -138,21 +138,21 @@ void freePackage(/*@only@*/ Package p) if (p == NULL) return; - FREE(p->preInFile); - FREE(p->postInFile); - FREE(p->preUnFile); - FREE(p->postUnFile); - FREE(p->verifyFile); + p->preInFile = _free(p->preInFile); + p->postInFile = _free(p->postInFile); + p->preUnFile = _free(p->preUnFile); + p->postUnFile = _free(p->postUnFile); + p->verifyFile = _free(p->verifyFile); headerFree(p->header); freeStringBuf(p->fileList); - FREE(p->fileFile); + p->fileFile = _free(p->fileFile); if (p->cpioList) { TFI_t fi = p->cpioList; + p->cpioList = NULL; freeFi(fi); - free((void *)fi); + fi = _free(fi); } - p->cpioList = NULL; freeStringBuf(p->specialDoc); @@ -160,7 +160,7 @@ void freePackage(/*@only@*/ Package p) freeTriggerFiles(p->triggerFiles); - free(p); + p = _free(p); } void freePackages(Spec spec) @@ -317,7 +317,7 @@ int addSource(Spec spec, Package pkg, const char *field, int tag) sprintf(buf, "%sURL%d", (flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num); addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC); - free((void *)body); + body = _free(body); } return 0; @@ -345,9 +345,9 @@ static inline void freeSl(/*@only@*/struct speclines *sl) if (sl == NULL) return; for (i = 0; i < sl->sl_nlines; i++) - FREE(sl->sl_lines[i]); - FREE(sl->sl_lines); - free(sl); + sl->sl_lines[i] = _free(sl->sl_lines[i]); + sl->sl_lines = _free(sl->sl_lines); + sl = _free(sl); } /** @@ -373,18 +373,16 @@ static inline void freeSt(/*@only@*/struct spectags *st) return; for (i = 0; i < st->st_ntags; i++) { struct spectag *t = st->st_t + i; - FREE(t->t_lang); - FREE(t->t_msgid); + t->t_lang = _free(t->t_lang); + t->t_msgid = _free(t->t_msgid); } - FREE(st->st_t); - free(st); + st->st_t = _free(st->st_t); + st = _free(st); } Spec newSpec(void) { - Spec spec; - - spec = (Spec)xmalloc(sizeof *spec); + Spec spec = xcalloc(1, sizeof(*spec)); spec->specFile = NULL; spec->sourceRpmName = NULL; @@ -398,7 +396,7 @@ Spec newSpec(void) spec->nextline = NULL; spec->nextpeekc = '\0'; spec->lineNum = 0; - spec->readStack = xmalloc(sizeof(struct ReadLevelEntry)); + spec->readStack = xcalloc(1, sizeof(*spec->readStack)); spec->readStack->next = NULL; spec->readStack->reading = 1; @@ -452,25 +450,25 @@ void freeSpec(/*@only@*/ Spec spec) freeStringBuf(spec->install); spec->install = NULL; freeStringBuf(spec->clean); spec->clean = NULL; - FREE(spec->buildRootURL); - FREE(spec->buildSubdir); - FREE(spec->rootURL); - FREE(spec->specFile); - FREE(spec->sourceRpmName); + spec->buildRootURL = _free(spec->buildRootURL); + spec->buildSubdir = _free(spec->buildSubdir); + spec->rootURL = _free(spec->rootURL); + spec->specFile = _free(spec->specFile); + spec->sourceRpmName = _free(spec->sourceRpmName); while (spec->fileStack) { ofi = spec->fileStack; - spec->fileStack = spec->fileStack->next; + spec->fileStack = ofi->next; ofi->next = NULL; - FREE(ofi->fileName); - free(ofi); + ofi->fileName = _free(ofi->fileName); + ofi = _free(ofi); } while (spec->readStack) { rl = spec->readStack; - spec->readStack = spec->readStack->next; + spec->readStack = rl->next; rl->next = NULL; - free(rl); + rl = _free(rl); } if (spec->sourceHeader != NULL) { @@ -480,10 +478,10 @@ void freeSpec(/*@only@*/ Spec spec) if (spec->sourceCpioList) { TFI_t fi = spec->sourceCpioList; + spec->sourceCpioList = NULL; freeFi(fi); - free((void *)fi); + fi = _free(fi); } - spec->sourceCpioList = NULL; headerFree(spec->buildRestrictions); spec->buildRestrictions = NULL; @@ -493,18 +491,18 @@ void freeSpec(/*@only@*/ Spec spec) freeSpec( spec->buildArchitectureSpecs[spec->buildArchitectureCount]); } - FREE(spec->buildArchitectureSpecs); + spec->buildArchitectureSpecs = _free(spec->buildArchitectureSpecs); } - FREE(spec->buildArchitectures); + spec->buildArchitectures = _free(spec->buildArchitectures); - FREE(spec->passPhrase); - FREE(spec->cookie); + spec->passPhrase = _free(spec->passPhrase); + spec->cookie = _free(spec->cookie); freeSources(spec->sources); spec->sources = NULL; freePackages(spec); closeSpec(spec); - free(spec); + spec = _free(spec); } /*@only@*/ struct OpenFileInfo * newOpenFileInfo(void) |