Просмотр исходного кода

libdpkg: Make checksubprocerr less deep and a bit more readable

Move the PROCNOERR check before the reporting, and exit directly instead
in case of error.
Guillem Jover лет назад: 18
Родитель
Сommit
3ec776bb18
2 измененных файлов с 12 добавлено и 6 удалено
  1. 5 0
      ChangeLog
  2. 7 6
      lib/mlib.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-06-28  Guillem Jover  <guillem@debian.org>
+
+	* lib/mlib.c (checksubprocerr): Move the PROCNOERR check before
+	the reporting, and exit directly instead in case of error.
+
 2008-06-28  Guillem Jover  <guillem@debian.org>
 
 	* lib/ehandle.c (badusage): Use ohshit instead of its own error

+ 7 - 6
lib/mlib.c

@@ -123,12 +123,13 @@ int checksubprocerr(int status, const char *description, int flags) {
   int n;
   if (WIFEXITED(status)) {
     n= WEXITSTATUS(status); if (!n) return n;
-    if(!(flags & PROCNOERR)) {
-      if(flags & PROCWARN)
-        fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),description,n);
-      else
-        ohshit(_("subprocess %s returned error exit status %d"),description,n);
-    }
+    if (flags & PROCNOERR)
+      return -1;
+    if (flags & PROCWARN)
+      fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),
+              description, n);
+    else
+      ohshit(_("subprocess %s returned error exit status %d"), description, n);
   } else if (WIFSIGNALED(status)) {
     n= WTERMSIG(status); if (!n || ((flags & PROCPIPE) && n==SIGPIPE)) return 0;
     if (flags & PROCWARN)