- fix type-punning errors using temporary variables in rpmhandler + genpkglist
authorpmatilai <pmatilai>
Wed, 10 May 2006 15:39:15 +0000 (15:39 +0000)
committerpmatilai <pmatilai>
Wed, 10 May 2006 15:39:15 +0000 (15:39 +0000)
- fix "might be used uninitialized" complaint in apt-shell

apt-pkg/rpm/rpmhandler.cc
cmdline/apt-shell.cc
tools/genpkglist.cc

index 58b9b43..42d708d 100644 (file)
@@ -45,9 +45,11 @@ string RPMHandler::Epoch()
 {
    char str[512];
    int_32 count, type, *epoch;
+   void *val;
    assert(HeaderP != NULL);
    int rc = headerGetEntry(HeaderP, RPMTAG_EPOCH,
-                          &type, (void**)&epoch, &count);
+                          &type, &val, &count);
+   epoch = (int_32*)val;
    if (rc == 1 && count > 0) {
       snprintf(str, sizeof(str), "%i", epoch[0]);
       return str;
@@ -59,19 +61,23 @@ string RPMHandler::Epoch()
 unsigned long RPMHandler::GetITag(rpmTag Tag)
 {
    int_32 count, type, *num;
+   void *val;
    assert(HeaderP != NULL);
    int rc = headerGetEntry(HeaderP, Tag,
-                          &type, (void**)&num, &count);
+                          &type, (void**)&val, &count);
+   num = (int_32*)val;
    return rc?num[0]:0;
 }
 
 string RPMHandler::GetSTag(rpmTag Tag)
 {
    char *str;
+   void *val;
    int_32 count, type;
    assert(HeaderP != NULL);
    int rc = headerGetEntry(HeaderP, Tag,
-                          &type, (void**)&str, &count);
+                          &type, (void**)&val, &count);
+   str = (char *)val;
    return string(rc?str:"");
 }
 
@@ -94,9 +100,11 @@ bool RPMHandler::HasFile(const char *File)
    if (*File == '\0')
       return false;
    char **names = NULL;
+   void *val;
    int_32 count = 0;
    rpmHeaderGetEntry(HeaderP, RPMTAG_OLDFILENAMES,
-                     NULL, (void **) &names, &count);
+                     NULL, (void **) &val, &count);
+   names = (char **)val;
    while (count--)
    {
       char *name = names[count];
@@ -220,65 +228,71 @@ bool RPMHandler::Depends(unsigned int Type, vector<Dependency*> &Deps)
    char **verl = NULL;
    int *flagl = NULL;
    int res, type, count;
+   void *nameval = NULL;
+   void *verval = NULL;
+   void *flagval = NULL;
 
    switch (Type)
    {
    case pkgCache::Dep::Depends:
       res = headerGetEntry(HeaderP, RPMTAG_REQUIRENAME, &type,
-                           (void **)&namel, &count);
+                           (void **)&nameval, &count);
       if (res != 1)
           return true;
       res = headerGetEntry(HeaderP, RPMTAG_REQUIREVERSION, &type,
-                           (void **)&verl, &count);
+                           (void **)&verval, &count);
       res = headerGetEntry(HeaderP, RPMTAG_REQUIREFLAGS, &type,
-                           (void **)&flagl, &count);
+                           (void **)&flagval, &count);
       break;
 
    case pkgCache::Dep::Obsoletes:
       res = headerGetEntry(HeaderP, RPMTAG_OBSOLETENAME, &type,
-                           (void **)&namel, &count);
+                           (void **)&nameval, &count);
       if (res != 1)
           return true;
       res = headerGetEntry(HeaderP, RPMTAG_OBSOLETEVERSION, &type,
-                           (void **)&verl, &count);
+                           (void **)&verval, &count);
       res = headerGetEntry(HeaderP, RPMTAG_OBSOLETEFLAGS, &type,
-                           (void **)&flagl, &count);
+                           (void **)&flagval, &count);
       break;
    case pkgCache::Dep::Conflicts:
       res = headerGetEntry(HeaderP, RPMTAG_CONFLICTNAME, &type,
-                           (void **)&namel, &count);
+                           (void **)&nameval, &count);
       if (res != 1)
           return true;
       res = headerGetEntry(HeaderP, RPMTAG_CONFLICTVERSION, &type,
-                           (void **)&verl, &count);
+                           (void **)&verval, &count);
       res = headerGetEntry(HeaderP, RPMTAG_CONFLICTFLAGS, &type,
-                           (void **)&flagl, &count);
+                           (void **)&flagval, &count);
       break;
 #if RPM_VERSION >= 0x040403
    case pkgCache::Dep::Suggests:
       res = headerGetEntry(HeaderP, RPMTAG_SUGGESTSNAME, &type,
-                           (void **)&namel, &count);
+                           (void **)&nameval, &count);
       if (res != 1)
           return true; 
       res = headerGetEntry(HeaderP, RPMTAG_SUGGESTSVERSION, &type,
-                           (void **)&verl, &count);
+                           (void **)&verval, &count);
       res = headerGetEntry(HeaderP, RPMTAG_SUGGESTSFLAGS, &type,
-                           (void **)&flagl, &count);
+                           (void **)&flagval, &count);
       break;
 #if 0 // Enhances is not even known to apt, sigh...
    case pkgCache::Dep::Enhances:
       res = headerGetEntry(HeaderP, RPMTAG_ENHANCESNAME, &type,
-                           (void **)&namel, &count);
+                           (void **)&nameval, &count);
       if (res != 1)
           return true;
       res = headerGetEntry(HeaderP, RPMTAG_ENHANCESVERSION, &type,
-                           (void **)&verl, &count);
+                           (void **)&verval, &count);
       res = headerGetEntry(HeaderP, RPMTAG_ENHANCESFLAGS, &type,
-                           (void **)&flagl, &count);
+                           (void **)&flagval, &count);
       break;
 #endif
 #endif
    }
