Use rpm_count_t everywhere for header data count
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Dec 2007 16:16:39 +0000 (18:16 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Dec 2007 16:16:39 +0000 (18:16 +0200)
- typedef'ed as uint32_t as that's the key size limit imposed by BDB,
  relevant for RPM_BIN_TYPE
- easy to change to whatever later on as it's now consistent everywhere
- explicit casts where needed to avoid new warnings from signedness

15 files changed:
build/files.c
build/parsePreamble.c
build/parseScript.c
build/rpmfc.c
lib/formats.c
lib/legacy.c
lib/package.c
lib/psm.c
lib/rpmfi.c
lib/rpmfi.h
lib/rpmts.c
lib/rpmts.h
lib/signature.c
rpmdb/header.c
rpmdb/header.h

index 1e9b1d0..54c6646 100644 (file)
@@ -2071,7 +2071,7 @@ void initSourceHeader(rpmSpec spec)
     if (spec->BANames && spec->BACount > 0) {
        (void) headerAddEntry(spec->sourceHeader, RPMTAG_BUILDARCHS,
                       RPM_STRING_ARRAY_TYPE,
-                      spec->BANames, spec->BACount);
+                      spec->BANames, (rpm_count_t) spec->BACount);
     }
 }
 
index 71da7ab..458da39 100644 (file)
@@ -58,7 +58,8 @@ static void addOrAppendListEntry(Header h, int32_t tag, char * line)
 
     xx = poptParseArgvString(line, &argc, &argv);
     if (argc)
-       xx = headerAddOrAppendEntry(h, tag, RPM_STRING_ARRAY_TYPE, argv, argc);
+       xx = headerAddOrAppendEntry(h, tag, RPM_STRING_ARRAY_TYPE, 
+                                   argv, (rpm_count_t) argc);
     argv = _free(argv);
 }
 
index 54d85f5..e4c36f6 100644 (file)
@@ -303,12 +303,12 @@ int parseScript(rpmSpec spec, int parsePart)
     } else {
        if (progArgc == 1)
            (void) headerAddEntry(pkg->header, progtag, RPM_STRING_TYPE,
-                       *progArgv, progArgc);
+                       *progArgv, (rpm_count_t) progArgc);
        else {
            (void) rpmlibNeedsFeature(pkg->header,
                        "ScriptletInterpreterArgs", "4.0.3-1");
            (void) headerAddEntry(pkg->header, progtag, RPM_STRING_ARRAY_TYPE,
-                       progArgv, progArgc);
+                       progArgv, (rpm_count_t) progArgc);
        }
 
        if (*p != '\0')
index 5eb1b21..b93bf3e 100644 (file)
@@ -1527,7 +1527,7 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
     const char * N;
     const char * EVR;
     int genConfigDeps;
-    int c;
+    rpm_count_t c;
     int rc = 0;
     int xx;
 
index 38d893d..7333368 100644 (file)
@@ -637,7 +637,7 @@ static int triggercondsTag(Header h, rpmTagType * type,
            item = xmalloc(strlen(names[j]) + strlen(versions[j]) + 20);
            if (flags[j] & RPMSENSE_SENSEMASK) {
                buf[0] = '%', buf[1] = '\0';
-               flagsStr = depflagsFormat(RPM_INT32_TYPE, flags, buf, 0, j);
+               flagsStr = depflagsFormat(RPM_INT32_TYPE, flags, buf, 0, 0);
                sprintf(item, "%s %s %s", names[j], flagsStr, versions[j]);
                flagsStr = _free(flagsStr);
            } else {
index fde9b4b..4241282 100644 (file)
@@ -102,7 +102,7 @@ exit:
        xx = hae(h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE,
                        baseNames, count);
        xx = hae(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE,
-                       dirNames, dirIndex + 1);
+                       dirNames, (rpm_count_t) dirIndex + 1);
     }
 
     fileNames = hfd(fileNames, fnt);
index d2884c8..796b0ae 100644 (file)
@@ -486,7 +486,7 @@ verifyinfo_exit:
     dig->nbytes = 0;
 
     sig = memcpy(xmalloc(siglen), dataStart + info->offset, siglen);
