Eliminate bogus ferror() checks
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 18 May 2011 07:59:54 +0000 (10:59 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 18 May 2011 07:59:54 +0000 (10:59 +0300)
- fopen() returns NULL on errors, never an opened stream with error
  flag set. These are leftovers from past where rpmio fd was used
  instead of FILE and probably the checks were bogus even back then too.

build/files.c
build/pack.c
build/parseSpec.c
rpmbuild.c
rpmio/macro.c

index 8d7fb2e..0366443 100644 (file)
@@ -1733,7 +1733,7 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
            }
            fd = fopen(ffn, "r");
 
-           if (fd == NULL || ferror(fd)) {
+           if (fd == NULL) {
                rpmlog(RPMLOG_ERR, _("Could not open %%files file %s: %m\n"), ffn);
                return RPMRC_FAIL;
            }
index 8b06db2..ee4cfc9 100644 (file)
@@ -127,7 +127,7 @@ static StringBuf addFileToTagAux(rpmSpec spec,
     fn = rpmGetPath("%{_builddir}/%{?buildsubdir:%{buildsubdir}/}", file, NULL);
 
     f = fopen(fn, "r");
-    if (f == NULL || ferror(f)) {
+    if (f == NULL) {
        sb = freeStringBuf(sb);
        goto exit;
     }
index 8f2db6d..4df957f 100644 (file)
@@ -240,8 +240,7 @@ retry:
     /* Make sure the current file is open */
     if (ofi->fp == NULL) {
        ofi->fp = fopen(ofi->fileName, "r");
-       if (ofi->fp == NULL || ferror(ofi->fp)) {
-           /* XXX Fstrerror */
+       if (ofi->fp == NULL) {
            rpmlog(RPMLOG_ERR, _("Unable to open %s: %s\n"),
                     ofi->fileName, strerror(errno));
            return PART_ERROR;
index 856798a..dcdf3d4 100644 (file)
@@ -245,7 +245,7 @@ static int isSpecFile(const char * specfile)
     int checking;
 
     f = fopen(specfile, "r");
-    if (f == NULL || ferror(f)) {
+    if (f == NULL) {
        rpmlog(RPMLOG_ERR, _("Unable to open spec file %s: %s\n"),
                specfile, strerror(errno));
        return 0;
index d79ef18..8de886c 100644 (file)
@@ -1463,10 +1463,8 @@ rpmLoadMacroFile(rpmMacroContext mc, const char * fn)
     char *buf = xmalloc(blen);
     int rc = -1;
 
-    if (fd == NULL || ferror(fd)) {
-       if (fd) (void) fclose(fd);
+    if (fd == NULL)
        goto exit;
-    }
 
     /* XXX Assume new fangled macro expansion */
     max_macro_depth = 16;