+   namel = (char**)nameval;
+   verl = (char**)verval;
+   flagl = (int*)flagval;
 
    unsigned int Op = 0;
    bool DepMode = false;
@@ -336,15 +350,19 @@ bool RPMHandler::Provides(vector<Dependency*> &Provs)
    int type, count;
    char **namel = NULL;
    char **verl = NULL;
+   void *nameval = NULL;
+   void *verval = NULL;
    int res;
 
    res = headerGetEntry(HeaderP, RPMTAG_PROVIDENAME, &type,
-                        (void **)&namel, &count);
+                        (void **)&nameval, &count);
    if (res != 1)
        return true;
+   namel = (char **)nameval;
 
    res = headerGetEntry(HeaderP, RPMTAG_PROVIDEVERSION, &type,
-                        (void **)&verl, NULL);
+                        (void **)&verval, NULL);
+   verl = (char **)verval;
 
    if (res != 1)
       verl = NULL;
@@ -367,10 +385,12 @@ bool RPMHandler::Provides(vector<Dependency*> &Provs)
 bool RPMHandler::FileProvides(vector<string> &FileProvs)
 {
    const char **names = NULL;
+   void *val = NULL;
    int_32 count = 0;
    bool ret = true;
    rpmHeaderGetEntry(HeaderP, RPMTAG_OLDFILENAMES,
-                     NULL, (void **) &names, &count);
+                     NULL, (void **) &val, &count);
+   names = (const char **)val;
    while (count--) {
       FileProvs.push_back(names[count]);
    }
index f7c829b..cf1306b 100644 (file)
@@ -3511,7 +3511,7 @@ bool DoList(CommandLine &CmdL)
    const char *PkgName;
    int Matches[Cache->Head().PackageCount];
    unsigned int NumMatches = 0;
-   size_t Len, NameMaxLen = 0, VerMaxLen = 0;
+   size_t Len = 0, NameMaxLen = 0, VerMaxLen = 0;
    bool Matched;
    for (unsigned int J = 0; J < Cache->Head().PackageCount; J++)
    {
index 7e2f9c7..220a5d1 100644 (file)
@@ -104,6 +104,7 @@ static void copyStrippedFileList(Header header, Header newHeader)
    int count1, count2, count3;
    char **dirnames = NULL, **basenames = NULL;
    int_32 *dirindexes = NULL;
+   void *dirnameval = NULL, *basenameval = NULL, *dirindexval = NULL;
    char **dnames, **bnames;
    int_32 *dindexes;
    int res1, res2, res3;
@@ -111,11 +112,14 @@ static void copyStrippedFileList(Header header, Header newHeader)
 #define FREE(a) if (a) free(a);
    
    res1 = headerGetEntry(header, RPMTAG_DIRNAMES, &type1, 
-                        (void**)&dirnames, &count1);
+                        (void**)&dirnameval, &count1);
    res2 = headerGetEntry(header, RPMTAG_BASENAMES, &type2, 
-                        (void**)&basenames, &count2);
+                        (void**)&basenameval, &count2);
    res3 = headerGetEntry(header, RPMTAG_DIRINDEXES, &type3, 
-                        (void**)&dirindexes, &count3);
+                        (void**)&dirindexval, &count3);
+   dirnames = (char **)dirnameval;
+   basenames = (char **)basenameval;
+   dirindexes = (int_32 *)dirindexval;
    
    if (res1 != 1 || res2 != 1 || res3 != 1) {
       FREE(dirnames);
@@ -254,14 +258,19 @@ bool copyFields(Header h, Header newHeader,
       int type1, type2, type3;
       int count1, count2, count3;
       char **dnames, **bnames, **dindexes;
+      void *dnameval, *bnameval, *dindexval;
       int res;
    
       res = headerGetEntry(h, RPMTAG_DIRNAMES, &type1, 
-                          (void**)&dnames, &count1);
+                          (void**)&dnameval, &count1);
       res = headerGetEntry(h, RPMTAG_BASENAMES, &type2, 
-                          (void**)&bnames, &count2);
+                          (void**)&bnameval, &count2);
       res = headerGetEntry(h, RPMTAG_DIRINDEXES, &type3, 
-                          (void**)&dindexes, &count3);
+                          (void**)&dindexval, &count3);
+
+      dnames = (char **)dnameval;
+      bnames = (char **)bnameval;
+      dindexes = (char **)dindexval;
 
       if (res == 1) {
         headerAddEntry(newHeader, RPMTAG_DIRNAMES, type1, dnames, count1);
@@ -275,14 +284,17 @@ bool copyFields(Header h, Header newHeader,
    // update index of srpms
    if (idxfile) {
       int_32 type, count;
-      char *srpm;
-      char *name;
+      char *srpm, *name;
+      void *srpmval, *nameval;
       int res;
       
       res = headerGetEntry(h, RPMTAG_NAME, &type, 
-                          (void**)&name, &count);
+                          (void**)&nameval, &count);
       res = headerGetEntry(h, RPMTAG_SOURCERPM, &type, 
-                          (void**)&srpm, &count);
+                          (void**)&srpmval, &count);
+      name = (char *)nameval;
+      srpm = (char *)srpmval;
+
       if (res == 1) {
         fprintf(idxfile, "%s %s\n", srpm, name);
       }