-    (void) rpmtsSetSig(ts, info->tag, info->type, sig, info->count);
+    (void) rpmtsSetSig(ts, info->tag, info->type, sig, (size_t) info->count);
 
     switch (info->tag) {
     case RPMTAG_RSAHEADER:
index b2fd2a3..32e9205 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -475,7 +475,7 @@ static pid_t psmWait(rpmpsm psm)
  * Run internal Lua script.
  */
 static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag,
-                  int progArgc, const char **progArgv,
+                  unsigned int progArgc, const char **progArgv,
                   const char *script, int arg1, int arg2)
 {
     const rpmts ts = psm->ts;
@@ -572,7 +572,7 @@ static const char * ldconfig_path = "/sbin/ldconfig";
  * @return             0 on success
  */
 static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag,
-               int progArgc, const char ** progArgv,
+               unsigned int progArgc, const char ** progArgv,
                const char * script, int arg1, int arg2)
 {
     const rpmts ts = psm->ts;
@@ -1701,7 +1701,7 @@ assert(psm->mi == NULL);
 
        if (psm->goal == PSM_PKGINSTALL) {
            int32_t installTime = (int32_t) time(NULL);
-           int fc = rpmfiFC(fi);
+           rpm_count_t fc = rpmfiFC(fi);
 
            if (fi->h == NULL) break;   /* XXX can't happen */
            if (fi->fstates != NULL && fc > 0)
index 9b386c1..234f2fd 100644 (file)
@@ -45,12 +45,12 @@ fprintf(stderr, "--> fi %p ++ %d %s\n", fi, fi->nrefs, msg);
     return fi;
 }
 
-int rpmfiFC(rpmfi fi)
+rpm_count_t rpmfiFC(rpmfi fi)
 {
     return (fi != NULL ? fi->fc : 0);
 }
 
-int rpmfiDC(rpmfi fi)
+rpm_count_t rpmfiDC(rpmfi fi)
 {
     return (fi != NULL ? fi->dc : 0);
 }
@@ -768,7 +768,7 @@ assert(p != NULL);
     /* Add relocation values to the header */
     if (numValid) {
        const char ** actualRelocations;
-       int numActual;
+       rpm_count_t numActual;
 
        actualRelocations = xmalloc(numValid * sizeof(*actualRelocations));
        numActual = 0;
index 0107962..ebce59f 100644 (file)
@@ -108,7 +108,7 @@ rpmfi rpmfiLink (rpmfi fi, const char * msg);
  * @param fi           file info set
  * @return             current file count
  */
-int rpmfiFC(rpmfi fi);
+rpm_count_t rpmfiFC(rpmfi fi);
 
 /** \ingroup rpmfi
  * Return current file index from file info set.
@@ -130,7 +130,7 @@ int rpmfiSetFX(rpmfi fi, int fx);
  * @param fi           file info set
  * @return             current directory count
  */
-int rpmfiDC(rpmfi fi);
+rpm_count_t rpmfiDC(rpmfi fi);
 
 /** \ingroup rpmfi
  * Return current directory index from file info set.
index 3014674..88c5f9a 100644 (file)
@@ -1167,16 +1167,16 @@ const void * rpmtsSig(const rpmts ts)
     return sig;
 }
 
-int32_t rpmtsSiglen(const rpmts ts)
+size_t rpmtsSiglen(const rpmts ts)
 {
-    int32_t siglen = 0;
+    size_t siglen = 0;
     if (ts != NULL)
        siglen = ts->siglen;
     return siglen;
 }
 
 int rpmtsSetSig(rpmts ts,
-               int32_t sigtag, int32_t sigtype, const void * sig, int32_t siglen)
+               int32_t sigtag, int32_t sigtype, const void * sig, size_t siglen)
 {
     if (ts != NULL) {
        if (ts->sig && ts->sigtype)
index 517d674..881c5c8 100644 (file)
@@ -541,7 +541,7 @@ extern const void * rpmtsSig(const rpmts ts);
  * @param ts           transaction set
  * @return             signature tag data length
  */
-int32_t rpmtsSiglen(const rpmts ts);
+size_t rpmtsSiglen(const rpmts ts);
 
 /** \ingroup rpmts
  * Set signature tag info, i.e. from header.
@@ -554,7 +554,7 @@ int32_t rpmtsSiglen(const rpmts ts);
  */
 int rpmtsSetSig(rpmts ts,
                int32_t sigtag, int32_t sigtype,
-               const void * sig, int32_t siglen);
+               const void * sig, size_t siglen);
 
 /** \ingroup rpmts
  * Get OpenPGP packet parameters, i.e. signature/pubkey constants.
index fa72311..977e78c 100644 (file)
@@ -473,7 +473,7 @@ static int makePGPSignature(const char * file, int32_t * sigTagp,
  * @return             0 on success, 1 on failure
  */
 static int makeGPGSignature(const char * file, int32_t * sigTagp,
-               uint8_t ** pktp, int32_t * pktlenp,
+               uint8_t ** pktp, size_t * pktlenp,
                const char * passPhrase)
 {
     char * sigfile = alloca(strlen(file)+sizeof(".sig"));
@@ -613,7 +613,7 @@ static int makeHDRSignature(Header sigh, const char * file, int32_t sigTag,
     Header h = NULL;
     FD_t fd = NULL;
     uint8_t * pkt;
-    int32_t pktlen;
+    rpm_count_t pktlen;
     const char * fn = NULL;
     const char * SHA1 = NULL;
     int ret = -1;      /* assume failure. */
@@ -715,7 +715,7 @@ int rpmAddSignature(Header sigh, const char * file, int32_t sigTag,
 {
     struct stat st;
     uint8_t * pkt;
-    int32_t pktlen;
+    rpm_count_t pktlen;
     int ret = -1;      /* assume failure. */
 
     switch (sigTag) {
index 9d100db..3525102 100644 (file)
@@ -1759,7 +1759,7 @@ int _headerAddI18NString(Header h, int32_t tag, const char * string,
     const char ** strArray;
     int length;
     int ghosts;
-    int i, langNum;
+    rpm_count_t i, langNum;
     char * buf;
 
     table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
@@ -1770,7 +1770,7 @@ int _headerAddI18NString(Header h, int32_t tag, const char * string,
 
     if (!table && !entry) {
        const char * charArray[2];
-       int count = 0;
+       rpm_count_t count = 0;
        if (!lang || (lang[0] == 'C' && lang[1] == '\0')) {
            charArray[count++] = "C";
        } else {
@@ -2735,7 +2735,8 @@ static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
        strarray = (const char **)data;
 
        if (tag->fmt)
-           val = tag->fmt(RPM_STRING_TYPE, strarray[element], buf, tag->pad, element);
+           val = tag->fmt(RPM_STRING_TYPE, strarray[element], buf, tag->pad, 
+                          (rpm_count_t) element);
 
        if (val) {
            need = strlen(val);
@@ -2781,7 +2782,8 @@ static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
        }
 
        if (tag->fmt)
-           val = tag->fmt(RPM_INT32_TYPE, &intVal, buf, tag->pad, element);
+           val = tag->fmt(RPM_INT32_TYPE, &intVal, buf, tag->pad, 
+                          (rpm_count_t) element);
 
        if (val) {
            need = strlen(val);
@@ -2796,7 +2798,7 @@ static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
     case RPM_BIN_TYPE:
        /* XXX HACK ALERT: element field abused as no. bytes of binary data. */
        if (tag->fmt)
-           val = tag->fmt(RPM_BIN_TYPE, data, buf, tag->pad, count);
+           val = tag->fmt(RPM_BIN_TYPE, data, buf, tag->pad, (rpm_count_t) count);
 
        if (val) {
            need = strlen(val);
index 37114ba..dd59930 100644 (file)
@@ -143,7 +143,7 @@ enum headerSprintfExtensionType {
  */
 typedef char * (*headerTagFormatFunction)(int32_t type,
                                const void * data, char * formatPrefix,
-                               int padding, int element);
+                               int padding, rpm_count_t element);
 
 /** \ingroup header
  * HEADER_EXT_FORMAT format function prototype.