Prechádzať zdrojové kódy

dpkg-divert: Return from a command function instead of directly exiting

This makes it possible to perform any necessary normal cleanup before
exiting, and unifies the usage with all other command functions.
Guillem Jover 10 rokov pred
rodič
commit
97a8d2695c
2 zmenil súbory, kde vykonal 4 pridanie a 2 odobranie
  1. 2 0
      debian/changelog
  2. 2 2
      src/divertcmd.c

+ 2 - 0
debian/changelog

@@ -11,6 +11,8 @@ dpkg (1.18.4) UNRELEASED; urgency=low
   * Fix memory leaks in «dpkg --verify» and dpkg infodb format upgrade logic.
   * Fix memory leaks in «dpkg --verify» and dpkg infodb format upgrade logic.
   * Merge all update-alternatives action handling into a single if-else-if
   * Merge all update-alternatives action handling into a single if-else-if
     block, to unify the code an allow a future switch into a shared library.
     block, to unify the code an allow a future switch into a shared library.
+  * Perform any necessary cleanups on normal exit from dpkg-divert --add and
+    --remove commands.
   * Build system:
   * Build system:
     - Set PERL5LIB globally for the test suite to the local modules directory,
     - Set PERL5LIB globally for the test suite to the local modules directory,
       to avoid using the system modules. Regression introduced in dpkg 1.17.8.
       to avoid using the system modules. Regression introduced in dpkg 1.17.8.

+ 2 - 2
src/divertcmd.c

@@ -464,7 +464,7 @@ diversion_add(const char *const *argv)
 			if (opt_verbose > 0)
 			if (opt_verbose > 0)
 				printf(_("Leaving '%s'\n"),
 				printf(_("Leaving '%s'\n"),
 				       diversion_describe(fnn_from->divert));
 				       diversion_describe(fnn_from->divert));
-			exit(0);
+			return 0;
 		}
 		}
 
 
 		ohshit(_("'%s' clashes with '%s'"),
 		ohshit(_("'%s' clashes with '%s'"),
@@ -595,7 +595,7 @@ diversion_remove(const char *const *argv)
 		if (opt_verbose > 0)
 		if (opt_verbose > 0)
 			printf(_("Ignoring request to remove shared diversion '%s'.\n"),
 			printf(_("Ignoring request to remove shared diversion '%s'.\n"),
 			       diversion_describe(contest));
 			       diversion_describe(contest));
-		exit(0);
+		return 0;
 	}
 	}
 
 
 	if (opt_verbose > 0)
 	if (opt_verbose > 0)