From 2ecee0c334d95fafb9ad423e998482cd1209d0e4 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 5 May 2008 11:00:45 +0300 Subject: [PATCH] Make parseFiles() return PART_ERROR on failure - streamline exits by assuming failure --- build/parseFiles.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/build/parseFiles.c b/build/parseFiles.c index e685b44..b043668 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -21,7 +21,7 @@ int parseFiles(rpmSpec spec) { - int nextPart; + int nextPart, res = PART_ERROR; Package pkg; int rc, argc; int arg; @@ -35,7 +35,6 @@ int parseFiles(rpmSpec spec) if ((rc = poptParseArgvString(spec->line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%files: %s\n"), spec->lineNum, poptStrerror(rc)); - rc = RPMRC_FAIL; goto exit; } @@ -51,7 +50,6 @@ int parseFiles(rpmSpec spec) spec->lineNum, poptBadOption(optCon, POPT_BADOPTION_NOALIAS), spec->line); - rc = RPMRC_FAIL; goto exit; } @@ -62,7 +60,6 @@ int parseFiles(rpmSpec spec) rpmlog(RPMLOG_ERR, _("line %d: Too many names: %s\n"), spec->lineNum, spec->line); - rc = RPMRC_FAIL; goto exit; } } @@ -70,14 +67,12 @@ int parseFiles(rpmSpec spec) if (lookupPackage(spec, name, flag, &pkg)) { rpmlog(RPMLOG_ERR, _("line %d: Package does not exist: %s\n"), spec->lineNum, spec->line); - rc = RPMRC_FAIL; goto exit; } if (pkg->fileList != NULL) { rpmlog(RPMLOG_ERR, _("line %d: Second %%files list\n"), spec->lineNum); - rc = RPMRC_FAIL; goto exit; } @@ -90,24 +85,24 @@ int parseFiles(rpmSpec spec) if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { nextPart = PART_NONE; + } else if (rc < 0) { + goto exit; } else { - if (rc) - goto exit; while (! (nextPart = isPart(spec->line))) { appendStringBuf(pkg->fileList, spec->line); if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { nextPart = PART_NONE; break; - } - if (rc) + } else if (rc < 0) { goto exit; + } } } - rc = nextPart; + res = nextPart; exit: argv = _free(argv); optCon = poptFreeContext(optCon); - return rc; + return res; } -- 2.7.4