[PATCH 28/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may
be  passed  to exit() to indicate successful or unsuccessful termination,
respectively. The value of status in exit(status) may be EXIT_SUCCESS,
EXIT_FAILURE, or any other value, though only the least significant 8 bits (that
is, status & 0377) shall be available to a waiting parent proces. So exit(-1)
return 255.

Use the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit
status instead of "0" or "1", respectively. In <stdlib.h> EXIT_FAILURE has the
value "1": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for
consistency.

Signed-off-by: Elia Pinto <gitter.spiros@xxxxxxxxx>
---
 help.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/help.c b/help.c
index afd3af2412..e661dfddd8 100644
--- a/help.c
+++ b/help.c
@@ -582,7 +582,7 @@ const char *help_unknown_cmd(const char *cmd)
 
 	if (autocorrect == AUTOCORRECT_NEVER) {
 		fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	load_command_list("git-", &main_cmds, &other_cmds);
@@ -667,7 +667,7 @@ const char *help_unknown_cmd(const char *cmd)
 			strbuf_release(&msg);
 			if (!(starts_with(answer, "y") ||
 			      starts_with(answer, "Y")))
-				exit(1);
+				exit(EXIT_FAILURE);
 		} else {
 			fprintf_ln(stderr,
 				   _("Continuing in %0.1f seconds, "
@@ -690,7 +690,7 @@ const char *help_unknown_cmd(const char *cmd)
 			fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
 	}
 
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 void get_version_info(struct strbuf *buf, int show_build_options)
@@ -789,5 +789,5 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd,
 	}
 
 	string_list_clear(&suggested_refs, 0);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
-- 
2.35.1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux