chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
Blob Blame History Raw
From 2ec0832287bd1443ebf336f8a98293f30bfa2036 Mon Sep 17 00:00:00 2001
Message-Id: <2ec0832287bd1443ebf336f8a98293f30bfa2036.1554983205.git.pmatilai@redhat.com>
From: Panu Matilainen <pmatilai@redhat.com>
Date: Mon, 18 Mar 2019 15:24:54 +0200
Subject: [PATCH 1/3] Make rpmsign exit values more consistent with our other
 tools

rpmPkgSign*() return -1 for failure, which is not that helpful when
returned to shell and the way it was counted could easily wrap around
when signing multiple packages. Return number of failures similarly to
how rpm -q and frieds does, avoid overflows and xargs special value 255.
---
 rpmsign.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/rpmsign.c b/rpmsign.c
index ae86f666d..1a5cd59c2 100644
--- a/rpmsign.c
+++ b/rpmsign.c
@@ -134,7 +134,8 @@ static int doSign(poptContext optCon, struct rpmSignArgs *sargs)
     const char *arg;
     rc = 0;
     while ((arg = poptGetArg(optCon)) != NULL) {
-	rc += rpmPkgSign(arg, sargs);
+	if (rpmPkgSign(arg, sargs) < 0)
+	    rc++;
     }
 
 exit:
@@ -175,7 +176,8 @@ int main(int argc, char *argv[])
     case MODE_DELSIGN:
 	ec = 0;
 	while ((arg = poptGetArg(optCon)) != NULL) {
-	    ec += rpmPkgDelSign(arg, &sargs);
+	    if (rpmPkgDelSign(arg, &sargs) < 0)
+		ec++;
 	}
 	break;
     case MODE_NONE:
@@ -188,5 +190,5 @@ int main(int argc, char *argv[])
 
 exit:
     rpmcliFini(optCon);
-    return ec;
+    return RETVAL(ec);
 }
-- 
2.20.1