Explorar o código

dpkg-trigger: Move exit from command function to its call site

This makes it explicit that the code flow stops at the call site instead
of requiring the reader to know that this specific function never returns.
Guillem Jover %!s(int64=10) %!d(string=hai) anos
pai
achega
df5deb4f20
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      src/trigcmd.c

+ 5 - 5
src/trigcmd.c

@@ -168,7 +168,7 @@ static const struct trigdefmeths tdm_add = {
 	.trig_end = tdm_add_trig_end,
 };
 
-static void DPKG_ATTR_NORET
+static int
 do_check(void)
 {
 	enum trigdef_update_status uf;
@@ -177,13 +177,13 @@ do_check(void)
 	switch (uf) {
 	case TDUS_ERROR_NO_DIR:
 		notice(_("triggers data directory not yet created"));
-		exit(1);
+		return 1;
 	case TDUS_ERROR_NO_DEFERRED:
 		notice(_("trigger records not yet in existence"));
-		exit(1);
+		return 1;
 	case TDUS_OK:
 	case TDUS_ERROR_EMPTY_DEFERRED:
-		exit(0);
+		return 0;
 	default:
 		internerr("unknown trigdef_update_start return value '%d'", uf);
 	}
@@ -218,7 +218,7 @@ main(int argc, const char *const *argv)
 		if (*argv)
 			badusage(_("--%s takes no arguments"),
 			         "check-supported");
-		do_check();
+		return do_check();
 	}
 
 	if (!*argv || argv[1])