Eliminate dead NULL-assignments at scope-end in librpm, part I
authorPanu Matilainen <pmatilai@redhat.com>
Sat, 28 May 2011 19:12:37 +0000 (22:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Sat, 28 May 2011 19:24:20 +0000 (22:24 +0300)
- Remove NULL-assignments of local variables at the end of scope
  in header + tag- and format-extension code. While this
  NULL-on-free idiom of rpm codebase is harmless as such, these
  unnecessary NULL-assignments have the effect of hiding real problems
  in the amount of noise they generate on code analysis.
- While the changes are supposedly trivial, doing this in smaller parts
  to make bisecting easier in case a some regression slips through.

lib/formats.c
lib/header.c
lib/headerfmt.c
lib/headerutil.c
lib/tagexts.c

index 7ce4608..3c47463 100644 (file)
@@ -274,15 +274,14 @@ static char * deptypeFormat(rpmtd td, char * formatPrefix)
 static char * permsFormat(rpmtd td, char * formatPrefix)
 {
     char * val = NULL;
-    char * buf;
 
     if (rpmtdClass(td) != RPM_NUMERIC_CLASS) {
        val = xstrdup(_("(not a number)"));
     } else {
+       char *buf = rpmPermsString(rpmtdGetNumber(td));
        strcat(formatPrefix, "s");
-       buf = rpmPermsString(rpmtdGetNumber(td));
        rasprintf(&val, formatPrefix, buf);
-       buf = _free(buf);
+       free(buf);
     }
 
     return val;
@@ -522,7 +521,7 @@ static char * pgpsigFormat(rpmtd td, char * formatPrefix)
            t = stpcpy(t, tempstr);
            free(tempstr);
 
-           dig = pgpFreeDig(dig);
+           pgpFreeDig(dig);
        }
     }
 
@@ -623,7 +622,7 @@ static char * verifyFlags(rpmtd td, char * formatPrefix, const char *pad)
        strcat(formatPrefix, "s");
        char *buf = rpmVerifyString(rpmtdGetNumber(td), pad);
        rasprintf(&val, formatPrefix, buf);
-       buf = _free(buf);
+       free(buf);
     }
     return val;
 }
index e1c5f2c..a138c9f 100644 (file)
@@ -695,7 +695,7 @@ static void * doHeaderUnload(Header h, size_t * lengthPtr)
     return (void *) ei;
 
 errxit:
-    ei = _free(ei);
+    free(ei);
     return NULL;
 }
 
@@ -1022,7 +1022,7 @@ int headerWrite(FD_t fd, Header h, int magicp)
     nb = Fwrite(uh, sizeof(char), length, fd);
 
 exit:
-    uh = _free(uh);
+    free(uh);
     return (nb == length ? 0 : 1);
 }
 
index 4a41435..266488a 100644 (file)
@@ -137,7 +137,7 @@ freeFormat( sprintfToken format, int num)
            break;
        }
     }
-    format = _free(format);
+    free(format);
     return NULL;
 }
 
index d207fb8..a9f1221 100644 (file)
@@ -82,7 +82,7 @@ Header headerCopy(Header h)
        }
        rpmtdFreeData(&td);
     }
-    hi = headerFreeIterator(hi);
+    headerFreeIterator(hi);
 
     return headerReload(nh, RPMTAG_HEADERIMAGE);
 }
index aca3209..62a4e10 100644 (file)
@@ -145,8 +145,8 @@ static int filedepTag(Header h, rpmTag tagN, rpmtd td, headerGetFlags hgflags)
     rc = 1;
 
 exit:
-    fi = rpmfiFree(fi);
-    ds = rpmdsFree(ds);
+    rpmfiFree(fi);
+    rpmdsFree(ds);
     return rc;
 }
 
@@ -338,7 +338,7 @@ static int fileclassTag(Header h, rpmtd td, headerGetFlags hgflags)
     rc = 1;
 
 exit:
-    fi = rpmfiFree(fi);
+    rpmfiFree(fi);
     return rc; 
 }
 
@@ -431,7 +431,7 @@ static int i18nTag(Header h, rpmTag tag, rpmtd td, headerGetFlags hgflags)
            return 1;
     }
 
-    dstring = _free(dstring);
+    free(dstring);
 #endif
 
     rc = headerGet(h, tag, td, HEADERGET_ALLOC);