Assume failure in rpmInstallSourcePackage()
authorPanu Matilainen <pmatilai@redhat.com>
Sat, 15 Nov 2008 16:44:00 +0000 (18:44 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 17 Nov 2008 12:20:21 +0000 (14:20 +0200)
- avoids bunch of redundant assignments

lib/psm.c

index 26cf0a1..7838278 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -249,18 +249,16 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
     if (h == NULL)
        goto exit;
 
-    rpmrc = RPMRC_OK;
+    rpmrc = RPMRC_FAIL; /* assume failure */
 
     isSource = headerIsSource(h);
 
     if (!isSource) {
        rpmlog(RPMLOG_ERR, _("source package expected, binary found\n"));
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
 
     if (rpmtsAddInstallElement(ts, h, NULL, 0, NULL)) {
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
 
@@ -268,13 +266,11 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
     h = headerFree(h);
 
     if (fi == NULL) {  /* XXX can't happen */
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
 
     fi->te = rpmtsElement(ts, 0);
     if (fi->te == NULL) {      /* XXX can't happen */
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
 
@@ -312,7 +308,6 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
     }
 
     if (rpmMkdirs(rpmtsRootDir(ts), "%{_topdir}:%{_sourcedir}:%{_specdir}")) {
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
     /* Build dnl/dil with {_sourcedir, _specdir} as values. */
@@ -344,7 +339,6 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
        free(_sourcedir);
     } else {
        rpmlog(RPMLOG_ERR, _("source package contains no .spec file\n"));
-       rpmrc = RPMRC_FAIL;
        goto exit;
     }
 
@@ -352,12 +346,11 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
     psm->goal = PSM_PKGINSTALL;
 
        /* FIX: psm->fi->dnl should be owned. */
-    rpmrc = rpmpsmStage(psm, PSM_PROCESS);
+    if (rpmpsmStage(psm, PSM_PROCESS) == RPMRC_OK)
+       rpmrc = RPMRC_OK;
 
     (void) rpmpsmStage(psm, PSM_FINI);
 
-    if (rpmrc) rpmrc = RPMRC_FAIL;
-
 exit:
     if (specFilePtr && specFile && rpmrc == RPMRC_OK)
        *specFilePtr = specFile;