RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: jbj@rpm5.org Module: rpm Date: 19-Oct-2007 02:36:48 Branch: HEAD Handle: 2007101901364205 Modified files: rpm CHANGES rpm/build files.c pack.c parsePreamble.c parseSpec.c reqprov.c rpm/lib depends.c formats.c package.c psm.c rpmchecksig.c rpmds.c rpmfc.c rpmfi.c rpminstall.c rpmrollback.c rpmte.c rpmts.c transaction.c rpm/python header-py.c rpm/rpmdb hdrNVR.c hdrfmt.c hdrinline.h header.c header.h pkgio.c rpmdb.c signature.c rpm/tools rpmcache.c Log: - remove useless HE_t indirection with (*he->p).ptr, he->p.ptr instead. Summary: Revision Changes Path 1.1731 +1 -0 rpm/CHANGES 1.276 +17 -25 rpm/build/files.c 2.240 +12 -18 rpm/build/pack.c 2.138 +13 -19 rpm/build/parsePreamble.c 2.111 +3 -5 rpm/build/parseSpec.c 1.76 +5 -7 rpm/build/reqprov.c 1.354 +14 -20 rpm/lib/depends.c 2.115 +14 -14 rpm/lib/formats.c 2.177 +4 -6 rpm/lib/package.c 2.248 +67 -87 rpm/lib/psm.c 1.161 +15 -23 rpm/lib/rpmchecksig.c 2.76 +16 -22 rpm/lib/rpmds.c 1.28 +7 -9 rpm/lib/rpmfc.c 2.92 +33 -37 rpm/lib/rpmfi.c 1.178 +9 -11 rpm/lib/rpminstall.c 1.23 +12 -18 rpm/lib/rpmrollback.c 2.63 +25 -31 rpm/lib/rpmte.c 2.114 +5 -7 rpm/lib/rpmts.c 1.347 +10 -16 rpm/lib/transaction.c 1.67 +48 -60 rpm/python/header-py.c 1.20 +10 -16 rpm/rpmdb/hdrNVR.c 1.20 +80 -95 rpm/rpmdb/hdrfmt.c 1.21 +1 -1 rpm/rpmdb/hdrinline.h 1.92 +44 -65 rpm/rpmdb/header.c 1.46 +1 -3 rpm/rpmdb/header.h 1.21 +6 -10 rpm/rpmdb/pkgio.c 1.192 +99 -98 rpm/rpmdb/rpmdb.c 1.14 +4 -6 rpm/rpmdb/signature.c 2.21 +2 -4 rpm/tools/rpmcache.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.1730 -r1.1731 CHANGES --- rpm/CHANGES 18 Oct 2007 20:31:16 -0000 1.1730 +++ rpm/CHANGES 19 Oct 2007 00:36:42 -0000 1.1731 @@ -1,4 +1,5 @@ 4.5 -> 5.0: + - jbj: remove useless HE_t indirection with (*he->p).ptr, he->p.ptr instead. - jbj: fix several indirection problems. - jbj: eliminate data arg in (*headerTagFormatFunction). - jbj: start simplifying the world's most complicated sprintf. @@ . patch -p0 <<'@@ .' Index: rpm/build/files.c ============================================================================ $ cvs diff -u -r1.275 -r1.276 files.c --- rpm/build/files.c 17 Oct 2007 20:04:50 -0000 1.275 +++ rpm/build/files.c 19 Oct 2007 00:36:43 -0000 1.276 @@ -271,9 +271,7 @@ /*@modifies internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int_32 currentTime = time(NULL); int_32 * mtime; int xx; @@ -281,7 +279,7 @@ he->tag = RPMTAG_FILEMTIMES; xx = hge(h, he, 0); - mtime = he_p.i32p; + mtime = he->p.i32p; he->tag = RPMTAG_OLDFILENAMES; xx = hge(h, he, 0); @@ -289,9 +287,9 @@ xx = currentTime - mtime[i]; if (xx < 0) xx = -xx; if (xx > tc) - rpmlog(RPMLOG_WARNING, _("TIMECHECK failure: %s\n"), he_p.argv[i]); + rpmlog(RPMLOG_WARNING, _("TIMECHECK failure: %s\n"), he->p.argv[i]); } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); mtime = _free(mtime); } @@ -1168,11 +1166,9 @@ /*@modifies h @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; HAE_t hae = (HAE_t)headerAddEntry; HRE_t hre = (HRE_t)headerRemoveEntry; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char ** fileNames; const char * fn; const char ** dirNames; @@ -1196,7 +1192,7 @@ he->tag = RPMTAG_OLDFILENAMES; xx = hge(h, he, 0); - fileNames = he_p.argv; + fileNames = he->p.argv; count = he->c; if (!xx || fileNames == NULL || count <= 0) return; /* no file list */ @@ -1252,19 +1248,19 @@ if (count > 0) { he->tag = RPMTAG_DIRINDEXES; he->t = RPM_INT32_TYPE; - he_p.i32p = dirIndexes; + he->p.i32p = dirIndexes; he->c = count; - xx = hae(h, he->tag, he->t, he_p, he->c); + xx = hae(h, he->tag, he->t, he->p, he->c); he->tag = RPMTAG_BASENAMES; he->t = RPM_STRING_ARRAY_TYPE; - he_p.argv = baseNames; + he->p.argv = baseNames; he->c = count; - xx = hae(h, he->tag, he->t, he_p, he->c); + xx = hae(h, he->tag, he->t, he->p, he->c); he->tag = RPMTAG_DIRNAMES; he->t = RPM_STRING_ARRAY_TYPE; - he_p.argv = dirNames; + he->p.argv = dirNames; he->c = dirIndex + 1; - xx = hae(h, he->tag, he->t, he_p, he->c); + xx = hae(h, he->tag, he->t, he->p, he->c); } fileNames = _free(fileNames); @@ -2161,9 +2157,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); struct FileList_s fl; char *s, **files, **fp; const char *fileName; @@ -2228,7 +2222,7 @@ he->tag = RPMTAG_DEFAULTPREFIX; xx = hge(pkg->header, he, 0); - fl.prefix = he_p.str; + fl.prefix = he->p.str; fl.fileCount = 0; fl.totalFileSize = 0; @@ -2689,9 +2683,7 @@ /*@modifies check_fileList @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); Package pkg; int res = 0; int xx; @@ -2708,8 +2700,8 @@ he->tag = RPMTAG_NVRA; xx = hge(pkg->header, he, 0); - rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), he_p.str); - he_p.ptr = _free(he_p.ptr); + rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), he->p.str); + he->p.ptr = _free(he->p.ptr); if ((rc = processPackageFiles(spec, pkg, installSpecialDoc, test))) res = rc; @@ . patch -p0 <<'@@ .' Index: rpm/build/pack.c ============================================================================ $ cvs diff -u -r2.239 -r2.240 pack.c --- rpm/build/pack.c 17 Oct 2007 20:04:50 -0000 2.239 +++ rpm/build/pack.c 19 Oct 2007 00:36:43 -0000 2.240 @@ -174,19 +174,17 @@ /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); StringBuf sb = newStringBuf(); int xx; he->tag = tag; xx = hge(h, he, 0); if (xx) { - appendLineStringBuf(sb, he_p.str); + appendLineStringBuf(sb, he->p.str); (void) headerRemoveEntry(h, tag); } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); if ((sb = addFileToTagAux(spec, file, sb)) == NULL) return 1; @@ -438,9 +436,7 @@ void providePackageNVR(Header h) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char *N, *V, *R; int_32 E; int gotE; @@ -462,8 +458,8 @@ *p = '\0'; he->tag = RPMTAG_EPOCH; gotE = hge(h, he, 0); - E = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + E = (he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); if (gotE) { sprintf(p, "%d:", E); p += strlen(p); @@ -476,7 +472,7 @@ */ he->tag = RPMTAG_PROVIDENAME; xx = hge(h, he, 0); - provides = he_p.argv; + provides = he->p.argv; providesCount = he->c; if (!xx) goto exit; @@ -486,7 +482,7 @@ */ he->tag = RPMTAG_PROVIDEVERSION; xx = hge(h, he, 0); - providesEVR = he_p.argv; + providesEVR = he->p.argv; if (!xx) { for (i = 0; i < providesCount; i++) { char * vdummy = ""; @@ -501,7 +497,7 @@ he->tag = RPMTAG_PROVIDEFLAGS; xx = hge(h, he, 0); - provideFlags = he_p.i32p; + provideFlags = he->p.i32p; /*@-nullderef@*/ /* LCL: providesEVR is not NULL */ if (provides && providesEVR && provideFlags) @@ -859,9 +855,7 @@ int packageBinaries(Spec spec) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); struct cpioSourceArchive_s csabuf; CSA_t csa = &csabuf; int rc; @@ -913,8 +907,8 @@ he->tag = RPMTAG_NVRA; xx = hge(pkg->header, he, 0); rpmlog(RPMLOG_ERR, _("Could not generate output " - "filename for package %s: %s\n"), he_p.str, errorString); - he_p.ptr = _free(he_p.ptr); + "filename for package %s: %s\n"), he->p.str, errorString); + he->p.ptr = _free(he->p.ptr); return RPMRC_FAIL; } fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL); @@ . patch -p0 <<'@@ .' Index: rpm/build/parsePreamble.c ============================================================================ $ cvs diff -u -r2.137 -r2.138 parsePreamble.c --- rpm/build/parsePreamble.c 17 Oct 2007 20:04:50 -0000 2.137 +++ rpm/build/parsePreamble.c 19 Oct 2007 00:36:43 -0000 2.138 @@ -212,9 +212,7 @@ /*@*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; he->tag = tag; @@ -223,10 +221,10 @@ return -1; /*@-boundsread@*/ while (he->c--) { - if (!xstrcasecmp(he_p.argv[he->c], name)) + if (!xstrcasecmp(he->p.argv[he->c], name)) break; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); /*@=boundsread@*/ return (he->c >= 0 ? 1 : 0); } @@ -441,9 +439,7 @@ spectag stashSt(Spec spec, Header h, int tag, const char * lang) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); spectag t = NULL; int xx; @@ -464,10 +460,10 @@ xx = hge(h, he, 0); if (xx) { char buf[1024]; - sprintf(buf, "%s(%s)", he_p.str, tagName(tag)); + sprintf(buf, "%s(%s)", he->p.str, tagName(tag)); t->t_msgid = xstrdup(buf); } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } } /*@-usereleased -compdef@*/ @@ -500,9 +496,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); char * field = spec->line; char * end; int multiToken = 0; @@ -604,23 +598,23 @@ xx = hge(pkg->header, he, 0); if (tag == RPMTAG_PREFIXES) while (he->c--) { - if (he_p.argv[he->c][0] != '/') { + if (he->p.argv[he->c][0] != '/') { rpmlog(RPMLOG_ERR, _("line %d: Prefixes must begin with \"/\": %s\n"), spec->lineNum, spec->line); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); return RPMRC_FAIL; } - len = strlen(he_p.argv[he->c]); - if (he_p.argv[he->c][len - 1] == '/' && len > 1) { + len = strlen(he->p.argv[he->c]); + if (he->p.argv[he->c][len - 1] == '/' && len > 1) { rpmlog(RPMLOG_ERR, _("line %d: Prefixes must not end with \"/\": %s\n"), spec->lineNum, spec->line); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); return RPMRC_FAIL; } } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); break; case RPMTAG_DOCDIR: SINGLE_TOKEN_ONLY; @@ . patch -p0 <<'@@ .' Index: rpm/build/parseSpec.c ============================================================================ $ cvs diff -u -r2.110 -r2.111 parseSpec.c --- rpm/build/parseSpec.c 17 Oct 2007 20:04:50 -0000 2.110 +++ rpm/build/parseSpec.c 19 Oct 2007 00:36:43 -0000 2.111 @@ -435,9 +435,7 @@ const char *cookie, int anyarch, int force, int verify) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmParseState parsePart = PART_PREAMBLE; int initialPackage = 1; Package pkg; @@ -608,8 +606,8 @@ he->tag = RPMTAG_NVRA; xx = hge(pkg->header, he, 0); rpmlog(RPMLOG_ERR, _("Package has no %%description: %s\n"), - he_p.str); - he_p.ptr = _free(he_p.ptr); + he->p.str); + he->p.ptr = _free(he->p.ptr); spec = freeSpec(spec); return RPMRC_FAIL; } @@ . patch -p0 <<'@@ .' Index: rpm/build/reqprov.c ============================================================================ $ cvs diff -u -r1.75 -r1.76 reqprov.c --- rpm/build/reqprov.c 17 Oct 2007 20:04:50 -0000 1.75 +++ rpm/build/reqprov.c 19 Oct 2007 00:36:43 -0000 1.76 @@ -15,9 +15,7 @@ int index) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char ** names; rpmTag nametag = 0; rpmTag versiontag = 0; @@ -63,7 +61,7 @@ /* Check for duplicate dependencies. */ he->tag = nametag; xx = hge(h, he, 0); - names = he_p.argv; + names = he->p.argv; len = he->c; if (xx) { const char ** versions = NULL; @@ -74,15 +72,15 @@ if (flagtag) { he->tag = versiontag; xx = hge(h, he, 0); - versions = he_p.argv; + versions = he->p.argv; he->tag = flagtag; xx = hge(h, he, 0); - flags = he_p.i32p; + flags = he->p.i32p; } if (indextag) { he->tag = indextag; xx = hge(h, he, 0); - indexes = he_p.i32p; + indexes = he->p.i32p; } /*@-boundsread@*/ @@ . patch -p0 <<'@@ .' Index: rpm/lib/depends.c ============================================================================ $ cvs diff -u -r1.353 -r1.354 depends.c --- rpm/lib/depends.c 17 Oct 2007 20:04:51 -0000 1.353 +++ rpm/lib/depends.c 19 Oct 2007 00:36:44 -0000 1.354 @@ -151,19 +151,17 @@ /*@*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * one, * two; int rc = 0; int xx; he->tag = RPMTAG_HDRID; xx = hge(first, he, 0); - one = he_p.str; + one = he->p.str; he->tag = RPMTAG_HDRID; xx = hge(second, he, 0); - two = he_p.str; + two = he->p.str; if (one && two) rc = ((strcmp(one, two) == 0) ? 1 : 0); @@ -193,9 +191,7 @@ fnpyKey key, int upgrade, rpmRelocation relocs) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmdepFlags depFlags = rpmtsDFlags(ts); uint_32 tscolor = rpmtsColor(ts); uint_32 dscolor; @@ -235,16 +231,16 @@ */ he->tag = RPMTAG_ARCH; xx = hge(h, he, 0); - arch = he_p.str; + arch = he->p.str; he->tag = RPMTAG_OS; xx = hge(h, he, 0); - os = he_p.str; + os = he->p.str; if (nplatpat > 1) { const char * platform = NULL; he->tag = RPMTAG_PLATFORM; xx = hge(h, he, 0); - platform = he_p.str; + platform = he->p.str; if (!xx || platform == NULL) platform = rpmExpand(arch, "-unknown-", os, NULL); @@ -253,11 +249,11 @@ rpmps ps = rpmtsProblems(ts); he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); -assert(he_p.str != NULL); - rpmpsAppend(ps, RPMPROB_BADPLATFORM, he_p.str, key, +assert(he->p.str != NULL); + rpmpsAppend(ps, RPMPROB_BADPLATFORM, he->p.str, key, platform, NULL, NULL, 0); ps = rpmpsFree(ps); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); ec = 1; } platform = _free(platform); @@ -1312,9 +1308,7 @@ /*@modifies ts, mi, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmdepFlags depFlags = rpmtsDFlags(ts); uint_32 tscolor = rpmtsColor(ts); int scareMem = 0; @@ -1332,7 +1326,7 @@ he->tag = RPMTAG_NVRA; rc = hge(h, he, 0); -assert(he_p.str != NULL); +assert(he->p.str != NULL); if (!(depFlags & RPMDEPS_FLAG_NOREQUIRES)) requires = rpmdsNew(h, RPMTAG_REQUIRENAME, scareMem); if (!(depFlags & RPMDEPS_FLAG_NOCONFLICTS)) @@ -1347,7 +1341,7 @@ (void) rpmdsSetNoPromote(dirnames, _rpmds_nopromote); (void) rpmdsSetNoPromote(linktos, _rpmds_nopromote); - rc = checkPackageDeps(ts, he_p.str, + rc = checkPackageDeps(ts, he->p.str, requires, conflicts, dirnames, linktos, depName, tscolor, adding); @@ -1355,7 +1349,7 @@ dirnames = rpmdsFree(dirnames); conflicts = rpmdsFree(conflicts); requires = rpmdsFree(requires); - he_p.str = _free(he_p.str); + he->p.str = _free(he->p.str); if (rc) { ec = 1; @@ . patch -p0 <<'@@ .' Index: rpm/lib/formats.c ============================================================================ $ cvs diff -u -r2.114 -r2.115 formats.c --- rpm/lib/formats.c 17 Oct 2007 20:04:51 -0000 2.114 +++ rpm/lib/formats.c 19 Oct 2007 00:36:44 -0000 2.115 @@ -36,7 +36,7 @@ return 1; he->t = RPM_STRING_ARRAY_TYPE; - if (he->p) (*he->p).argv = list; + he->p.argv = list; he->freeData = 0; return 0; @@ -57,21 +57,21 @@ HGE_t hge = (HGE_t)headerGetExtension; rpmTagData fnames = { .ptr = NULL }; rpmTagData fsizes = { .ptr = NULL }; - rpmTagData * p; + rpmTagData p; uint_64 * usages; int numFiles; int rc = 1; /* assume error */ int xx, yy; - p = he->p; + p.ptr = he->p.ptr; he->tag = RPMTAG_FILESIZES; - he->p = &fsizes; xx = hge(h, he, 0); + fsizes.ptr = he->p.ptr; he->tag = RPMTAG_FILEPATHS; - he->p = &fnames; yy = hge(h, he, 0); + fnames.ptr = he->p.ptr; numFiles = he->c; - he->p = p; + he->p.ptr = p.ptr; if (!xx || !yy) { numFiles = 0; fsizes.ui32p = _free(fsizes.ui32p); @@ -90,7 +90,7 @@ if (rpmGetFilesystemUsage(fnames.argv, fsizes.ui32p, numFiles, &usages, 0)) goto exit; - if (he->p) (*he->p).ui64p = usages; + he->p.ui64p = usages; rc = 0; exit: @@ -112,7 +112,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFClasses(h, &(*he->p).argv, &he->c); + rpmfiBuildFClasses(h, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -129,7 +129,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFContexts(h, &(*he->p).argv, &he->c); + rpmfiBuildFContexts(h, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -146,7 +146,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFSContexts(h, &(*he->p).argv, &he->c); + rpmfiBuildFSContexts(h, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -163,7 +163,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildREContexts(h, &(*he->p).argv, &he->c); + rpmfiBuildREContexts(h, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -180,7 +180,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFDeps(h, RPMTAG_PROVIDENAME, &(*he->p).argv, &he->c); + rpmfiBuildFDeps(h, RPMTAG_PROVIDENAME, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -197,7 +197,7 @@ rpmGlobalMacroContext, fileSystem, internalState @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFDeps(h, RPMTAG_REQUIRENAME, &(*he->p).argv, &he->c); + rpmfiBuildFDeps(h, RPMTAG_REQUIRENAME, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ -253,7 +253,7 @@ /* XXX perhaps return "(none)" inband if no suggests/enhances <shrug>. */ he->t = RPM_STRING_ARRAY_TYPE; - (*he->p).argv = argv; + he->p.argv = argv; he->c = argc; he->freeData = 1; return 0; @@ . patch -p0 <<'@@ .' Index: rpm/lib/package.c ============================================================================ $ cvs diff -u -r2.176 -r2.177 package.c --- rpm/lib/package.c 17 Oct 2007 20:04:51 -0000 2.176 +++ rpm/lib/package.c 19 Oct 2007 00:36:44 -0000 2.177 @@ -185,9 +185,7 @@ rpmRC rpmReadPackageFile(rpmts ts, void * _fd, const char * fn, Header * hdrp) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); pgpDig dig = rpmtsDig(ts); FD_t fd = _fd; char buf[8*BUFSIZ]; @@ -353,7 +351,7 @@ he->tag = sigtag; xx = hge(sigh, he, 0); sigtype = he->t; - sig = he_p.ptr; + sig = he->p.ptr; siglen = he->c; if (sig == NULL) { rc = RPMRC_FAIL; @@ -383,7 +381,7 @@ he->tag = RPMTAG_HEADERIMMUTABLE; xx = hge(h, he, 0); uht = he->t; - uh = he_p.ptr; + uh = he->p.ptr; uhc = he->c; if (!xx) break; @@ -422,7 +420,7 @@ he->tag = RPMTAG_HEADERIMMUTABLE; xx = hge(h, he, 0); uht = he->t; - uh = he_p.ptr; + uh = he->p.ptr; uhc = he->c; if (!xx) break; @@ . patch -p0 <<'@@ .' Index: rpm/lib/psm.c ============================================================================ $ cvs diff -u -r2.247 -r2.248 psm.c --- rpm/lib/psm.c 17 Oct 2007 20:04:51 -0000 2.247 +++ rpm/lib/psm.c 19 Oct 2007 00:36:44 -0000 2.248 @@ -56,9 +56,7 @@ int rpmVersionCompare(Header first, Header second) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * one, * two; int_32 Eone, Etwo; int rc; @@ -66,12 +64,12 @@ he->tag = RPMTAG_EPOCH; xx = hge(first, he, 0); - Eone = (xx && he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + Eone = (xx && he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_EPOCH; xx = hge(second, he, 0); - Etwo = (xx && he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + Etwo = (xx && he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); if (Eone < Etwo) return -1; @@ -80,10 +78,10 @@ he->tag = RPMTAG_VERSION; xx = hge(first, he, 0); - one = he_p.str; + one = he->p.str; he->tag = RPMTAG_VERSION; xx = hge(second, he, 0); - two = he_p.str; + two = he->p.str; rc = rpmvercmp(one, two); one = _free(one); two = _free(two); @@ -92,10 +90,10 @@ he->tag = RPMTAG_RELEASE; xx = hge(first, he, 0); - one = he_p.str; + one = he->p.str; he->tag = RPMTAG_RELEASE; xx = hge(second, he, 0); - two = he_p.str; + two = he->p.str; rc = rpmvercmp(one, two); one = _free(one); two = _free(two); @@ -187,9 +185,7 @@ const char ** specFilePtr, const char ** cookie) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); FD_t fd = _fd; int scareMem = 0; rpmfi fi = NULL; @@ -266,7 +262,7 @@ *cookie = NULL; he->tag = RPMTAG_COOKIE; xx = hge(fi->h, he, 0); - *cookie = he_p.str; + *cookie = he->p.str; } /* XXX FIXME: don't do per-file mapping, force global flags. */ @@ -286,7 +282,7 @@ if (fi->h != NULL) { /* XXX can't happen */ he->tag = RPMTAG_FILEPATHS; xx = hge(fi->h, he, 0); - fi->apath = he_p.argv; + fi->apath = he->p.argv; if (headerIsEntry(fi->h, RPMTAG_COOKIE)) for (i = 0; i < fi->fc; i++) @@ -495,9 +491,7 @@ /*@modifies psm, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const rpmts ts = psm->ts; int rootFdno = -1; rpmRC rc = RPMRC_OK; @@ -514,7 +508,7 @@ he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); -assert(xx && he_p.str != NULL); +assert(he->p.str != NULL); /* Save the current working directory. */ /*@-nullpass@*/ @@ -562,7 +556,7 @@ { char buf[BUFSIZ]; - xx = snprintf(buf, BUFSIZ, "%s(%s)", sln, he_p.str); + xx = snprintf(buf, BUFSIZ, "%s(%s)", sln, he->p.str); xx = rpmluaRunScript(lua, script, buf); if (xx == -1) rc = RPMRC_FAIL; @@ -589,7 +583,7 @@ xx = fchdir(rootFdno); xx = close(rootFdno); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); return rc; } @@ -630,9 +624,7 @@ fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const rpmts ts = psm->ts; const char ** argv = NULL; int argc = 0; @@ -660,8 +652,8 @@ he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); -assert(he_p.str != NULL); - NVRA = he_p.str; +assert(he->p.str != NULL); + NVRA = he->p.str; if (progArgv && strcmp(progArgv[0], "<lua>") == 0) { #ifdef WITH_LUA @@ -710,19 +702,19 @@ he->tag = RPMTAG_INSTPREFIXES; xx = hge(h, he, 0); - prefixes = he_p.argv; + prefixes = he->p.argv; numPrefixes = he->c; if (!xx) { - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_INSTALLPREFIX; xx = hge(h, he, 0); if (xx) { char * t; - prefixes = xmalloc(sizeof(*prefixes) + strlen(he_p.argv[0]) + 1); + prefixes = xmalloc(sizeof(*prefixes) + strlen(he->p.argv[0]) + 1); prefixes[0] = t = (char *) &prefixes[1]; - t = stpcpy(t, he_p.argv[0]); + t = stpcpy(t, he->p.argv[0]); *t = '\0'; - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); numPrefixes = 1; } else { prefixes = NULL; @@ -959,9 +951,7 @@ /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmfi fi = psm->fi; const char * argv0 = NULL; const char * script; @@ -971,35 +961,35 @@ assert(fi->h != NULL); he->tag = psm->scriptTag; xx = hge(fi->h, he, 0); - script = he_p.str; + script = he->p.str; if (script == NULL) goto exit; he->tag = psm->progTag; xx = hge(fi->h, he, 0); - if (he_p.ptr == NULL) + if (he->p.ptr == NULL) goto exit; /* Coerce strings into header argv return. */ if (he->t == RPM_STRING_TYPE) { - const char * s = he_p.str; + const char * s = he->p.str; char * t; - he_p.argv = xmalloc(sizeof(*he_p.argv)+strlen(s)+1); - he_p.argv[0] = t = (char *) &he_p.argv[1]; + he->p.argv = xmalloc(sizeof(*he->p.argv)+strlen(s)+1); + he->p.argv[0] = t = (char *) &he->p.argv[1]; t = stpcpy(t, s); *t = '\0'; s = _free(s); } /* Expand "%script -p %%{interpreter}" macros. */ - if (he_p.argv[0][0] == '%') - he_p.argv[0] = argv0 = rpmExpand(he_p.argv[0], NULL); + if (he->p.argv[0][0] == '%') + he->p.argv[0] = argv0 = rpmExpand(he->p.argv[0], NULL); - rc = runScript(psm, fi->h, tag2sln(psm->scriptTag), he->c, he_p.argv, + rc = runScript(psm, fi->h, tag2sln(psm->scriptTag), he->c, he->p.argv, script, psm->scriptArg, -1); exit: argv0 = _free(argv0); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); script = _free(script); return rc; } @@ -1023,9 +1013,7 @@ { int scareMem = 0; HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const rpmts ts = psm->ts; rpmds trigger = NULL; const char ** triggerScripts; @@ -1039,10 +1027,10 @@ he->tag = RPMTAG_NAME; xx = hge(sourceH, he, 0); - sourceName = he_p.str; + sourceName = he->p.str; he->tag = RPMTAG_NAME; xx = hge(triggeredH, he, 0); - triggerName = he_p.str; + triggerName = he->p.str; trigger = rpmdsInit(rpmdsNew(triggeredH, RPMTAG_TRIGGERNAME, scareMem)); if (trigger == NULL) @@ -1070,13 +1058,13 @@ he->tag = RPMTAG_TRIGGERINDEX; xx = hge(triggeredH, he, 0); - triggerIndices = he_p.i32p; + triggerIndices = he->p.i32p; he->tag = RPMTAG_TRIGGERSCRIPTS; xx = hge(triggeredH, he, 0); - triggerScripts = he_p.argv; + triggerScripts = he->p.argv; he->tag = RPMTAG_TRIGGERSCRIPTPROG; xx = hge(triggeredH, he, 0); - triggerProgs = he_p.argv; + triggerProgs = he->p.argv; if (triggerIndices && triggerScripts && triggerProgs) { int arg1; @@ -1175,9 +1163,7 @@ fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const rpmts ts = psm->ts; rpmfi fi = psm->fi; const char ** triggerNames; @@ -1194,11 +1180,11 @@ he->tag = RPMTAG_TRIGGERNAME; xx = hge(fi->h, he, 0); - triggerNames = he_p.argv; + triggerNames = he->p.argv; numTriggers = he->c; he->tag = RPMTAG_TRIGGERINDEX; xx = hge(fi->h, he, 0); - triggerIndices = he_p.i32p; + triggerIndices = he->p.i32p; numTriggerIndices = he->c; if (!(triggerNames && numTriggers > 0 && triggerIndices && numTriggerIndices > 0)) @@ -1361,16 +1347,14 @@ /*@*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); uint_32 val; int xx; he->tag = tag; xx = hge(h, he, 0); - val = (xx && he_p.ui32p ? *he_p.ui32p : 0); - he_p.ptr = _free(he_p.ptr); + val = (xx && he->p.ui32p ? he->p.ui32p[0] : 0); + he->p.ptr = _free(he->p.ptr); return val; } @@ -1385,16 +1369,14 @@ /*@modifies th @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx = 1; he->tag = tag; if (hge(sh, he, 0) && he->c > 0) - xx = headerAddEntry(th, he->tag, he->t, he_p.ptr, he->c); + xx = headerAddEntry(th, he->tag, he->t, he->p.ptr, he->c); assert(xx); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); return 0; } @@ -1578,9 +1560,7 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const rpmts ts = psm->ts; uint_32 tscolor = rpmtsColor(ts); rpmfi fi = psm->fi; @@ -1676,8 +1656,8 @@ */ he->tag = RPMTAG_DEFAULTPREFIX; xx = hge(fi->h, he, 0); - fi->striplen = (xx && he_p.str ? strlen(he_p.str) + 1 : 1); - he_p.ptr = _free(he_p.ptr); + fi->striplen = (xx && he->p.str ? strlen(he->p.str) + 1 : 1); + he->p.ptr = _free(he->p.ptr); fi->mapflags = CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID | (fi->mapflags & CPIO_SBIT_CHECK); @@ -1686,18 +1666,18 @@ else he->tag = RPMTAG_FILEPATHS; xx = hge(fi->h, he, 0); -assert(he_p.argv != NULL); - fi->apath = he_p.argv; +assert(he->p.argv != NULL); + fi->apath = he->p.argv; if (fi->fuser == NULL) { he->tag = RPMTAG_FILEUSERNAME; xx = hge(fi->h, he, 0); - fi->fuser = he_p.argv; + fi->fuser = he->p.argv; } if (fi->fgroup == NULL) { he->tag = RPMTAG_FILEGROUPNAME; xx = hge(fi->h, he, 0); - fi->fgroup = he_p.argv; + fi->fgroup = he->p.argv; } rc = RPMRC_OK; } @@ -1819,19 +1799,19 @@ /* Save originnal header's origin (i.e. URL) */ he->tag = RPMTAG_PACKAGEORIGIN; xx = hge(fi->h, he, 0); - origin = he_p.str; + origin = he->p.str; /* Retrieve original header blob. */ he->tag = RPMTAG_HEADERIMMUTABLE; xx = hge(fi->h, he, 0); - uh = he_p.ptr; + uh = he->p.ptr; if (xx && uh != NULL) { psm->oh = headerCopyLoad(uh); uh = _free(uh); } else { he->tag = RPMTAG_HEADERIMAGE; xx = hge(fi->h, he, 0); - uh = he_p.ptr; + uh = he->p.ptr; if (xx && uh != NULL) { HeaderIterator hi; int_32 tag; @@ -1855,9 +1835,9 @@ if (ptr) { he->tag = tag; he->t = type; - he_p.ptr = (void *) ptr; /* NOCAST */ + he->p.ptr = (void *) ptr; /* NOCAST */ he->c = count; - xx = hae(psm->oh, he->tag, he->t, he_p, he->c); + xx = hae(psm->oh, he->tag, he->t, he->p, he->c); } } hi = headerFreeIterator(hi); @@ -1919,17 +1899,17 @@ he->tag = RPMTAG_REMOVETID; he->t = RPM_INT32_TYPE; - he_p.i32p = &tid; + he->p.i32p = &tid; he->c = 1; - xx = hae(psm->oh, he->tag, he->t, he_p, he->c); + xx = hae(psm->oh, he->tag, he->t, he->p, he->c); /* Add original header's origin (i.e. URL) */ if (origin != NULL) { he->tag = RPMTAG_PACKAGEORIGIN; he->t = RPM_STRING_TYPE; - he_p.str = origin; + he->p.str = origin; he->c = 1; - xx = hae(psm->oh, he->tag, he->t, he_p, he->c); + xx = hae(psm->oh, he->tag, he->t, he->p, he->c); origin = _free(origin); } @@ -2318,7 +2298,7 @@ he->tag = RPMTAG_PAYLOADCOMPRESSOR; xx = hge(fi->h, he, 0); - payload_compressor = he_p.str; + payload_compressor = he->p.str; if (payload_compressor == NULL) payload_compressor = xstrdup("gzip"); @@ -2335,7 +2315,7 @@ he->tag = RPMTAG_PAYLOADFORMAT; xx = hge(fi->h, he, 0); - payload_format = he_p.str; + payload_format = he->p.str; if (!xx || payload_format == NULL || !(!strcmp(payload_format, "tar") || !strcmp(payload_format, "ustar"))) { payload_format = _free(payload_format); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmchecksig.c ============================================================================ $ cvs diff -u -r1.160 -r1.161 rpmchecksig.c --- rpm/lib/rpmchecksig.c 17 Oct 2007 20:04:51 -0000 1.160 +++ rpm/lib/rpmchecksig.c 19 Oct 2007 00:36:44 -0000 1.161 @@ -143,23 +143,21 @@ /*@modifies *signid, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int rc = 1; int xx; he->tag = sigtag; xx = hge(sigh, he, 0); - if (xx && he_p.ptr != NULL) { + if (xx && he->p.ptr != NULL) { pgpDig dig = pgpNewDig(0); - if (!pgpPrtPkts(he_p.ptr, he->c, dig, 0)) { + if (!pgpPrtPkts(he->p.ptr, he->c, dig, 0)) { memcpy(signid, dig->signature.signid, sizeof(dig->signature.signid)); rc = 0; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); dig = pgpFreeDig(dig); } return rc; @@ -180,9 +178,7 @@ fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmgi gi = NULL; FD_t fd = NULL; FD_t ofd = NULL; @@ -279,11 +275,11 @@ nh = headerNew(); if (nh == NULL) { - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); goto exit; } - oh = headerCopyLoad(he_p.ptr); + oh = headerCopyLoad(he->p.ptr); for (hi = headerInitIterator(oh); headerNextIterator(hi, &htag, &type, &ptr, &count); ptr = headerFreeData(ptr, type)) @@ -673,9 +669,7 @@ /*@modifies fd, *dig, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); unsigned char buf[4*BUFSIZ]; ssize_t count; int rc = 1; @@ -699,7 +693,7 @@ he->tag = RPMTAG_HEADERIMMUTABLE; xx = hge(h, he, 0); - if (!xx || he_p.ptr == NULL) { + if (!xx || he->p.ptr == NULL) { h = headerFree(h); rpmlog(RPMLOG_ERR, _("%s: headerGetEntry failed\n"), fn); goto exit; @@ -708,12 +702,12 @@ dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE); if (hmagic && nmagic > 0) (void) rpmDigestUpdate(dig->hdrsha1ctx, hmagic, nmagic); - (void) rpmDigestUpdate(dig->hdrsha1ctx, he_p.ptr, he->c); + (void) rpmDigestUpdate(dig->hdrsha1ctx, he->p.ptr, he->c); dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE); if (hmagic && nmagic > 0) (void) rpmDigestUpdate(dig->hdrmd5ctx, hmagic, nmagic); - (void) rpmDigestUpdate(dig->hdrmd5ctx, he_p.ptr, he->c); - he_p.ptr = _free(he_p.ptr); + (void) rpmDigestUpdate(dig->hdrmd5ctx, he->p.ptr, he->c); + he->p.ptr = _free(he->p.ptr); } h = headerFree(h); } @@ -762,9 +756,7 @@ const char * fn) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int res2, res3; char result[1024]; char buf[8192], * b; @@ -861,8 +853,8 @@ ) { he->tag = sigtag; xx = hge(sigh, he, 0); - xx = pgpPrtPkts(he_p.ptr, he->c, dig, 0); - he_p.ptr = _free(he_p.ptr); + xx = pgpPrtPkts(he->p.ptr, he->c, dig, 0); + he->p.ptr = _free(he->p.ptr); #if defined(SUPPORT_RPMV3_VERIFY_RSA) /* XXX assume same hash_algo in header-only and header+payload */ if ((headerIsEntry(sigh, RPMSIGTAG_PGP) @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.c ============================================================================ $ cvs diff -u -r2.75 -r2.76 rpmds.c --- rpm/lib/rpmds.c 17 Oct 2007 20:04:51 -0000 2.75 +++ rpm/lib/rpmds.c 19 Oct 2007 00:36:44 -0000 2.76 @@ -236,9 +236,7 @@ { int scareMem = (flags & 0x1); HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmTag tagEVR, tagF; rpmds ds = NULL; @@ -287,7 +285,7 @@ he->tag = tagN; xx = hge(h, he, 0); - N = he_p.argv; + N = he->p.argv; Count = he->c; if (xx && N != NULL && Count > 0) { ds = xcalloc(1, sizeof(*ds)); @@ -303,23 +301,23 @@ if (tagEVR > 0) { he->tag = tagEVR; xx = hge(h, he, 0); - ds->EVR = he_p.argv; + ds->EVR = he->p.argv; } if (tagF > 0) { he->tag = tagF; xx = hge(h, he, 0); - ds->Flags = he_p.i32p; + ds->Flags = he->p.i32p; } { he->tag = RPMTAG_ARCH; xx = hge(h, he, 0); - ds->A = he_p.str; + ds->A = he->p.str; } { he->tag = RPMTAG_BUILDTIME; xx = hge(h, he, 0); - ds->BT = (he_p.ui32p ? *he_p.ui32p : 0); - he_p.ptr = _free(he_p.ptr); + ds->BT = (he->p.ui32p ? he->p.ui32p[0] : 0); + he->p.ptr = _free(he->p.ptr); } if (tagN == RPMTAG_DIRNAMES) { @@ -475,9 +473,7 @@ rpmds rpmdsThis(Header h, rpmTag tagN, int_32 Flags) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmds ds = NULL; const char * Type; const char * Name, * V, * R; @@ -511,8 +507,8 @@ he->tag = RPMTAG_EPOCH; xx = hge(h, he, 0); - E = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + E = (he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); /*@-mods@*/ xx = headerNEVRA(h, &Name, NULL, &V, &R, NULL); @@ -544,12 +540,12 @@ he->tag = RPMTAG_ARCH; xx = hge(h, he, 0); - ds->A = he_p.str; + ds->A = he->p.str; he->tag = RPMTAG_BUILDTIME; xx = hge(h, he, 0); - ds->BT = (he_p.ui32p ? *he_p.ui32p : 0); - he_p.ptr = _free(he_p.ptr); + ds->BT = (he->p.ui32p ? he->p.ui32p[0] : 0); + he->p.ptr = _free(he->p.ptr); { char pre[2]; pre[0] = ds->Type[0]; @@ -3713,9 +3709,7 @@ int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * pkgN, * V, * R; int_32 E; int gotE = 0; @@ -3741,8 +3735,8 @@ /*@=mods@*/ he->tag = RPMTAG_EPOCH; gotE = hge(h, he, 0); - E = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + E = (he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); nb = 21 + 1 + 1; if (V) nb += strlen(V); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfc.c ============================================================================ $ cvs diff -u -r1.27 -r1.28 rpmfc.c --- rpm/lib/rpmfc.c 17 Oct 2007 20:04:51 -0000 1.27 +++ rpm/lib/rpmfc.c 19 Oct 2007 00:36:44 -0000 1.28 @@ -1322,9 +1322,7 @@ /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); StringBuf sb_stdin = newStringBuf(); StringBuf sb_stdout = NULL; DepMsg_t dm; @@ -1342,22 +1340,22 @@ /* Retrieve scriptlet interpreter. */ he->tag = dm->ntag; xx = hge(pkg->header, he, 0); - if (!xx || he_p.str == NULL) + if (!xx || he->p.str == NULL) continue; - xx = strcmp(he_p.str, "/bin/sh") && strcmp(he_p.str, "/bin/bash"); - he_p.ptr = _free(he_p.ptr); + xx = strcmp(he->p.str, "/bin/sh") && strcmp(he->p.str, "/bin/bash"); + he->p.ptr = _free(he->p.ptr); if (xx) continue; /* Retrieve scriptlet body. */ he->tag = dm->vtag; xx = hge(pkg->header, he, 0); - if (!xx || he_p.str == NULL) + if (!xx || he->p.str == NULL) continue; truncStringBuf(sb_stdin); - appendLineStringBuf(sb_stdin, he_p.str); + appendLineStringBuf(sb_stdin, he->p.str); stripTrailingBlanksStringBuf(sb_stdin); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); xx = rpmfcExec(dm->argv, sb_stdin, &sb_stdout, failnonzero); if (xx == -1) @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.c ============================================================================ $ cvs diff -u -r2.91 -r2.92 rpmfi.c --- rpm/lib/rpmfi.c 17 Oct 2007 20:04:51 -0000 2.91 +++ rpm/lib/rpmfi.c 19 Oct 2007 00:36:44 -0000 2.92 @@ -686,11 +686,9 @@ { rpmte p = rpmtsRelocateElement(ts); HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; HAE_t hae = (HAE_t) headerAddEntry; HME_t hme = (HME_t) headerModifyEntry; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); static int _printed = 0; int allowBadRelocate = (rpmtsFilterFlags(ts) & RPMPROB_FILTER_FORCERELOCATE); rpmRelocation relocations = NULL; @@ -722,7 +720,7 @@ he->tag = RPMTAG_PREFIXES; xx = hge(origH, he, 0); validType = he->t; - validRelocations = he_p.argv; + validRelocations = he->p.argv; numValid = he->c; if (!xx) numValid = 0; @@ -745,9 +743,9 @@ if (!headerIsEntry(origH, RPMTAG_INSTPREFIXES)) { he->tag = RPMTAG_INSTPREFIXES; he->t = validType; - he_p.argv = validRelocations; + he->p.argv = validRelocations; he->c = numValid; - xx = hae(origH, he->tag, he->t, he_p, he->c); + xx = hae(origH, he->tag, he->t, he->p, he->c); } validRelocations = _free(validRelocations); } @@ -873,9 +871,9 @@ if (numActual) { he->tag = RPMTAG_INSTPREFIXES; he->t = RPM_STRING_ARRAY_TYPE; - he_p.argv = actualRelocations; + he->p.argv = actualRelocations; he->c = numActual; - xx = hae(h, he->tag, he->t, he_p, he->c); + xx = hae(h, he->tag, he->t, he->p, he->c); } actualRelocations = _free(actualRelocations); @@ -884,24 +882,24 @@ he->tag = RPMTAG_BASENAMES; xx = hge(h, he, 0); - baseNames = he_p.argv; + baseNames = he->p.argv; fileCount = he->c; he->tag = RPMTAG_DIRINDEXES; xx = hge(h, he, 0); - dirIndexes = he_p.i32p; + dirIndexes = he->p.i32p; he->tag = RPMTAG_DIRNAMES; xx = hge(h, he, 0); - dirNames = he_p.argv; + dirNames = he->p.argv; dirCount = he->c; he->tag = RPMTAG_FILEFLAGS; xx = hge(h, he, 0); - fFlags = he_p.ui32p; + fFlags = he->p.ui32p; he->tag = RPMTAG_FILECOLORS; xx = hge(h, he, 0); - fColors = he_p.ui32p; + fColors = he->p.ui32p; he->tag = RPMTAG_FILEMODES; xx = hge(h, he, 0); - fModes = he_p.ui16p; + fModes = he->p.ui16p; dColors = alloca(dirCount * sizeof(*dColors)); memset(dColors, 0, dirCount * sizeof(*dColors)); @@ -1104,49 +1102,49 @@ he->tag = RPMTAG_BASENAMES; xx = hge(h, he, 0); he->tag = RPMTAG_ORIGBASENAMES; - xx = hae(h, he->tag, he->t, he_p, he->c); - he_p.ptr = _free(he_p.ptr); + xx = hae(h, he->tag, he->t, he->p, he->c); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_DIRNAMES; xx = hge(h, he, 0); he->tag = RPMTAG_ORIGDIRNAMES; - xx = hae(h, he->tag, he->t, he_p, he->c); - he_p.ptr = _free(he_p.ptr); + xx = hae(h, he->tag, he->t, he->p, he->c); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_DIRINDEXES; xx = hge(h, he, 0); he->tag = RPMTAG_ORIGDIRINDEXES; - xx = hae(h, he->tag, he->t, he_p, he->c); - he_p.ptr = _free(he_p.ptr); + xx = hae(h, he->tag, he->t, he->p, he->c); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_BASENAMES; he->t = RPM_STRING_ARRAY_TYPE; - he_p.argv = baseNames; + he->p.argv = baseNames; he->c = fileCount; - xx = hme(h, he->tag, he->t, he_p, he->c); + xx = hme(h, he->tag, he->t, he->p, he->c); fi->bnl = _free(fi->bnl); xx = hge(h, he, 0); - fi->bnl = he_p.argv; + fi->bnl = he->p.argv; fi->fc = he->c; he->tag = RPMTAG_DIRNAMES; he->t = RPM_STRING_ARRAY_TYPE; - he_p.argv = dirNames; + he->p.argv = dirNames; he->c = dirCount; - xx = hme(h, he->tag, he->t, he_p, he->c); + xx = hme(h, he->tag, he->t, he->p, he->c); fi->dnl = _free(fi->dnl); xx = hge(h, he, 0); - fi->dnl = he_p.argv; + fi->dnl = he->p.argv; fi->dc = he->c; he->tag = RPMTAG_DIRINDEXES; he->t = RPM_INT32_TYPE; - he_p.i32p = dirIndexes; + he->p.i32p = dirIndexes; he->c = fileCount; - xx = hme(h, he->tag, he->t, he_p, he->c); + xx = hme(h, he->tag, he->t, he->p, he->c); fi->dil = _free(fi->dil); xx = hge(h, he, 0); - fi->dil = he_p.ui32p; + fi->dil = he->p.ui32p; } baseNames = _free(baseNames); @@ -1265,20 +1263,18 @@ #define _fdupestring(_h, _tag, _data) \ he->tag = _tag; \ xx = hge((_h), he, 0); \ - _data = he_p.str; + _data = he->p.str; #define _fdupedata(_h, _tag, _data) \ he->tag = _tag; \ xx = hge((_h), he, 0); \ - _data = he_p.ptr; + _data = he->p.ptr; rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, int flags) { int scareMem = (flags & 0x1); HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmte p; rpmfi fi = NULL; const char * Type; @@ -1319,8 +1315,8 @@ he->tag = RPMTAG_ARCHIVESIZE; xx = hge(h, he, 0); fi->archivePos = 0; - fi->archiveSize = (xx && he_p.ui32p ? *he_p.ui32p : 0); - he_p.ptr = _free(he_p.ptr); + fi->archiveSize = (xx && he->p.ui32p ? he->p.ui32p[0] : 0); + he->p.ptr = _free(he->p.ptr); /* Extract pre- and post-transaction script and interpreter strings. */ _fdupestring(h, RPMTAG_PRETRANS, fi->pretrans); @@ -1332,7 +1328,7 @@ he->tag = RPMTAG_BASENAMES; xx = hge(h, he, 0); - fi->bnl = he_p.argv; + fi->bnl = he->p.argv; fi->fc = he->c; if (!xx) { fi->fc = 0; @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpminstall.c ============================================================================ $ cvs diff -u -r1.177 -r1.178 rpminstall.c --- rpm/lib/rpminstall.c 17 Oct 2007 20:04:51 -0000 1.177 +++ rpm/lib/rpminstall.c 19 Oct 2007 00:36:44 -0000 1.178 @@ -307,9 +307,7 @@ int rpmcliInstall(rpmts ts, QVA_t ia, const char ** argv) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int numFailed = 0; int numRPMS = 0; rpmRelocation relocations = NULL; @@ -423,15 +421,15 @@ he->tag = RPMTAG_PREFIXES; xx = hge(h, he, 0); if (xx && he->c == 1) { - relocations->oldPath = xstrdup(he_p.argv[0]); - he_p.ptr = _free(he_p.ptr); + relocations->oldPath = xstrdup(he->p.argv[0]); + he->p.ptr = _free(he->p.ptr); } else { - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); rpmlog(RPMLOG_ERR, - _("package %s is not relocatable\n"), he_p.str); - he_p.ptr = _free(he_p.ptr); + _("package %s is not relocatable\n"), he->p.str); + he->p.ptr = _free(he->p.ptr); numFailed++; goto exit; /*@notreached@*/ @@ -446,9 +444,9 @@ he->tag = RPMTAG_NAME; xx = hge(h, he, 0); -assert(xx != 0 && he_p.str != NULL); - mi = rpmtsInitIterator(ts, RPMTAG_NAME, he_p.str, 0); - he_p.ptr = _free(he_p.ptr); +assert(xx != 0 && he->p.str != NULL); + mi = rpmtsInitIterator(ts, RPMTAG_NAME, he->p.str, 0); + he->p.ptr = _free(he->p.ptr); count = rpmdbGetIteratorCount(mi); while ((oldH = rpmdbNextIterator(mi)) != NULL) { if (rpmVersionCompare(oldH, h) < 0) @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmrollback.c ============================================================================ $ cvs diff -u -r1.22 -r1.23 rpmrollback.c --- rpm/lib/rpmrollback.c 17 Oct 2007 20:04:51 -0000 1.22 +++ rpm/lib/rpmrollback.c 19 Oct 2007 00:36:44 -0000 1.23 @@ -91,9 +91,7 @@ IDTX IDTXload(rpmts ts, rpmTag tag, uint_32 rbtid) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); IDTX idtx = NULL; rpmdbMatchIterator mi; Header h; @@ -107,10 +105,10 @@ while ((h = rpmdbNextIterator(mi)) != NULL) { he->tag = tag; xx = hge(h, he, 0); - if (!xx || he_p.i32p == NULL) + if (!xx || he->p.i32p == NULL) continue; - tid = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + tid = (he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); if (tid == 0 || tid == -1) continue; @@ -143,9 +141,7 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag, uint_32 rbtid) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); IDTX idtx = NULL; Header h; int_32 tid; @@ -197,10 +193,10 @@ } he->tag = tag; xx = hge(h, he, 0); - if (!xx || he_p.i32p == NULL) + if (!xx || he->p.i32p == NULL) goto bottom; - tid = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + tid = (he->p.i32p ? he->p.i32p[0] : 0); + he->p.ptr = _free(he->p.ptr); /* Don't bother with headers installed prior to the rollback goal. */ if (tid < rbtid) @@ -291,9 +287,7 @@ /*@modifies ts, p, ip, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int rc = 0; int xx; @@ -314,7 +308,7 @@ he->tag = RPMTAG_BLINKPKGID; xx = hge(ip->h, he, 0); - flinkPkgid = he_p.argv; + flinkPkgid = he->p.argv; pn = he->c; /* XXX Always erase packages at beginning of upgrade chain. */ @@ -325,11 +319,11 @@ he->tag = RPMTAG_BLINKHDRID; xx = hge(ip->h, he, 0); - flinkHdrid = he_p.argv; + flinkHdrid = he->p.argv; hn = he->c; he->tag = RPMTAG_BLINKNEVRA; xx = hge(ip->h, he, 0); - flinkNEVRA = he_p.argv; + flinkNEVRA = he->p.argv; nn = he->c; /* @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmte.c ============================================================================ $ cvs diff -u -r2.62 -r2.63 rpmte.c --- rpm/lib/rpmte.c 17 Oct 2007 20:04:51 -0000 2.62 +++ rpm/lib/rpmte.c 19 Oct 2007 00:36:44 -0000 2.63 @@ -96,15 +96,13 @@ { int scareMem = 0; HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); -assert(he_p.str != NULL); - p->NEVR = he_p.str; +assert(he->p.str != NULL); + p->NEVR = he->p.str; p->name = xstrdup(p->NEVR); if ((p->release = strrchr(p->name, '-')) != NULL) *p->release++ = '\0'; @@ -115,32 +113,32 @@ he->tag = RPMTAG_HDRID; xx = hge(h, he, 0); - p->hdrid = he_p.str; + p->hdrid = he->p.str; he->tag = RPMTAG_PKGID; xx = hge(h, he, 0); - if (he_p.ui8p != NULL) { + if (he->p.ui8p != NULL) { static const char hex[] = "0123456789abcdef"; char * t; int i; p->pkgid = t = xmalloc((2*he->c) + 1); for (i = 0 ; i < he->c; i++) { - *t++ = hex[ (unsigned)((he_p.ui8p[i] >> 4) & 0x0f) ]; - *t++ = hex[ (unsigned)((he_p.ui8p[i] ) & 0x0f) ]; + *t++ = hex[ (unsigned)((he->p.ui8p[i] >> 4) & 0x0f) ]; + *t++ = hex[ (unsigned)((he->p.ui8p[i] ) & 0x0f) ]; } *t = '\0'; - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } else p->pkgid = NULL; he->tag = RPMTAG_ARCH; xx = hge(h, he, 0); - p->arch = he_p.str; + p->arch = he->p.str; he->tag = RPMTAG_OS; xx = hge(h, he, 0); - p->os = he_p.str; + p->os = he->p.str; p->isSource = (headerIsEntry(h, RPMTAG_SOURCERPM) == 0 && @@ -150,10 +148,10 @@ he->tag = RPMTAG_EPOCH; xx = hge(h, he, 0); - if (he_p.i32p != NULL) { + if (he->p.i32p != NULL) { p->epoch = xmalloc(20); - sprintf(p->epoch, "%d", *he_p.i32p); - he_p.ptr = _free(he_p.ptr); + sprintf(p->epoch, "%d", he->p.i32p[0]); + he->p.ptr = _free(he->p.ptr); } else p->epoch = NULL; @@ -217,9 +215,7 @@ alKey pkgKey) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmte p = xcalloc(1, sizeof(*p)); int xx; @@ -233,9 +229,9 @@ p->pkgFileSize = 96 + 256; he->tag = RPMTAG_SIGSIZE; xx = hge(h, he, 0); - if (xx && he_p.ui32p) - p->pkgFileSize += *he_p.ui32p; - he_p.ptr = _free(he_p.ptr); + if (xx && he->p.ui32p) + p->pkgFileSize += *he->p.ui32p; + he->p.ptr = _free(he->p.ptr); break; case TR_REMOVED: p->u.addedKey = pkgKey; @@ -603,9 +599,7 @@ int rpmteChain(rpmte p, rpmte q, Header oh, const char * msg) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * blinkNEVRA = NULL; const char * blinkPkgid = NULL; const char * blinkHdrid = NULL; @@ -615,8 +609,8 @@ msg = ""; he->tag = RPMTAG_NVRA; xx = hge(oh, he, 0); -assert(he_p.str != NULL); - blinkNEVRA = he_p.str; +assert(he->p.str != NULL); + blinkNEVRA = he->p.str; /* * Convert binary pkgid to a string. @@ -625,24 +619,24 @@ */ he->tag = RPMTAG_PKGID; xx = hge(oh, he, 0); - if (xx && he_p.ui8p != NULL) { + if (xx && he->p.ui8p != NULL) { static const char hex[] = "0123456789abcdef"; char * t; int i; blinkPkgid = t = xmalloc((2*he->c) + 1); for (i = 0 ; i < he->c; i++) { - *t++ = hex[ ((he_p.ui8p[i] >> 4) & 0x0f) ]; - *t++ = hex[ ((he_p.ui8p[i] ) & 0x0f) ]; + *t++ = hex[ ((he->p.ui8p[i] >> 4) & 0x0f) ]; + *t++ = hex[ ((he->p.ui8p[i] ) & 0x0f) ]; } *t = '\0'; - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } else blinkPkgid = NULL; he->tag = RPMTAG_HDRID; xx = hge(oh, he, 0); - blinkHdrid = he_p.str; + blinkHdrid = he->p.str; /*@-modfilesys@*/ if (__mydebug) @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmts.c ============================================================================ $ cvs diff -u -r2.113 -r2.114 rpmts.c --- rpm/lib/rpmts.c 17 Oct 2007 20:04:51 -0000 2.113 +++ rpm/lib/rpmts.c 19 Oct 2007 00:36:44 -0000 2.114 @@ -305,9 +305,7 @@ int rpmtsSolve(rpmts ts, rpmds ds, /*@unused@*/ const void * data) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * errstr; const char * str = NULL; const char * qfmt; @@ -358,8 +356,8 @@ he->tag = RPMTAG_NAME; xx = hge(h, he, 0); - hnamelen = ((xx && he_p.str) ? strlen(he_p.str) : 0); - he_p.ptr = _free(he_p.ptr); + hnamelen = ((xx && he->p.str) ? strlen(he->p.str) : 0); + he->p.ptr = _free(he->p.ptr); /* XXX Prefer the shortest pkg N for basenames/provides resp. */ if (bhnamelen > 0 && hnamelen > bhnamelen) @@ -368,8 +366,8 @@ /* XXX Prefer the newest build if given alternatives. */ he->tag = RPMTAG_BUILDTIME; xx = hge(h, he, 0); - htime = (xx && he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + htime = (xx && he->p.ui32p ? he->p.ui32p[0] : 0); + he->p.ptr = _free(he->p.ptr); if (htime <= bhtime) continue; @@ . patch -p0 <<'@@ .' Index: rpm/lib/transaction.c ============================================================================ $ cvs diff -u -r1.346 -r1.347 transaction.c --- rpm/lib/transaction.c 17 Oct 2007 20:04:51 -0000 1.346 +++ rpm/lib/transaction.c 19 Oct 2007 00:36:44 -0000 1.347 @@ -101,9 +101,7 @@ /*@modifies ts, p, fi, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * altNVRA = NULL; uint_32 tscolor = rpmtsColor(ts); uint_32 prefcolor = rpmtsPrefColor(ts); @@ -124,8 +122,8 @@ while ((h = rpmdbNextIterator(mi)) != NULL) { he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); -assert(he_p.str != NULL); - altNVRA = he_p.str; +assert(he->p.str != NULL); + altNVRA = he->p.str; otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem); break; } @@ -249,9 +247,7 @@ /*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); Header h; const unsigned char * otherStates; int i, xx; @@ -268,7 +264,7 @@ he->tag = RPMTAG_FILESTATES; xx = hge(h, he, 0); - otherStates = he_p.ptr; + otherStates = he->p.ptr; /* XXX there's an obscure segfault here w/o NULL check ... */ if (otherStates != NULL) @@ -282,7 +278,7 @@ fi->actions[fileNum] = FA_SKIP; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); mi = rpmdbFreeIterator(mi); return 0; @@ -615,9 +611,7 @@ /*@modifies ts @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int_32 reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL); const char * reqEVR; rpmds req; @@ -645,13 +639,13 @@ rpmps ps = rpmtsProblems(ts); he->tag = RPMTAG_NVRA; rc = hge(h, he, 0); -assert(he_p.str != NULL); +assert(he->p.str != NULL); rpmpsAppend(ps, RPMPROB_OLDPACKAGE, rpmteNEVR(p), rpmteKey(p), NULL, NULL, - he_p.str, + he->p.str, 0); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); ps = rpmpsFree(ps); rc = 1; } else @@ . patch -p0 <<'@@ .' Index: rpm/python/header-py.c ============================================================================ $ cvs diff -u -r1.66 -r1.67 header-py.c --- rpm/python/header-py.c 17 Oct 2007 20:04:52 -0000 1.66 +++ rpm/python/header-py.c 19 Oct 2007 00:36:46 -0000 1.67 @@ -173,21 +173,19 @@ /*@modifies h @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; HAE_t hae = (HAE_t)headerAddEntry; HRE_t hre = (HRE_t)headerRemoveEntry; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; /*@-branchstate@*/ if (!headerIsEntry(h, RPMTAG_OLDFILENAMES)) { he->tag = RPMTAG_FILEPATHS; xx = hge(h, he, 0); - if (he_p.ptr == NULL || he->c <= 0) + if (he->p.ptr == NULL || he->c <= 0) return; - xx = hae(h, RPMTAG_OLDFILENAMES, he->t, he_p.ptr, he->c); - he_p.ptr = _free(he_p.ptr); + xx = hae(h, RPMTAG_OLDFILENAMES, he->t, he->p, he->c); + he->p.ptr = _free(he->p.ptr); } /*@=branchstate@*/ @@ -205,11 +203,9 @@ /*@modifies h @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; HAE_t hae = (HAE_t)headerAddEntry; HRE_t hre = (HRE_t)headerRemoveEntry; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char ** fileNames; const char ** dirNames; const char ** baseNames; @@ -232,7 +228,7 @@ he->tag = RPMTAG_OLDFILENAMES; xx = hge(h, he, 0); - fileNames = he_p.argv; + fileNames = he->p.argv; count = he->c; if (!xx || fileNames == NULL || count <= 0) return; /* no file list */ @@ -305,9 +301,7 @@ /*@*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; if (!headerIsEntry (h, RPMTAG_BASENAMES) @@ -318,13 +312,13 @@ he->tag = RPMTAG_FILEPATHS; xx = hge(h, he, 0); - if (he_p.ptr == NULL || he->c <= 0) + if (he->p.ptr == NULL || he->c <= 0) return; /* XXX Legacy tag needs to go away. */ - headerAddEntry(h, RPMTAG_OLDFILENAMES, he->t, he_p.ptr, he->c); + headerAddEntry(h, RPMTAG_OLDFILENAMES, he->t, he->p.ptr, he->c); - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } #endif /* SUPPORT_RPMV3_BASENAMES_HACKS */ @@ -337,9 +331,7 @@ static void providePackageNVR(Header h) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char *N, *V, *R; int_32 E; int gotE; @@ -361,8 +353,8 @@ *p = '\0'; he->tag = RPMTAG_EPOCH; gotE = hge(h, he, 0); - E = (he_p.i32p ? *he_p.i32p : 0); - he_p.ptr = _free(he_p.ptr); + E = (he->p.i32p ? *he->p.i32p : 0); + he->p.ptr = _free(he->p.ptr); if (gotE) { sprintf(p, "%d:", E); p += strlen(p); @@ -375,7 +367,7 @@ */ he->tag = RPMTAG_PROVIDENAME; xx = hge(h, he, 0); - provides = he_p.argv; + provides = he->p.argv; providesCount = he->c; if (!xx) goto exit; @@ -385,7 +377,7 @@ */ he->tag = RPMTAG_PROVIDEVERSION; xx = hge(h, he, 0); - providesEVR = he_p.argv; + providesEVR = he->p.argv; if (!xx) { for (i = 0; i < providesCount; i++) { char * vdummy = ""; @@ -400,7 +392,7 @@ he->tag = RPMTAG_PROVIDEFLAGS; xx = hge(h, he, 0); - provideFlags = he_p.i32p; + provideFlags = he->p.i32p; /*@-nullderef@*/ /* LCL: providesEVR is not NULL */ if (provides && providesEVR && provideFlags) @@ -700,13 +692,11 @@ * @return 0 on success, 1 on bad magic, 2 on error */ static int rpmHeaderGetEntry(Header h, rpmTag tag, /*@out@*/ rpmTagType *type, - /*@out@*/ void **p, /*@out@*/ rpmTagCount *c) + /*@out@*/ rpmTagData *p, /*@out@*/ rpmTagCount *c) /*@modifies *type, *p, *c @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; switch (tag) { @@ -715,9 +705,9 @@ he->tag = RPMTAG_FILEPATHS; xx = hge(h, he, 0); if (p) - *p = he_p.ptr; + (*p).ptr = he->p.ptr; else - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); if (c) *c = he->c; if (type) *type = he->t; return (he->c > 0 ? 1 : 0); @@ -736,7 +726,11 @@ /* XXX FIXME: memory leak. */ msgstr = headerSprintf(h, fmt, rpmTagTable, rpmHeaderFormats, &errstr); if (msgstr) { - *p = (void *) msgstr; + if (p) + (*p).str = msgstr; + else + msgstr = _free(msgstr); + if (type) *type = RPM_STRING_TYPE; if (c) *c = 1; return 1; @@ -758,14 +752,11 @@ static PyObject * hdr_subscript(hdrObject * s, PyObject * item) /*@*/ { - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int_32 tag = -1; - void * data; + rpmTagData data; int i; PyObject * o, * metao; - char ** stringArray; int forceArray = 0; int freeData = 0; char * str; @@ -793,8 +784,8 @@ /* Retrieve data from extension or header. */ if (ext) { - he->p = (hRET_t *)&data; /* NOCAST */ ext->u.tagFunction(s->h, he); + data.ptr = he->p.ptr; freeData = he->freeData; } else { if (tag == -1) { @@ -866,93 +857,90 @@ case RPM_OPENPGP_TYPE: case RPM_ASN1_TYPE: case RPM_BIN_TYPE: - o = PyString_FromStringAndSize(data, he->c); + o = PyString_FromStringAndSize(data.str, he->c); break; - case RPM_INT64_TYPE: + case RPM_CHAR_TYPE: + case RPM_INT8_TYPE: if (he->c != 1 || forceArray) { metao = PyList_New(0); for (i = 0; i < he->c; i++) { - o = PyInt_FromLong(((long long *) data)[i]); + o = PyInt_FromLong(data.i8p[i]); PyList_Append(metao, o); Py_DECREF(o); } o = metao; } else { - o = PyInt_FromLong(*((long long *) data)); + o = PyInt_FromLong(data.i8p[0]); } break; - case RPM_INT32_TYPE: + + case RPM_INT16_TYPE: if (he->c != 1 || forceArray) { metao = PyList_New(0); for (i = 0; i < he->c; i++) { - o = PyInt_FromLong(((int *) data)[i]); + o = PyInt_FromLong(data.i16p[i]); PyList_Append(metao, o); Py_DECREF(o); } o = metao; } else { - o = PyInt_FromLong(*((int *) data)); + o = PyInt_FromLong(data.i16p[0]); } break; - case RPM_CHAR_TYPE: - case RPM_INT8_TYPE: + case RPM_INT32_TYPE: if (he->c != 1 || forceArray) { metao = PyList_New(0); for (i = 0; i < he->c; i++) { - o = PyInt_FromLong(((char *) data)[i]); + o = PyInt_FromLong(data.i32p[i]); PyList_Append(metao, o); Py_DECREF(o); } o = metao; } else { - o = PyInt_FromLong(*((char *) data)); + o = PyInt_FromLong(data.i32p[0]); } break; - case RPM_INT16_TYPE: + case RPM_INT64_TYPE: if (he->c != 1 || forceArray) { metao = PyList_New(0); for (i = 0; i < he->c; i++) { - o = PyInt_FromLong(((short *) data)[i]); + o = PyInt_FromLong(data.i64p[i]); PyList_Append(metao, o); Py_DECREF(o); } o = metao; } else { - o = PyInt_FromLong(*((short *) data)); + o = PyInt_FromLong(data.i64p[0]); } break; case RPM_STRING_ARRAY_TYPE: - stringArray = data; - metao = PyList_New(0); for (i = 0; i < he->c; i++) { - o = PyString_FromString(stringArray[i]); + o = PyString_FromString(data.argv[i]); PyList_Append(metao, o); Py_DECREF(o); } - free (stringArray); o = metao; + data.ptr = _free(data.ptr); break; case RPM_STRING_TYPE: if (he->c != 1 || forceArray) { - stringArray = data; - metao = PyList_New(0); for (i=0; i < he->c; i++) { - o = PyString_FromString(stringArray[i]); + o = PyString_FromString(data.argv[i]); PyList_Append(metao, o); Py_DECREF(o); } o = metao; } else { - o = PyString_FromString(data); + o = PyString_FromString(data.argv[0]); if (freeData) - free (data); + data.ptr = _free(data.ptr); } break; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/hdrNVR.c ============================================================================ $ cvs diff -u -r1.19 -r1.20 hdrNVR.c --- rpm/rpmdb/hdrNVR.c 17 Oct 2007 20:04:53 -0000 1.19 +++ rpm/rpmdb/hdrNVR.c 19 Oct 2007 00:36:47 -0000 1.20 @@ -36,9 +36,7 @@ /*@modifies rpmGlobalMacroContext @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); struct tagMacro * tagm; char numbuf[32]; int xx; @@ -62,11 +60,11 @@ continue; switch (he->t) { case RPM_INT32_TYPE: - sprintf(numbuf, "%d", *he_p.i32p); + sprintf(numbuf, "%d", he->p.i32p[0]); addMacro(NULL, tagm->macroname, NULL, numbuf, -1); /*@switchbreak@*/ break; case RPM_STRING_TYPE: - addMacro(NULL, tagm->macroname, NULL, he_p.str, -1); + addMacro(NULL, tagm->macroname, NULL, he->p.str, -1); /*@switchbreak@*/ break; case RPM_STRING_ARRAY_TYPE: case RPM_I18NSTRING_TYPE: @@ -78,7 +76,7 @@ default: /*@switchbreak@*/ break; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } return 0; } @@ -90,9 +88,7 @@ /*@modifies rpmGlobalMacroContext @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); struct tagMacro * tagm; int xx; @@ -118,7 +114,7 @@ default: /*@switchbreak@*/ break; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } /* XXX restore previous %{buildroot} (if any) */ @@ -178,20 +174,18 @@ uint_32 hGetColor(Header h) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); uint_32 hcolor = 0; int xx; he->tag = RPMTAG_FILECOLORS; xx = hge(h, he, 0); - if (xx && he_p.ptr != NULL && he->c > 0) { + if (xx && he->p.ptr != NULL && he->c > 0) { int i; for (i = 0; i < he->c; i++) - hcolor |= he_p.ui32p[i]; + hcolor |= he->p.ui32p[i]; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); hcolor &= 0x0f; return hcolor; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/hdrfmt.c ============================================================================ $ cvs diff -u -r1.19 -r1.20 hdrfmt.c --- rpm/rpmdb/hdrfmt.c 18 Oct 2007 20:31:17 -0000 1.19 +++ rpm/rpmdb/hdrfmt.c 19 Oct 2007 00:36:47 -0000 1.20 @@ -78,7 +78,7 @@ static /*@only@*/ char * triggertypeFormat(HE_t he, /*@unused@*/ char * formatPrefix, /*@unused@*/ int padding) { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; const int_32 * item = data.i32p; char * val; @@ -109,7 +109,7 @@ /*@modifies formatPrefix @*/ /*@requires maxRead(data) >= 0 @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; char * val; char * buf; @@ -140,7 +140,7 @@ /*@modifies formatPrefix @*/ /*@requires maxRead(data) >= 0 @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; /* XXX HACK: he->freeData for element index. */ int element = he->freeData; char * val; @@ -192,7 +192,7 @@ /*@unused@*/ char * formatPrefix, /*@unused@*/ int padding) /*@*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; const char * enc; const unsigned char * s; size_t ns; @@ -249,7 +249,7 @@ /*@unused@*/ char * formatPrefix, int padding) /*@*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; char * val; if (!(he->t == RPM_BIN_TYPE || he->t == RPM_ASN1_TYPE || he->t == RPM_OPENPGP_TYPE)) { @@ -350,7 +350,7 @@ char * formatPrefix, int padding) /*@modifies formatPrefix @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; const char * xtag = NULL; size_t nb; char * val; @@ -511,7 +511,7 @@ char * formatPrefix, int padding) /*@modifies formatPrefix @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; int element = he->freeData; /* XXX HACK: he->freeData for element index. */ const char * xtag = NULL; const char * ytag = NULL; @@ -667,7 +667,7 @@ /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; char * val, * t; if (!(he->t == RPM_BIN_TYPE || he->t == RPM_ASN1_TYPE || he->t == RPM_OPENPGP_TYPE)) { @@ -774,7 +774,7 @@ /*@modifies formatPrefix @*/ /*@requires maxRead(data) >= 0 @*/ { - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; char * val; if (he->t != RPM_INT32_TYPE) { @@ -833,7 +833,7 @@ char ** array; he->tag = RPMTAG_INSTALLPREFIX; - if (headerGetEntry(h, RPMTAG_INSTALLPREFIX, &he->t, he->p, &he->c)) { + if (headerGetEntry(h, RPMTAG_INSTALLPREFIX, &he->t, &he->p, &he->c)) { he->freeData = 0; return 0; } @@ -841,7 +841,7 @@ if (headerGetEntry(h, he->tag, &ipt, &array, &he->c)) { he->t = RPM_STRING_TYPE; he->c = 1; - if (he->p) (*he->p).str = xstrdup(array[0]); + he->p.str = xstrdup(array[0]); he->freeData = 1; array = headerFreeData(array, ipt); return 0; @@ -858,6 +858,7 @@ static int triggercondsTag(Header h, HE_t he) /*@modifies he @*/ { + HE_t _he = memset(alloca(sizeof(*_he)), 0, sizeof(*_he)); rpmTagData flags; rpmTagData indices; rpmTagData names; @@ -875,6 +876,12 @@ if (!xx) return 0; + _he->tag = he->tag; + _he->t = RPM_INT32_TYPE; + _he->p.i32p = NULL; + _he->c = 1; + _he->freeData = -1; + xx = headerGetEntry(h, RPMTAG_TRIGGERINDEX, NULL, &indices, NULL); xx = headerGetEntry(h, RPMTAG_TRIGGERFLAGS, NULL, &flags, NULL); xx = headerGetEntry(h, RPMTAG_TRIGGERVERSION, NULL, &versions, NULL); @@ -882,11 +889,9 @@ he->t = RPM_STRING_ARRAY_TYPE; he->c = numScripts; - if (he->p == NULL) - goto exit; he->freeData = 1; - (*he->p).argv = conds = xmalloc(sizeof(*conds) * numScripts); + he->p.argv = conds = xmalloc(sizeof(*conds) * numScripts); for (i = 0; i < numScripts; i++) { chptr = xstrdup(""); @@ -896,14 +901,8 @@ item = xmalloc(strlen(names.argv[j]) + strlen(versions.argv[j]) + 20); if (flags.i32p[j] & RPMSENSE_SENSEMASK) { - HE_s _he_s = { .tag = 0, .t = 0, .p = NULL, .c = 0, .freeData = 0 }; - HE_t _he = &_he_s; buf[0] = '%', buf[1] = '\0'; - _he->tag = he->tag; - _he->t = RPM_INT32_TYPE; - _he->p = &flags; - _he->c = 1; - he->freeData = j;/* XXX HACK: he->freeData for element index. */ + _he->p.i32p = &flags.i32p[j]; flagsStr = depflagsFormat(_he, buf, 0); sprintf(item, "%s %s %s", names.argv[j], flagsStr, versions.argv[j]); flagsStr = _free(flagsStr); @@ -919,7 +918,6 @@ conds[i] = chptr; } -exit: names.ptr = headerFreeData(names.ptr, -1); versions.ptr = headerFreeData(versions.ptr, -1); s.ptr = headerFreeData(s.ptr, -1); @@ -951,11 +949,9 @@ he->t = RPM_STRING_ARRAY_TYPE; he->c = numScripts; - if (he->p == NULL) - goto exit; he->freeData = 1; - (*he->p).argv = conds = xmalloc(sizeof(*conds) * numScripts); + he->p.argv = conds = xmalloc(sizeof(*conds) * numScripts); for (i = 0; i < numScripts; i++) { for (j = 0; j < numNames; j++) { if (indices[j] != i) @@ -975,7 +971,6 @@ } } -exit: s = headerFreeData(s, -1); return 0; } @@ -1008,8 +1003,7 @@ int rc = 1; /* assume failure */ he->t = RPM_STRING_TYPE; - if (he->p) - (*he->p).ptr = NULL; + he->p.str = NULL; he->c = 0; he->freeData = 0; @@ -1060,12 +1054,9 @@ const char * s = /*@-unrecog@*/ dgettext(domain, msgid) /*@=unrecog@*/; if (s) { rc = 0; - if (he->p) { - (*he->p).str = xstrdup(s); - he->freeData = 1; - } else - he->freeData = 0; + he->p.str = xstrdup(s); he->c = 1; + he->freeData = 1; } } } @@ -1076,25 +1067,22 @@ if (!rc) return rc; - rc = headerGetEntry(h, he->tag, &he->t, he->p, &he->c); + rc = headerGetEntry(h, he->tag, &he->t, &he->p, &he->c); if (rc) { rc = 0; - if (he->p) { - (*he->p).str = xstrdup((*he->p).str); - (*he->p).str = xstrtolocale((*he->p).str); - he->freeData = 1; - } + he->p.str = xstrdup(he->p.str); + he->p.str = xstrtolocale(he->p.str); + he->freeData = 1; /*@-nullstate@*/ return rc; /*@=nullstate@*/ } he->t = RPM_STRING_TYPE; + he->p.str = NULL; he->c = 0; - if (he->p) { - (*he->p).ptr = NULL; - he->freeData = 0; - } + he->freeData = 0; + return 1; } @@ -1105,48 +1093,50 @@ /*@modifies he @*/ { rpmTagType t; - char **d, **d2, *dp; - int_32 c; + rpmTagData p; + rpmTagCount c; + const char ** argv; + char * te; int rc; - rc = headerGetEntry(h, he->tag, &t, &d, &c); - if (!rc || d == NULL || c == 0) { - if (he->p) - (*he->p).ptr = NULL; + rc = headerGetEntry(h, he->tag, &t, &p, &c); + if (!rc || p.ptr == NULL || c == 0) { + he->t = RPM_STRING_TYPE; + he->p.str = NULL; he->c = 0; he->freeData = 0; return 1; } if (t == RPM_STRING_TYPE) { - d = (char **)xstrdup((char *)d); - d = (char **)xstrtolocale((char *)d); + p.str = xstrdup(p.str); + p.str = xstrtolocale(p.str); he->freeData = 1; } else if (t == RPM_STRING_ARRAY_TYPE) { - int i, l = 0; + size_t l = 0; + int i; for (i = 0; i < c; i++) { - d[i] = xstrdup(d[i]); - d[i] = (char *)xstrtolocale(d[i]); -assert(d[i] != NULL); - l += strlen(d[i]) + 1; + p.argv[i] = xstrdup(p.argv[i]); + p.argv[i] = xstrtolocale(p.argv[i]); +assert(p.argv[i] != NULL); + l += strlen(p.argv[i]) + 1; } - d2 = xmalloc(c * sizeof(*d2) + l); - dp = (char *)(d2 + c); + argv = xmalloc(c * sizeof(*argv) + l); + te = (char *)&argv[c]; for (i = 0; i < c; i++) { - d2[i] = dp; - strcpy(dp, d[i]); - dp += strlen(dp) + 1; - d[i] = _free(d[i]); + argv[i] = te; + te = stpcpy(te, p.argv[i]); + te++; + p.argv[i] = _free(p.argv[i]); } - d = _free(d); - d = d2; + p.ptr = _free(p.ptr); + p.argv = argv; he->freeData = 1; } else he->freeData = 0; he->t = t; - if (he->p) - (*he->p).ptr = (void **)d; + he->p.ptr = p.ptr; he->c = c; return 0; } @@ -1222,14 +1212,10 @@ { he->tag = RPMTAG_DBINSTANCE; he->t = RPM_INT32_TYPE; - if (he->p) { - (*he->p).i32p = xcalloc(1, sizeof(*(*he->p).i32p)); - (*he->p).i32p[0] = headerGetInstance(h); - he->freeData = 1; - } else - he->freeData = 0; + he->p.i32p = xmalloc(sizeof(*he->p.i32p)); + he->p.i32p[0] = headerGetInstance(h); + he->freeData = 1; he->c = 1; - return 0; } /*@=globuse@*/ @@ -1279,7 +1265,7 @@ fileSystem, internalState @*/ { he->t = RPM_STRING_TYPE; - if (he->p) (*he->p).str = hGetNVRA(h); + he->p.str = hGetNVRA(h); he->c = 1; he->freeData = 1; return 0; @@ -1305,15 +1291,15 @@ */ static void rpmfiBuildFNames(Header h, rpmTag tagN, /*@null@*/ /*@out@*/ const char *** fnp, - /*@null@*/ /*@out@*/ int * fcp) + /*@null@*/ /*@out@*/ rpmTagCount * fcp) /*@modifies *fnp, *fcp @*/ { - const char ** baseNames; - const char ** dirNames; - int * dirIndexes; - int count; - const char ** fileNames; - int size; + rpmTagData baseNames; + rpmTagData dirNames; + rpmTagData dirIndexes; + rpmTagData fileNames; + rpmTagCount count; + size_t size; rpmTag dirNameTag = 0; rpmTag dirIndexesTag = 0; rpmTagType bnt, dnt; @@ -1337,29 +1323,28 @@ xx = headerGetEntry(h, dirNameTag, &dnt, &dirNames, NULL); xx = headerGetEntry(h, dirIndexesTag, NULL, &dirIndexes, &count); - size = sizeof(*fileNames) * count; + size = sizeof(*fileNames.argv) * count; for (i = 0; i < count; i++) { const char * dn = NULL; - (void) urlPath(dirNames[dirIndexes[i]], &dn); - size += strlen(baseNames[i]) + strlen(dn) + 1; + (void) urlPath(dirNames.argv[dirIndexes.i32p[i]], &dn); + size += strlen(baseNames.argv[i]) + strlen(dn) + 1; } - fileNames = xmalloc(size); - t = ((char *) fileNames) + (sizeof(*fileNames) * count); + fileNames.argv = xmalloc(size); + t = (char *)&fileNames.argv[count]; for (i = 0; i < count; i++) { const char * dn = NULL; - fileNames[i] = t; - (void) urlPath(dirNames[dirIndexes[i]], &dn); - t = stpcpy( stpcpy(t, dn), baseNames[i]); - *t++ = '\0'; + (void) urlPath(dirNames.argv[dirIndexes.i32p[i]], &dn); + fileNames.argv[i] = t; + t = stpcpy( stpcpy(t, dn), baseNames.argv[i]); } - baseNames = headerFreeData(baseNames, bnt); - dirNames = headerFreeData(dirNames, dnt); + baseNames.ptr = headerFreeData(baseNames.ptr, bnt); + dirNames.ptr = headerFreeData(dirNames.ptr, dnt); if (fnp) - *fnp = fileNames; + *fnp = fileNames.argv; else - fileNames = _free(fileNames); + fileNames.ptr = _free(fileNames.ptr); if (fcp) *fcp = count; } @@ -1373,7 +1358,7 @@ /*@modifies he @*/ { he->t = RPM_STRING_ARRAY_TYPE; - rpmfiBuildFNames(h, he->tag, (he->p ? &(*he->p).argv : NULL), &he->c); + rpmfiBuildFNames(h, he->tag, &he->p.argv, &he->c); he->freeData = 1; return 0; } @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/hdrinline.h ============================================================================ $ cvs diff -u -r1.20 -r1.21 hdrinline.h --- rpm/rpmdb/hdrinline.h 17 Oct 2007 20:04:53 -0000 1.20 +++ rpm/rpmdb/hdrinline.h 19 Oct 2007 00:36:47 -0000 1.21 @@ -264,7 +264,7 @@ /*@modifies *he @*/ { if (h == NULL) return 0; - return (h2hv(h)->hdrext) (h, he->tag, &he->t, he->p, &he->c); + return (h2hv(h)->hdrext) (h, he->tag, &he->t, &he->p, &he->c); } /** \ingroup header @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header.c ============================================================================ $ cvs diff -u -r1.91 -r1.92 header.c --- rpm/rpmdb/header.c 18 Oct 2007 20:31:17 -0000 1.91 +++ rpm/rpmdb/header.c 19 Oct 2007 00:36:47 -0000 1.92 @@ -1819,8 +1819,7 @@ const char * name = tagName(tag); headerSprintfExtension exts = (headerSprintfExtension)headerCompoundFormats; headerSprintfExtension ext; - hRET_t he_p = { .ptr = NULL }; - HE_t he = alloca(sizeof(*he)); + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); size_t nb = 0; int extNum; int rc; @@ -1828,12 +1827,7 @@ if ((sw = headerGetStats(h, 19)) != NULL) /* RPMTS_OP_HDRGET */ (void) rpmswEnter(sw, 0); - memset(&he_p, 0, sizeof(he_p)); - memset(he, 0, sizeof(*he)); he->tag = tag; -/*@-immediatetrans@*/ - he->p = (p ? &he_p : NULL); -/*@=immediatetrans@*/ /* Search extensions for specific tag override. */ for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST; @@ -1848,7 +1842,7 @@ if (ext && ext->name != NULL && ext->type == HEADER_EXT_TAG) rc = ext->u.tagFunction(h, he); else - rc = intGetEntry(h, he->tag, &he->t, he->p, &he->c, 0); + rc = intGetEntry(h, he->tag, &he->t, &he->p, &he->c, 0); if (!rc) goto exit; @@ -1865,21 +1859,21 @@ /*@fallthrough@*/ case RPM_CHAR_TYPE: case RPM_INT8_TYPE: - nb = he->c * sizeof(*he_p.i8p); + nb = he->c * sizeof(*he->p.i8p); break; case RPM_INT16_TYPE: - nb = he->c * sizeof(*he_p.i16p); + nb = he->c * sizeof(*he->p.i16p); break; case RPM_INT32_TYPE: - nb = he->c * sizeof(*he_p.i32p); + nb = he->c * sizeof(*he->p.i32p); break; case RPM_INT64_TYPE: - nb = he->c * sizeof(*he_p.i64p); + nb = he->c * sizeof(*he->p.i64p); break; case RPM_I18NSTRING_TYPE: case RPM_STRING_TYPE: - if (he_p.str) - nb = strlen(he_p.str) + 1; + if (he->p.str) + nb = strlen(he->p.str) + 1; else rc = 0; break; @@ -1889,15 +1883,15 @@ /* Allocate all returned storage (if not already). */ if (p && nb && !he->freeData) { - void * ptr = memcpy(xmalloc(nb), he_p.ptr, nb); - he_p.ptr = ptr; + void * ptr = memcpy(xmalloc(nb), he->p.ptr, nb); + he->p.ptr = ptr; } exit: if (type) *type = he->t; if (p) - p->ptr = he_p.ptr; + p->ptr = he->p.ptr; if (c) *c = he->c; @@ -2819,16 +2813,16 @@ break; case RPM_CHAR_TYPE: case RPM_INT8_TYPE: - ival = (*he->p).i8p[ix]; + ival = he->p.i8p[ix]; break; case RPM_INT16_TYPE: - ival = (*he->p).ui16p[ix]; /* XXX note unsigned. */ + ival = he->p.ui16p[ix]; /* XXX note unsigned. */ break; case RPM_INT32_TYPE: - ival = (*he->p).i32p[ix]; + ival = he->p.i32p[ix]; break; case RPM_INT64_TYPE: - ival = (*he->p).i64p[ix]; + ival = he->p.i64p[ix]; break; } @@ -2901,7 +2895,7 @@ /*@modifies formatPrefix @*/ { char * val; - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; if (he->t != RPM_INT32_TYPE) { val = xstrdup(_("(not a number)")); @@ -2967,7 +2961,7 @@ /*@modifies formatPrefix @*/ { char * result, * dst, * src, * buf; - rpmTagData data = { .ptr = (*he->p).ptr }; + rpmTagData data = { .ptr = he->p.ptr }; if (he->t == RPM_INT32_TYPE) { result = xmalloc(padding + 20); @@ -3397,25 +3391,16 @@ /*@modifies *typeptr, *data, *countptr, ec @*/ { if (!ec->avail) { - HE_s he_s; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); int xx; - he->tag = 0; -/*@-immediatetrans@*/ - he->t = 0; -/*@-type@*/ - he->p = &ec->data; -/*@=type@*/ - he->c = 0; -/*@=immediatetrans@*/ - he->freeData = 0; xx = fn(hsa->h, he); ec->type = he->t; + ec->data.ptr = he->p.ptr; ec->count = he->c; + ec->freeit = he->freeData; if (xx) return 1; - ec->freeit = he->freeData; ec->avail = 1; } @@ -3437,9 +3422,7 @@ static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element) /*@modifies hsa @*/ { - hRET_t he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); char * val = NULL; size_t need = 0; char * t, * te; @@ -3448,17 +3431,17 @@ memset(buf, 0, sizeof(buf)); if (tag->ext) { - if (getExtension(hsa, tag->ext, &he->t, he->p, &he->c, hsa->ec + tag->extNum)) + if (getExtension(hsa, tag->ext, &he->t, &he->p, &he->c, hsa->ec + tag->extNum)) { he->c = 1; he->t = RPM_STRING_TYPE; - he_p.str = "(none)"; + he->p.str = "(none)"; } } else { - if (!headerGetEntry(hsa->h, tag->tag, &he->t, he->p, &he->c)) { + if (!headerGetEntry(hsa->h, tag->tag, &he->t, &he->p, &he->c)) { he->c = 1; he->t = RPM_STRING_TYPE; - he_p.str = "(none)"; + he->p.str = "(none)"; } /* XXX this test is unnecessary, array sizes are checked */ @@ -3466,7 +3449,7 @@ default: if (element >= he->c) { /*@-modobserver -observertrans@*/ - he_p.ptr = headerFreeData(he_p.ptr, he->t); + he->p.ptr = headerFreeData(he->p.ptr, he->t); /*@=modobserver =observertrans@*/ hsa->errmsg = _("(index out of range)"); @@ -3485,42 +3468,42 @@ if (tag->arrayCount) { /*@-modobserver -observertrans@*/ if (he->freeData) { - he_p.ptr = headerFreeData(he_p.ptr, he->t); + he->p.ptr = headerFreeData(he->p.ptr, he->t); he->freeData = 0; } /*@=modobserver =observertrans@*/ countBuf = he->c; - he_p.i32p = &countBuf; + he->p.i32p = &countBuf; he->c = 1; he->t = RPM_INT32_TYPE; } (void) stpcpy( stpcpy(buf, "%"), tag->format); - if (he_p.ptr) + if (he->p.ptr) switch (he->t) { case RPM_STRING_ARRAY_TYPE: - { hRET_t _he_p = { .ptr = NULL }; - HE_s _he_s = { .tag = 0, .t = 0, .p = &_he_p, .c = 0, .freeData = 0 }; - HE_t _he = &_he_s; + { HE_t _he = memset(alloca(sizeof(*_he)), 0, sizeof(*_he)); _he->tag = he->tag; _he->t = RPM_STRING_TYPE; - (*_he->p).str = (*he->p).argv[element]; + _he->p.str = he->p.argv[element]; _he->c = 1; - _he->freeData = -1; - if (tag->fmt) + if (tag->fmt) { + /* XXX HACK: he->freeData for element index. */ + _he->freeData = -1; val = tag->fmt(_he, buf, tag->pad); + } if (val) { need = strlen(val); } else { - need = strlen((*_he->p).str) + tag->pad + 20; + need = strlen(_he->p.str) + tag->pad + 20; val = xmalloc(need+1); strcat(buf, "s"); /*@-formatconst@*/ - sprintf(val, buf, (*_he->p).str); + sprintf(val, buf, _he->p.str); /*@=formatconst@*/ } @@ -3536,11 +3519,11 @@ if (val) { need = strlen(val); } else { - need = strlen((*he->p).str) + tag->pad + 20; + need = strlen(he->p.str) + tag->pad + 20; val = xmalloc(need+1); strcat(buf, "s"); /*@-formatconst@*/ - sprintf(val, buf, (*he->p).str); + sprintf(val, buf, he->p.str); /*@=formatconst@*/ } break; @@ -3574,11 +3557,11 @@ need = strlen(val); } else { #ifdef NOTYET - val = memcpy(xmalloc(he->c), he_p.ptr, he->c); + val = memcpy(xmalloc(he->c), he->p.ptr, he->c); #else /* XXX format string not used */ static char hex[] = "0123456789abcdef"; - const char * s = he_p.str; + const char * s = he->p.str; need = 2 * he->c + tag->pad; val = t = xmalloc(need+1); @@ -3601,7 +3584,7 @@ /*@-modobserver -observertrans@*/ if (he->freeData) { - he_p.ptr = headerFreeData(he_p.ptr, he->t); + he->p.ptr = headerFreeData(he->p.ptr, he->t); he->freeData = 0; } /*@=modobserver =observertrans@*/ @@ -3628,9 +3611,7 @@ int element) /*@modifies hsa @*/ { - hRET_t he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); char numbuf[64]; /* XXX big enuf for "Tag_0x01234567" */ char * t, * te; int i, j; @@ -3883,9 +3864,7 @@ /*@requires maxSet(errmsg) >= 0 @*/ { headerSprintfArgs hsa = memset(alloca(sizeof(*hsa)), 0, sizeof(*hsa)); - hRET_t he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); sprintfToken nextfmt; sprintfTag tag; char * t, * te; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header.h ============================================================================ $ cvs diff -u -r1.45 -r1.46 header.h --- rpm/rpmdb/header.h 18 Oct 2007 20:31:17 -0000 1.45 +++ rpm/rpmdb/header.h 19 Oct 2007 00:36:47 -0000 1.46 @@ -176,11 +176,9 @@ #if !defined(SWIG) struct _HE_s { int_32 tag; -/*@null@*/ rpmTagType t; /*@null@*/ - hRET_t * p; -/*@null@*/ + rpmTagData p; rpmTagCount c; int freeData; }; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/pkgio.c ============================================================================ $ cvs diff -u -r1.20 -r1.21 pkgio.c --- rpm/rpmdb/pkgio.c 17 Oct 2007 20:04:53 -0000 1.20 +++ rpm/rpmdb/pkgio.c 19 Oct 2007 00:36:47 -0000 1.21 @@ -74,9 +74,7 @@ rpmRC rpmtsFindPubkey(rpmts ts, void * _dig) { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); pgpDig dig = (_dig ? _dig : rpmtsDig(ts)); const void * sig = pgpGetSig(dig); pgpDigParams sigp = pgpGetSignature(dig); @@ -160,10 +158,10 @@ ix = rpmdbGetIteratorFileNum(mi); /*@-moduncon -nullstate @*/ if (ix >= he->c - || b64decode(he_p.argv[ix], (void **) &ts->pkpkt, &ts->pkpktlen)) + || b64decode(he->p.argv[ix], (void **) &ts->pkpkt, &ts->pkpktlen)) ix = -1; /*@=moduncon =nullstate @*/ - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); break; } mi = rpmdbFreeIterator(mi); @@ -539,9 +537,7 @@ /*@modifies *ptr, *msg, fileSystem @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); Header * sighp = ptr; char buf[BUFSIZ]; int_32 block[4]; @@ -710,13 +706,13 @@ he->tag = RPMSIGTAG_SIZE; xx = hge(sigh, he, 0); if (xx) { - size_t datasize = *he_p.ui32p; + size_t datasize = he->p.ui32p[0]; rc = printSize(fd, sigSize, pad, datasize); if (rc != RPMRC_OK) (void) snprintf(buf, sizeof(buf), _("sigh sigSize(%d): BAD, fstat(2) failed\n"), sigSize); } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } exit: @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.c ============================================================================ $ cvs diff -u -r1.191 -r1.192 rpmdb.c --- rpm/rpmdb/rpmdb.c 17 Oct 2007 20:04:53 -0000 1.191 +++ rpm/rpmdb/rpmdb.c 19 Oct 2007 00:36:47 -0000 1.192 @@ -860,9 +860,7 @@ fileSystem, internalState @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * fn = NULL; int xx; @@ -884,12 +882,12 @@ he->tag = RPMTAG_INSTALLTID; if (hge(h, he, 0)) { struct utimbuf stamp; - stamp.actime = *he_p.i32p; - stamp.modtime = *he_p.i32p; + stamp.actime = he->p.i32p[0]; + stamp.modtime = he->p.i32p[0]; if (!Utime(fn, &stamp)) rpmlog(RPMLOG_DEBUG, " +++ %s\n", fn); } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); } } else { if (!Unlink(fn)) @@ -1408,9 +1406,7 @@ /*@requires maxSet(matches) >= 0 @*/ { HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); const char * dirName; const char * baseName; fingerPrintCache fpc; @@ -1511,13 +1507,13 @@ he->tag = RPMTAG_BASENAMES; xx = hge(h, he, 0); - baseNames = he_p.argv; + baseNames = he->p.argv; he->tag = RPMTAG_DIRNAMES; xx = hge(h, he, 0); - dirNames = he_p.argv; + dirNames = he->p.argv; he->tag = RPMTAG_DIRINDEXES; xx = hge(h, he, 0); - dirIndexes = he_p.ui32p; + dirIndexes = he->p.ui32p; do { fingerPrint fp2; @@ -2150,9 +2146,7 @@ /*@modifies mi->mi_re @*/ { HGE_t hge = (HGE_t) headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); char numbuf[32]; miRE mire; int ntags = 0; @@ -2181,8 +2175,8 @@ continue; } he->t = RPM_INT32_TYPE; + he->p.i32p = xcalloc(1, sizeof(*he->p.i32p)); he->c = 1; - he_p.i32p = xcalloc(he->c, sizeof(*he_p.i32p)); } anymatch = 0; /* no matches yet */ @@ -2190,32 +2184,45 @@ switch (he->t) { case RPM_CHAR_TYPE: case RPM_INT8_TYPE: - sprintf(numbuf, "%d", (int) *he_p.i8p); - rc = mireRegexec(mire, numbuf); - if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) - anymatch++; + for (j = 0; j < he->c; j++) { + sprintf(numbuf, "%d", he->p.i8p[j]); + rc = mireRegexec(mire, numbuf); + if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) + anymatch++; + } /*@switchbreak@*/ break; case RPM_INT16_TYPE: - sprintf(numbuf, "%d", (int) *he_p.i16p); - rc = mireRegexec(mire, numbuf); - if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) - anymatch++; + for (j = 0; j < he->c; j++) { + sprintf(numbuf, "%d", he->p.i16p[j]); + rc = mireRegexec(mire, numbuf); + if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) + anymatch++; + } /*@switchbreak@*/ break; case RPM_INT32_TYPE: - sprintf(numbuf, "%d", (int) *he_p.i32p); - rc = mireRegexec(mire, numbuf); - if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) - anymatch++; + for (j = 0; j < he->c; j++) { + sprintf(numbuf, "%d", he->p.i32p[j]); + rc = mireRegexec(mire, numbuf); + if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) + anymatch++; + } + /*@switchbreak@*/ break; + case RPM_INT64_TYPE: + for (j = 0; j < he->c; j++) { + sprintf(numbuf, "%lld", he->p.i64p[j]); + rc = mireRegexec(mire, numbuf); + if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) + anymatch++; + } /*@switchbreak@*/ break; - case RPM_I18NSTRING_TYPE: case RPM_STRING_TYPE: - rc = mireRegexec(mire, he_p.str); + rc = mireRegexec(mire, he->p.str); if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) anymatch++; /*@switchbreak@*/ break; case RPM_STRING_ARRAY_TYPE: for (j = 0; j < he->c; j++) { - rc = mireRegexec(mire, he_p.argv[j]); + rc = mireRegexec(mire, he->p.argv[j]); if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) { anymatch++; /*@innerbreak@*/ break; @@ -2223,13 +2230,14 @@ } /*@switchbreak@*/ break; case RPM_BIN_TYPE: - { const char * s = bin2hex(he_p.ptr, he->c); + { const char * s = bin2hex(he->p.ptr, he->c); rc = mireRegexec(mire, s); if ((!rc && !mire->notmatch) || (rc && mire->notmatch)) anymatch++; s = _free(s); } /*@switchbreak@*/ break; case RPM_NULL_TYPE: + case RPM_I18NSTRING_TYPE: default: /*@switchbreak@*/ break; } @@ -2241,7 +2249,7 @@ /*@innerbreak@*/ break; } - he_p.ptr = _free(he_p.ptr); + he->p.ptr = _free(he->p.ptr); if (anymatch) nmatches++; @@ -2779,9 +2787,7 @@ DBT * data = alloca(sizeof(*data)); union _dbswap mi_offset; HGE_t hge = (HGE_t)headerGetExtension; - rpmTagData he_p = { .ptr = NULL }; - HE_s he_s = { .tag = 0, .t = 0, .p = &he_p, .c = 0, .freeData = 0 }; - HE_t he = &he_s; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); Header h; sigset_t signalMask; int ret = 0; @@ -2818,8 +2824,8 @@ he->tag = RPMTAG_NVRA; xx = hge(h, he, 0); - rpmlog(RPMLOG_DEBUG, " --- h#%8u %s\n", hdrNum, he_p.str); - he_p.ptr = _free(he_p.ptr); + rpmlog(RPMLOG_DEBUG, " --- h#%8u %s\n", hdrNum, he->p.str); + he->p.ptr = _free(he->p.ptr); (void) blockSignals(db, &signalMask); @@ -2836,7 +2842,7 @@ dbi = NULL; he->tag = db->db_tagn[dbix]; he->t = 0; - he_p.ptr = NULL; + he->p.ptr = NULL; he->c = 0; switch (he->tag) { @@ -2889,13 +2895,13 @@ /* XXX Coerce strings into header argv return. */ if (he->t == RPM_STRING_TYPE) { - const char * s = he_p.str; + const char * s = he->p.str; char * t; - he_p.argv = xcalloc(1, sizeof(*he_p.argv)+strlen(s)+1); - he_p.argv[0] = t = (char *) &he_p.argv[1]; + he->c = 1; + he->p.argv = xcalloc(1, sizeof(*he->p.argv)+strlen(s)+1); + he->p.argv[0] = t = (char *) &he->p.argv[1]; (void) strcpy(t, s); s = _free(s); - he->c = 1; } printed = 0; @@ -2908,7 +2914,7 @@ switch (dbi->dbi_rpmtag) { case RPMTAG_FILEDIGESTS: /* Filter out empty file digests. */ - if (!(he_p.argv[i] && *he_p.argv[i] != '\0')) + if (!(he->p.argv[i] && *he->p.argv[i] != '\0')) /*@innercontinue@*/ continue; /*@switchbreak@*/ break; default: @@ -2923,26 +2929,26 @@ /*@switchbreak@*/ break; case RPM_CHAR_TYPE: case RPM_INT8_TYPE: - key->size = sizeof(*he_p.i8p); -/*@i@*/ key->data = he_p.i8p + i; + key->size = sizeof(*he->p.i8p); +/*@i@*/ key->data = he->p.i8p + i; /*@switchbreak@*/ break; case RPM_INT16_TYPE: - key->size = sizeof(*he_p.i16p); -/*@i@*/ key->data = he_p.i16p + i; + key->size = sizeof(*he->p.i16p); +/*@i@*/ key->data = he->p.i16p + i; /*@switchbreak@*/ break; case RPM_INT32_TYPE: - key->size = sizeof(*he_p.i32p); -/*@i@*/ key->data = he_p.i32p + i; + key->size = sizeof(*he->p.i32p); +/*@i@*/ key->data = he->p.i32p + i; /*@switchbreak@*/ break; case RPM_INT64_TYPE: - key->size = sizeof(*he_p.i64p); -/*@i@*/ key->data = he_p.i64p + i; + key->size = sizeof(*he->p.i64p); +/*@i@*/ key->data = he->p.i64p + i; /*@switchbreak@*/ break; case RPM_OPENPGP_TYPE: case RPM_ASN1_TYPE: case RPM_BIN_TYPE: key->size = he->c; -/*@i@*/ key->data = he_p.ptr; +/*@i@*/ key->data = he->p.ptr; he->c = 1; /* XXX break out of loop. */ /*@switchbreak@*/ break; case RPM_I18NSTRING_TYPE: /* XXX never occurs. */ @@ -2952,7 +2958,7 @@ case RPM_STRING_ARRAY_TYPE: /* Convert from hex to binary. */ if (dbi->dbi_rpmtag == RPMTAG_FILEDIGESTS) { - const char * s = he_p.argv[i]; + const char * s = he->p.argv[i]; size_t dlen = strlen(s); byte * t; assert((dlen & 1) == 0); @@ -2968,7 +2974,7 @@ if (dbi->dbi_rpmtag == RPMTAG_PUBKEYS) { int nbin; bin = xcalloc(1, 32); - nbin = pgpExtractPubkeyFingerprint(he_p.argv[i], bin); + nbin = pgpExtractPubkeyFingerprint(he->p.argv[i], bin); if (nbin <= 0) /*@innercontinue@*/ continue; key->data = bin; @@ -2977,8 +2983,8 @@ } /*@fallthrough@*/ default: -/*@i@*/ key->data = (void *) he_p.argv[i]; - key->size = strlen(he_p.argv[i]); +/*@i@*/ key->data = (void *) he->p.argv[i]; + key->size = strlen(he->p.argv[i]); stringvalued = 1; /*@switchbreak@*/ break; } @@ -3067,7 +3073,7 @@ he->tag = 0; he->t = 0; - he_p.ptr = _free(h