{"thread":{"id":"57596","subject":"[PATCH 07/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","startedAt":"2022-03-21T23:06:00Z","lastAt":"2022-03-23T11:13:15Z","messageCount":48,"participants":["Elia Pinto","Bagas Sanjaya","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":41},"messages":[{"id":"451775","messageId":"20220321225523.724509-8-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 07/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:49Z","receivedAt":"2022-03-21T23:06:00Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/help.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 222f994f86..e5ca9d4a6e 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -554,7 +554,7 @@ static const char *check_git_cmd(const char* cmd)\n \t\tif (!exclude_guides || alias[0] == '!') {\n \t\t\tprintf_ln(_(\"'%s' is aliased to '%s'\"), cmd, alias);\n \t\t\tfree(alias);\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\t}\n \t\t/*\n \t\t * Otherwise, we pretend that the command was \"git\n-- \n2.35.1\n\n"},{"id":"451776","messageId":"20220321225523.724509-14-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 13/41] rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:55Z","receivedAt":"2022-03-21T23:06:03Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/rebase.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex b29ad2b65e..cafacc87f8 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -988,7 +988,7 @@ static void NORETURN error_on_missing_default_upstream(void)\n \t\t\t \"\\n\"),\n \t\t       remote, current_branch->name);\n \t}\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n static void set_reflog_action(struct rebase_options *options)\n@@ -1266,10 +1266,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\tif (has_unstaged_changes(the_repository, 1)) {\n \t\t\tputs(_(\"You must edit all merge conflicts and then\\n\"\n \t\t\t       \"mark them as resolved using git add\"));\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t\tif (read_basic_state(&options))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\tgoto run_rebase;\n \t}\n \tcase ACTION_SKIP: {\n@@ -1285,7 +1285,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"could not discard worktree changes\"));\n \t\tremove_branch_state(the_repository, 0);\n \t\tif (read_basic_state(&options))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\tgoto run_rebase;\n \t}\n \tcase ACTION_ABORT: {\n@@ -1297,7 +1297,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\tstring_list_clear(&merge_rr, 1);\n \n \t\tif (read_basic_state(&options))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\tropts.oid = &options.orig_head;\n \t\tropts.branch = options.head_name;\n \t\tropts.flags = RESET_HEAD_HARD;\n@@ -1388,7 +1388,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \n \tfor (i = 0; i < exec.nr; i++)\n \t\tif (check_exec_cmd(exec.items[i].string))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \n \tif (!(options.flags & REBASE_NO_QUIET))\n \t\tstrvec_push(&options.git_am_opts, \"-q\");\n-- \n2.35.1\n\n"},{"id":"451777","messageId":"20220321225523.724509-35-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 34/41] setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:16Z","receivedAt":"2022-03-21T23:06:05Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n setup.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/setup.c b/setup.c\nindex 04ce33cdcd..f5cb3f30a4 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -1508,7 +1508,7 @@ int daemonize(void)\n \t\tcase -1:\n \t\t\tdie_errno(_(\"fork failed\"));\n \t\tdefault:\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t}\n \tif (setsid() == -1)\n \t\tdie_errno(_(\"setsid failed\"));\n-- \n2.35.1\n\n"},{"id":"451778","messageId":"20220321225523.724509-6-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 05/41] commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:47Z","receivedAt":"2022-03-21T23:08:53Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/commit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 009a1de0a3..13af49fdd2 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -496,7 +496,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t}\n \n \tif (list_paths(&partial, !current_head ? NULL : \"HEAD\", &pathspec))\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \n \tdiscard_cache();\n \tif (read_cache() < 0)\n@@ -1081,7 +1081,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tif (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {\n \t\t\tfprintf(stderr,\n \t\t\t_(\"Please supply the message using either -m or -F option.\\n\"));\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t\tstrvec_clear(&env);\n \t}\n@@ -1785,12 +1785,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tif (message_is_empty(&sb, cleanup_mode) && !allow_empty_message) {\n \t\trollback_index_files();\n \t\tfprintf(stderr, _(\"Aborting commit due to empty commit message.\\n\"));\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \tif (template_untouched(&sb, template_file, cleanup_mode) && !allow_empty_message) {\n \t\trollback_index_files();\n \t\tfprintf(stderr, _(\"Aborting commit; you did not edit the message.\\n\"));\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \n \tif (fixup_message && starts_with(sb.buf, \"amend! \") &&\n@@ -1801,7 +1801,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tif (message_is_empty(&body, cleanup_mode)) {\n \t\t\trollback_index_files();\n \t\t\tfprintf(stderr, _(\"Aborting commit due to empty commit message body.\\n\"));\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t\tstrbuf_release(&body);\n \t}\n-- \n2.35.1\n\n"},{"id":"451779","messageId":"20220321225523.724509-3-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 02/41] branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:44Z","receivedAt":"2022-03-21T23:08:59Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n branch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 6b31df539a..7a28ccdbd2 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -260,7 +260,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,\n \t\tstring_list_append(tracking.srcs, orig_ref);\n \tif (install_branch_config_multiple_remotes(config_flags, new_ref,\n \t\t\t\ttracking.remote, tracking.srcs) < 0)\n-\t\texit(-1);\n+\t\texit(EXIT_FAILURE);\n \n cleanup:\n \tstring_list_clear(&tracking_srcs, 0);\n@@ -388,7 +388,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,\n \t\t\tif (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {\n \t\t\t\terror(_(upstream_missing), start_name);\n \t\t\t\tadvise(_(upstream_advice));\n-\t\t\t\texit(1);\n+\t\t\t\texit(EXIT_FAILURE);\n \t\t\t}\n \t\t\tdie(_(upstream_missing), start_name);\n \t\t}\n-- \n2.35.1\n\n"},{"id":"451780","messageId":"20220321225523.724509-41-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 40/41] upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:22Z","receivedAt":"2022-03-21T23:09:02Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n upload-pack.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 3a851b3606..1683d80c4d 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -543,7 +543,7 @@ static int get_common_commits(struct upload_pack_data *data,\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t\tif (data->stateless_rpc)\n-\t\t\t\texit(0);\n+\t\t\t\texit(EXIT_SUCCESS);\n \t\t\tgot_common = 0;\n \t\t\tgot_other = 0;\n \t\t\tcontinue;\n-- \n2.35.1\n\n"},{"id":"451781","messageId":"20220321225523.724509-33-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 32/41] remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:14Z","receivedAt":"2022-03-21T23:09:05Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n remote-curl.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex ff44f41011..da61168c6f 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -1063,7 +1063,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,\n \tclient.git_cmd = 1;\n \tstrvec_pushv(&client.args, client_argv);\n \tif (start_command(&client))\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \twrite_or_die(client.in, preamble->buf, preamble->len);\n \tif (heads)\n \t\twrite_or_die(client.in, heads->buf, heads->len);\n-- \n2.35.1\n\n"},{"id":"451782","messageId":"20220321225523.724509-28-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 27/41] git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:09Z","receivedAt":"2022-03-21T23:09:09Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n git.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex a25940d72e..7b75e6e720 100644\n--- a/git.c\n+++ b/git.c\n@@ -158,20 +158,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\telse {\n \t\t\t\tputs(git_exec_path());\n \t\t\t\ttrace2_cmd_name(\"_query_\");\n-\t\t\t\texit(0);\n+\t\t\t\texit(EXIT_SUCCESS);\n \t\t\t}\n \t\t} else if (!strcmp(cmd, \"--html-path\")) {\n \t\t\tputs(system_path(GIT_HTML_PATH));\n \t\t\ttrace2_cmd_name(\"_query_\");\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\t} else if (!strcmp(cmd, \"--man-path\")) {\n \t\t\tputs(system_path(GIT_MAN_PATH));\n \t\t\ttrace2_cmd_name(\"_query_\");\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\t} else if (!strcmp(cmd, \"--info-path\")) {\n \t\t\tputs(system_path(GIT_INFO_PATH));\n \t\t\ttrace2_cmd_name(\"_query_\");\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\t} else if (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n \t\t\tuse_pager = 1;\n \t\t} else if (!strcmp(cmd, \"-P\") || !strcmp(cmd, \"--no-pager\")) {\n@@ -318,7 +318,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\t\tfor (i = 0; i < list.nr; i++)\n \t\t\t\t\tprintf(\"%s \", list.items[i].string);\n \t\t\t\tstring_list_clear(&list, 0);\n-\t\t\t\texit(0);\n+\t\t\t\texit(EXIT_SUCCESS);\n \t\t\t} else {\n \t\t\t\texit(list_cmds(cmd));\n \t\t\t}\n@@ -900,7 +900,7 @@ int cmd_main(int argc, const char **argv)\n \t\tprintf(_(\"usage: %s\\n\\n\"), git_usage_string);\n \t\tlist_common_cmds_help();\n \t\tprintf(\"\\n%s\\n\", _(git_more_info_string));\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \tcmd = argv[0];\n \n@@ -920,7 +920,7 @@ int cmd_main(int argc, const char **argv)\n \t\t\tfprintf(stderr, _(\"expansion of alias '%s' failed; \"\n \t\t\t\t\t  \"'%s' is not a git command\\n\"),\n \t\t\t\tcmd, argv[0]);\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t\tif (!done_help) {\n \t\t\tcmd = argv[0] = help_unknown_cmd(cmd);\n-- \n2.35.1\n\n"},{"id":"451783","messageId":"20220321225523.724509-27-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 26/41] daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:08Z","receivedAt":"2022-03-21T23:09:16Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n daemon.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 94a5b8a364..cd07ae1643 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -134,7 +134,7 @@ static void loginfo(const char *err, ...)\n static void NORETURN daemon_die(const char *err, va_list params)\n {\n \tlogreport(LOG_ERR, err, params);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n struct expand_path_context {\n-- \n2.35.1\n\n"},{"id":"451784","messageId":"20220321225523.724509-42-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 41/41] exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:23Z","receivedAt":"2022-03-21T23:09:18Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nAdd a coccinelle semantic patch for using the C standard EXIT_SUCCESS and\nEXIT_FAILURE to indicate the program exit status instead of \"0\" or \"1\",\nrespectively. In <stdlib.h> EXIT_FAILURE has the value \"1\": use EXIT_FAILURE\neven if the program uses exit(-1), ie 255, for consistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n contrib/coccinelle/exit.cocci | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n create mode 100644 contrib/coccinelle/exit.cocci\n\ndiff --git a/contrib/coccinelle/exit.cocci b/contrib/coccinelle/exit.cocci\nnew file mode 100644\nindex 0000000000..ea5c243061\n--- /dev/null\n+++ b/contrib/coccinelle/exit.cocci\n@@ -0,0 +1,24 @@\n+@@\n+@@\n+- exit(0);\n++ exit(EXIT_SUCCESS);\n+@@\n+@@\n+- _exit(0);\n++ _exit(EXIT_SUCCESS);\n+@@\n+@@\n+- exit(1);\n++ exit(EXIT_FAILURE);\n+@@\n+@@\n+- _exit(1);\n++ _exit(EXIT_FAILURE);\n+@@\n+@@\n+- exit(-1);\n++ exit(EXIT_FAILURE);\n+@@\n+@@\n+- _exit(-1);\n++ _exit(EXIT_FAILURE);\n-- \n2.35.1\n\n"},{"id":"451785","messageId":"20220321225523.724509-2-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 01/41] archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:43Z","receivedAt":"2022-03-21T23:09:20Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n archive.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/archive.c b/archive.c\nindex e29d0e00f6..c8c1df59de 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -590,7 +590,7 @@ static int parse_archive_args(int argc, const char **argv,\n \t\tfor (i = 0; i < nr_archivers; i++)\n \t\t\tif (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)\n \t\t\t\tprintf(\"%s\\n\", archivers[i]->name);\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t}\n \n \tif (!format && name_hint)\n-- \n2.35.1\n\n"},{"id":"451786","messageId":"20220321225523.724509-25-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 24/41] git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:06Z","receivedAt":"2022-03-21T23:09:22Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n contrib/credential/osxkeychain/git-credential-osxkeychain.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/credential/osxkeychain/git-credential-osxkeychain.c b/contrib/credential/osxkeychain/git-credential-osxkeychain.c\nindex 0b44a9b7cc..169cbff821 100644\n--- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c\n+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c\n@@ -19,7 +19,7 @@ static void die(const char *err, ...)\n \tvsnprintf(msg, sizeof(msg), err, params);\n \tfprintf(stderr, \"%s\\n\", msg);\n \tva_end(params);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n static void *xstrdup(const char *s1)\n@@ -143,7 +143,7 @@ static void read_credential(void)\n \t\t\telse if (!strcmp(v, \"smtp\"))\n \t\t\t\tprotocol = kSecProtocolTypeSMTP;\n \t\t\telse /* we don't yet handle other protocols */\n-\t\t\t\texit(0);\n+\t\t\t\texit(EXIT_SUCCESS);\n \t\t}\n \t\telse if (!strcmp(buf, \"host\")) {\n \t\t\tchar *colon = strchr(v, ':');\n-- \n2.35.1\n\n"},{"id":"451787","messageId":"20220321225523.724509-21-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 20/41] tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:02Z","receivedAt":"2022-03-21T23:09:25Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/tag.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e5a8f85693..55a808873c 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -315,7 +315,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,\n \t\tif (launch_editor(path, buf, NULL)) {\n \t\t\tfprintf(stderr,\n \t\t\t_(\"Please supply the message using either -m or -F option.\\n\"));\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t}\n \n-- \n2.35.1\n\n"},{"id":"451788","messageId":"20220321225523.724509-10-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 09/41] mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:51Z","receivedAt":"2022-03-21T23:09:28Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/mailsplit.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 7baef30569..9127ac49e3 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -73,7 +73,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)\n \n \tif (is_bare && !allow_bare) {\n \t\tfprintf(stderr, \"corrupt mailbox\\n\");\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \tfd = xopen(name, O_WRONLY | O_CREAT | O_EXCL, 0666);\n \toutput = xfdopen(fd, \"w\");\n-- \n2.35.1\n\n"},{"id":"451789","messageId":"20220321225523.724509-39-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 38/41] test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:20Z","receivedAt":"2022-03-21T23:09:31Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n t/helper/test-submodule-config.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c\nindex e2692746df..d4608300d5 100644\n--- a/t/helper/test-submodule-config.c\n+++ b/t/helper/test-submodule-config.c\n@@ -8,7 +8,7 @@ static void die_usage(int argc, const char **argv, const char *msg)\n {\n \tfprintf(stderr, \"%s\\n\", msg);\n \tfprintf(stderr, \"Usage: %s [<commit> <submodulepath>] ...\\n\", argv[0]);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n int cmd__submodule_config(int argc, const char **argv)\n-- \n2.35.1\n\n"},{"id":"451790","messageId":"20220321225523.724509-12-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 11/41] merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:53Z","receivedAt":"2022-03-21T23:09:36Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/merge.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex f178f5a3ee..3bb6f902f0 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -209,7 +209,7 @@ static struct strategy *get_strategy(const char *name)\n \t\t\t\tfprintf(stderr, \" %s\", other_cmds.names[i]->name);\n \t\t\tfprintf(stderr, \".\\n\");\n \t\t}\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \n \tCALLOC_ARRAY(ret, 1);\n@@ -824,7 +824,7 @@ static void abort_commit(struct commit_list *remoteheads, const char *err_msg)\n \tfprintf(stderr,\n \t\t_(\"Not committing merge; use 'git commit' to complete the merge.\\n\"));\n \twrite_merge_state(remoteheads);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n static const char merge_editor_comment[] =\n-- \n2.35.1\n\n"},{"id":"451792","messageId":"20220321225523.724509-18-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 17/41] shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:59Z","receivedAt":"2022-03-21T23:09:43Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/shortlog.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 26c5c0cf93..0763c94df6 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -381,7 +381,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n \t\tcase PARSE_OPT_COMPLETE:\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\tcase PARSE_OPT_DONE:\n \t\t\tgoto parse_done;\n \t\t}\n-- \n2.35.1\n\n"},{"id":"451793","messageId":"20220321225523.724509-13-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 12/41] pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:54Z","receivedAt":"2022-03-21T23:09:45Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/pull.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 4d667abc19..3b16e891ea 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -489,7 +489,7 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs\n \t\tfprintf_ln(stderr, _(\"Your configuration specifies to merge with the ref '%s'\\n\"\n \t\t\t\"from the remote, but no such ref was fetched.\"),\n \t\t\t*curr_branch->merge_name);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n /**\n-- \n2.35.1\n\n"},{"id":"451794","messageId":"20220321225523.724509-38-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 37/41] test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:19Z","receivedAt":"2022-03-21T23:09:47Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n t/helper/test-reach.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-reach.c b/t/helper/test-reach.c\nindex 2f65c7f6a5..b5c4cbf6cc 100644\n--- a/t/helper/test-reach.c\n+++ b/t/helper/test-reach.c\n@@ -40,7 +40,7 @@ int cmd__reach(int ac, const char **av)\n \tsetup_git_directory();\n \n \tif (ac < 2)\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \n \tA = B = NULL;\n \tX = Y = NULL;\n-- \n2.35.1\n\n"},{"id":"451795","messageId":"20220321225523.724509-34-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 33/41] run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:15Z","receivedAt":"2022-03-21T23:09:49Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n run-command.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex a8501e38ce..5a5d865716 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -319,7 +319,7 @@ static void child_die(enum child_errcode err)\n \n \t/* write(2) on buf smaller than PIPE_BUF (min 512) is atomic: */\n \txwrite(child_notifier, &buf, sizeof(buf));\n-\t_exit(1);\n+\t_exit(EXIT_FAILURE);\n }\n \n static void child_dup2(int fd, int to)\n-- \n2.35.1\n\n"},{"id":"451796","messageId":"20220321225523.724509-17-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 16/41] rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:58Z","receivedAt":"2022-03-21T23:09:50Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/rm.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 84a935a16e..4c4546bad8 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -369,7 +369,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \t\tif (get_oid(\"HEAD\", &oid))\n \t\t\toidclr(&oid);\n \t\tif (check_local_mod(&oid, index_only))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t}\n \n \t/*\n-- \n2.35.1\n\n"},{"id":"451797","messageId":"20220321225523.724509-32-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 31/41] path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:13Z","receivedAt":"2022-03-21T23:09:52Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n path.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex 2c895471d9..6639bab7b4 100644\n--- a/path.c\n+++ b/path.c\n@@ -915,7 +915,7 @@ void safe_create_dir(const char *dir, int share)\n \tif (mkdir(dir, 0777) < 0) {\n \t\tif (errno != EEXIST) {\n \t\t\tperror(dir);\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t}\n \telse if (share && adjust_shared_perm(dir))\n-- \n2.35.1\n\n"},{"id":"451798","messageId":"20220321225523.724509-1-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":null,"subject":"[PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:42Z","receivedAt":"2022-03-21T23:09:53Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nEXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but\nnot everywhere. Also in branch.c there is a returns exit(-1), ie 255, when\nexit(1) might be more appropriate.\n\nT$his patch series adds a coccinelle semantic patch exit.cocci in\ncontrib/coccinelle to rewrite:\n- exit(0) in exit(EXIT_SUCCESS)\n- exit(1) in exit(EXIT_FAILURE)\n- exit(-1) in exit(EXIT_FAILURE)\n\nThe patch treats the status code in _exit equivalently.\n\n\n\nElia Pinto (41):\n  archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or\n    EXIT_FAILURE exit status\n  help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n    status\n  update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n    status\n  obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or\n    EXIT_FAILURE exit status\n  git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n    exit status\n  daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n    status\n  parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n    status\n  path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n    status\n  test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n    exit status\n  test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or\n    EXIT_FAILURE exit status\n  upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n  exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n\n archive.c                                     |  2 +-\n branch.c                                      |  4 ++--\n builtin/am.c                                  |  4 ++--\n builtin/blame.c                               |  2 +-\n builtin/commit.c                              | 10 ++++----\n builtin/credential-cache--daemon.c            |  2 +-\n builtin/help.c                                |  2 +-\n builtin/init-db.c                             |  2 +-\n builtin/mailsplit.c                           |  2 +-\n builtin/merge-index.c                         |  2 +-\n builtin/merge.c                               |  4 ++--\n builtin/pull.c                                |  2 +-\n builtin/rebase.c                              | 12 +++++-----\n builtin/remote-ext.c                          |  2 +-\n builtin/rev-parse.c                           |  2 +-\n builtin/rm.c                                  |  2 +-\n builtin/shortlog.c                            |  2 +-\n builtin/show-branch.c                         |  4 ++--\n builtin/stash.c                               |  2 +-\n builtin/tag.c                                 |  2 +-\n builtin/unpack-objects.c                      |  6 ++---\n builtin/update-index.c                        |  4 ++--\n compat/obstack.c                              |  2 +-\n contrib/coccinelle/exit.cocci                 | 24 +++++++++++++++++++\n .../osxkeychain/git-credential-osxkeychain.c  |  4 ++--\n .../wincred/git-credential-wincred.c          |  2 +-\n daemon.c                                      |  2 +-\n git.c                                         | 14 +++++------\n help.c                                        |  8 +++----\n http-backend.c                                | 12 +++++-----\n parse-options.c                               |  2 +-\n path.c                                        |  2 +-\n remote-curl.c                                 |  2 +-\n run-command.c                                 |  2 +-\n setup.c                                       |  2 +-\n shell.c                                       |  2 +-\n t/helper/test-json-writer.c                   |  2 +-\n t/helper/test-reach.c                         |  2 +-\n t/helper/test-submodule-config.c              |  2 +-\n t/helper/test-submodule-nested-repo-config.c  |  2 +-\n upload-pack.c                                 |  2 +-\n 41 files changed, 95 insertions(+), 71 deletions(-)\n create mode 100644 contrib/coccinelle/exit.cocci\n\n-- \n2.35.1\n\n"},{"id":"451799","messageId":"20220321225523.724509-5-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 04/41] blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:46Z","receivedAt":"2022-03-21T23:09:56Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/blame.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 8d15b68afc..9866e6c911 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -921,7 +921,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n \t\tcase PARSE_OPT_COMPLETE:\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\tcase PARSE_OPT_DONE:\n \t\t\tif (ctx.argv[0])\n \t\t\t\tdashdash_pos = ctx.cpidx;\n-- \n2.35.1\n\n"},{"id":"451800","messageId":"20220321225523.724509-16-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 15/41] rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:57Z","receivedAt":"2022-03-21T23:09:59Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/rev-parse.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 8480a59f57..e313b64fcd 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -543,7 +543,7 @@ static int cmd_sq_quote(int argc, const char **argv)\n static void die_no_single_rev(int quiet)\n {\n \tif (quiet)\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \telse\n \t\tdie(_(\"Needed a single revision\"));\n }\n-- \n2.35.1\n\n"},{"id":"451801","messageId":"20220321225523.724509-30-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 29/41] http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:11Z","receivedAt":"2022-03-21T23:10:01Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n http-backend.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/http-backend.c b/http-backend.c\nindex 81a7229ece..932d92d70b 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -137,7 +137,7 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)\n \tif (err && *err)\n \t\tvfprintf(stderr, err, params);\n \tva_end(params);\n-\texit(0);\n+\texit(EXIT_SUCCESS);\n }\n \n __attribute__((format (printf, 2, 3)))\n@@ -153,7 +153,7 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)\n \tif (err && *err)\n \t\tvfprintf(stderr, err, params);\n \tva_end(params);\n-\texit(0);\n+\texit(EXIT_SUCCESS);\n }\n \n static void select_getanyfile(struct strbuf *hdr)\n@@ -488,7 +488,7 @@ static void run_service(const char **argv, int buffer_input)\n \tcld.clean_on_exit = 1;\n \tcld.wait_after_clean = 1;\n \tif (start_command(&cld))\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \n \tclose(1);\n \tif (gzipped_request)\n@@ -501,7 +501,7 @@ static void run_service(const char **argv, int buffer_input)\n \t\tclose(0);\n \n \tif (finish_command(&cld))\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n }\n \n static int show_text_ref(const char *name, const struct object_id *oid,\n@@ -628,7 +628,7 @@ static void check_content_type(struct strbuf *hdr, const char *accepted_type)\n \t\t\t\"Expected POST with Content-Type '%s',\"\n \t\t\t\" but received '%s' instead.\\n\",\n \t\t\taccepted_type, actual_type);\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t}\n }\n \n@@ -668,7 +668,7 @@ static NORETURN void die_webcgi(const char *err, va_list params)\n \t\thdr_nocache(&hdr);\n \t\tend_headers(&hdr);\n \t}\n-\texit(0); /* we successfully reported a failure ;-) */\n+\texit(EXIT_SUCCESS); /* we successfully reported a failure ;-) */\n }\n \n static int die_webcgi_recursing(void)\n-- \n2.35.1\n\n"},{"id":"451802","messageId":"20220321225523.724509-19-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 18/41] show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:00Z","receivedAt":"2022-03-21T23:10:04Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/show-branch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 330b0553b9..04a99aa7b2 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -820,7 +820,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \n \tif (!ref_name_cnt) {\n \t\tfprintf(stderr, \"No revs to be shown.\\n\");\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t}\n \n \tfor (num_rev = 0; ref_name[num_rev]; num_rev++) {\n@@ -898,7 +898,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t}\n \t}\n \tif (extra < 0)\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \n \t/* Sort topologically */\n \tsort_in_topological_order(&seen, sort_order);\n-- \n2.35.1\n\n"},{"id":"451803","messageId":"20220321225523.724509-4-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 03/41] am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:45Z","receivedAt":"2022-03-21T23:10:06Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/am.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 0f4111bafa..ac74bce555 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1638,7 +1638,7 @@ static void do_commit(const struct am_state *state)\n \tstruct strbuf sb = STRBUF_INIT;\n \n \tif (run_hooks(\"pre-applypatch\"))\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \n \tif (write_cache_as_tree(&tree, 0, NULL))\n \t\tdie(_(\"git write-tree failed to write a tree\"));\n@@ -1841,7 +1841,7 @@ static void am_run(struct am_state *state, int resume)\n \t\t}\n \n \t\tif (run_applypatch_msg_hook(state))\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\tif (to_keep)\n \t\t\tgoto commit;\n \n-- \n2.35.1\n\n"},{"id":"451804","messageId":"20220321225523.724509-37-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 36/41] test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:18Z","receivedAt":"2022-03-21T23:10:09Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n t/helper/test-json-writer.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-json-writer.c b/t/helper/test-json-writer.c\nindex 37c452535f..61c5a3dac1 100644\n--- a/t/helper/test-json-writer.c\n+++ b/t/helper/test-json-writer.c\n@@ -322,7 +322,7 @@ static void cmp(const char *test, const struct json_writer *jw, const char *exp)\n \n \tprintf(\"error[%s]: observed '%s' expected '%s'\\n\",\n \t       test, jw->json.buf, exp);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n #define t(v) do { make_##v(0); cmp(#v, &v, expect_##v); } while (0)\n-- \n2.35.1\n\n"},{"id":"451805","messageId":"20220321225523.724509-29-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 28/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:10Z","receivedAt":"2022-03-21T23:10:13Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex afd3af2412..e661dfddd8 100644\n--- a/help.c\n+++ b/help.c\n@@ -582,7 +582,7 @@ const char *help_unknown_cmd(const char *cmd)\n \n \tif (autocorrect == AUTOCORRECT_NEVER) {\n \t\tfprintf_ln(stderr, _(\"git: '%s' is not a git command. See 'git --help'.\"), cmd);\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n \n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n@@ -667,7 +667,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t\t\tstrbuf_release(&msg);\n \t\t\tif (!(starts_with(answer, \"y\") ||\n \t\t\t      starts_with(answer, \"Y\")))\n-\t\t\t\texit(1);\n+\t\t\t\texit(EXIT_FAILURE);\n \t\t} else {\n \t\t\tfprintf_ln(stderr,\n \t\t\t\t   _(\"Continuing in %0.1f seconds, \"\n@@ -690,7 +690,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t\t\tfprintf(stderr, \"\\t%s\\n\", main_cmds.names[i]->name);\n \t}\n \n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n void get_version_info(struct strbuf *buf, int show_build_options)\n@@ -789,5 +789,5 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd,\n \t}\n \n \tstring_list_clear(&suggested_refs, 0);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n-- \n2.35.1\n\n"},{"id":"451806","messageId":"20220321225523.724509-40-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 39/41] test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:21Z","receivedAt":"2022-03-21T23:10:15Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n t/helper/test-submodule-nested-repo-config.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c\nindex dc1c14bde3..e32b68ceac 100644\n--- a/t/helper/test-submodule-nested-repo-config.c\n+++ b/t/helper/test-submodule-nested-repo-config.c\n@@ -5,7 +5,7 @@ static void die_usage(const char **argv, const char *msg)\n {\n \tfprintf(stderr, \"%s\\n\", msg);\n \tfprintf(stderr, \"Usage: %s <submodulepath> <config name>\\n\", argv[0]);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n int cmd__submodule_nested_repo_config(int argc, const char **argv)\n-- \n2.35.1\n\n"},{"id":"451807","messageId":"20220321225523.724509-7-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 06/41] credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:48Z","receivedAt":"2022-03-21T23:10:17Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/credential-cache--daemon.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c\nindex 4c6c89ab0d..83441cad5e 100644\n--- a/builtin/credential-cache--daemon.c\n+++ b/builtin/credential-cache--daemon.c\n@@ -138,7 +138,7 @@ static void serve_one_client(FILE *in, FILE *out)\n \t\t * process actually ends, which closes the socket and gives\n \t\t * them EOF.\n \t\t */\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t}\n \telse if (!strcmp(action.buf, \"erase\"))\n \t\tremove_credential(&c);\n-- \n2.35.1\n\n"},{"id":"451808","messageId":"20220321225523.724509-15-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 14/41] remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:56Z","receivedAt":"2022-03-21T23:10:19Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/remote-ext.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/remote-ext.c b/builtin/remote-ext.c\nindex fd3538d4f0..3b32d68ed5 100644\n--- a/builtin/remote-ext.c\n+++ b/builtin/remote-ext.c\n@@ -172,7 +172,7 @@ static int command_loop(const char *child)\n \t\tif (!fgets(buffer, MAXCOMMAND - 1, stdin)) {\n \t\t\tif (ferror(stdin))\n \t\t\t\tdie(\"Command input error\");\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\t}\n \t\t/* Strip end of line characters. */\n \t\ti = strlen(buffer);\n-- \n2.35.1\n\n"},{"id":"451809","messageId":"20220321225523.724509-11-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 10/41] merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:52Z","receivedAt":"2022-03-21T23:10:20Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/merge-index.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex c0383fe9df..efa7ceaa35 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -37,7 +37,7 @@ static int merge_entry(int pos, const char *path)\n \t\telse {\n \t\t\tif (!quiet)\n \t\t\t\tdie(\"merge program failed\");\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\t}\n \t}\n \treturn found;\n-- \n2.35.1\n\n"},{"id":"451811","messageId":"20220321225523.724509-26-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 25/41] git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:07Z","receivedAt":"2022-03-21T23:15:04Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n contrib/credential/wincred/git-credential-wincred.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c\nindex 5091048f9c..25028cd39c 100644\n--- a/contrib/credential/wincred/git-credential-wincred.c\n+++ b/contrib/credential/wincred/git-credential-wincred.c\n@@ -20,7 +20,7 @@ static void die(const char *err, ...)\n \tvsnprintf(msg, sizeof(msg), err, params);\n \tfprintf(stderr, \"%s\\n\", msg);\n \tva_end(params);\n-\texit(1);\n+\texit(EXIT_FAILURE);\n }\n \n static void *xmalloc(size_t size)\n-- \n2.35.1\n\n"},{"id":"451812","messageId":"20220321225523.724509-23-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 22/41] update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:04Z","receivedAt":"2022-03-21T23:15:23Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/update-index.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex aafe7eeac2..9e4c15e846 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -699,7 +699,7 @@ static void read_head_pointers(void)\n \t\tdie(\"No HEAD -- no initial commit yet?\");\n \tif (read_ref(\"MERGE_HEAD\", &merge_head_oid)) {\n \t\tfprintf(stderr, \"Not in the middle of a merge.\\n\");\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t}\n }\n \n@@ -1127,7 +1127,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n \t\tcase PARSE_OPT_COMPLETE:\n-\t\t\texit(0);\n+\t\t\texit(EXIT_SUCCESS);\n \t\tcase PARSE_OPT_NON_OPTION:\n \t\tcase PARSE_OPT_DONE:\n \t\t{\n-- \n2.35.1\n\n"},{"id":"451813","messageId":"20220321225523.724509-9-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 08/41] init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:54:50Z","receivedAt":"2022-03-21T23:15:45Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/init-db.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 546f9c595e..d8ddc04b96 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -264,7 +264,7 @@ static int create_default_files(const char *template_path,\n \t\t\t    initial_branch);\n \n \t\tif (create_symref(\"HEAD\", ref, NULL) < 0)\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\tfree(ref);\n \t}\n \n-- \n2.35.1\n\n"},{"id":"451814","messageId":"20220321225523.724509-24-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 23/41] obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:05Z","receivedAt":"2022-03-21T23:15:53Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n compat/obstack.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/obstack.c b/compat/obstack.c\nindex 27cd5c1ea1..e8641816f7 100644\n--- a/compat/obstack.c\n+++ b/compat/obstack.c\n@@ -407,7 +407,7 @@ print_and_abort (void)\n # else\n   fprintf (stderr, \"%s\\n\", _(\"memory exhausted\"));\n # endif\n-  exit (1);\n+  exit(EXIT_FAILURE);\n }\n \n #endif\t/* !ELIDE_CODE */\n-- \n2.35.1\n\n"},{"id":"451815","messageId":"20220321225523.724509-22-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 21/41] unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:03Z","receivedAt":"2022-03-21T23:17:26Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/unpack-objects.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex dbeb0680a5..d5838bfad1 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -118,7 +118,7 @@ static void *get_data(unsigned long size)\n \t\t\terror(\"inflate returned %d\", ret);\n \t\t\tFREE_AND_NULL(buf);\n \t\t\tif (!recover)\n-\t\t\t\texit(1);\n+\t\t\t\texit(EXIT_FAILURE);\n \t\t\thas_errors = 1;\n \t\t\tbreak;\n \t\t}\n@@ -435,7 +435,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\n \t\tif (!recover)\n-\t\t\texit(1);\n+\t\t\texit(EXIT_FAILURE);\n \t\thas_errors = 1;\n \t\treturn;\n \t}\n@@ -482,7 +482,7 @@ static void unpack_one(unsigned nr)\n \t\thas_errors = 1;\n \t\tif (recover)\n \t\t\treturn;\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n }\n \n-- \n2.35.1\n\n"},{"id":"451816","messageId":"20220321225523.724509-31-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 30/41] parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:12Z","receivedAt":"2022-03-21T23:17:30Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n parse-options.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 6e57744fd2..0ee82fb760 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -883,7 +883,7 @@ int parse_options(int argc, const char **argv,\n \tcase PARSE_OPT_ERROR:\n \t\texit(129);\n \tcase PARSE_OPT_COMPLETE:\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \tcase PARSE_OPT_NON_OPTION:\n \tcase PARSE_OPT_DONE:\n \t\tbreak;\n-- \n2.35.1\n\n"},{"id":"451817","messageId":"20220321225523.724509-20-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 19/41] stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:01Z","receivedAt":"2022-03-21T23:17:44Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n builtin/stash.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 0c7b6a9588..9315ff74ce 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -656,7 +656,7 @@ static void assert_stash_ref(struct stash_info *info)\n \tif (!info->is_stash_ref) {\n \t\terror(_(\"'%s' is not a stash reference\"), info->revision.buf);\n \t\tfree_stash_info(info);\n-\t\texit(1);\n+\t\texit(EXIT_FAILURE);\n \t}\n }\n \n-- \n2.35.1\n\n"},{"id":"451818","messageId":"20220321225523.724509-36-gitter.spiros@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"[PATCH 35/41] shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-21T22:55:17Z","receivedAt":"2022-03-21T23:20:56Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"The C standard specifies two constants, EXIT_SUCCESS and  EXIT_FAILURE, that may\nbe  passed  to exit() to indicate successful or unsuccessful termination,\nrespectively. The value of status in exit(status) may be EXIT_SUCCESS,\nEXIT_FAILURE, or any other value, though only the least significant 8 bits (that\nis, status & 0377) shall be available to a waiting parent proces. So exit(-1)\nreturn 255.\n\nUse the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit\nstatus instead of \"0\" or \"1\", respectively. In <stdlib.h> EXIT_FAILURE has the\nvalue \"1\": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for\nconsistency.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\n shell.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/shell.c b/shell.c\nindex 811e13b9c9..d2d1718e9c 100644\n--- a/shell.c\n+++ b/shell.c\n@@ -146,7 +146,7 @@ int cmd_main(int argc, const char **argv)\n \t\t\t    \"and have read and execute access.\");\n \t\t}\n \t\trun_shell();\n-\t\texit(0);\n+\t\texit(EXIT_SUCCESS);\n \t} else if (argc != 3 || strcmp(argv[1], \"-c\")) {\n \t\t/*\n \t\t * We do not accept any other modes except \"-c\" followed by\n-- \n2.35.1\n\n"},{"id":"451829","messageId":"5dea325c-c80c-c203-c42e-b55e58b717de@gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2022-03-22T06:49:24Z","receivedAt":"2022-03-22T06:49:42Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On 22/03/22 05.54, Elia Pinto wrote:\n> Elia Pinto (41):\n>    archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or\n>      EXIT_FAILURE exit status\n>    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n>      status\n>    update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n>      status\n>    obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or\n>      EXIT_FAILURE exit status\n>    git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n>      exit status\n>    daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n>      status\n>    parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n>      status\n>    path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n>      status\n>    test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n>      exit status\n>    test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or\n>      EXIT_FAILURE exit status\n>    upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n>    exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> \n\nI think we should only have 2 patches in this series: the first is to replace\nwith EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"451832","messageId":"CA+EOSBmzndi=f108Ho8e801K_cDPFdWuddkiLwFfNNK_2Rg4_Q@mail.gmail.com","threadId":"57596","inReplyTo":"5dea325c-c80c-c203-c42e-b55e58b717de@gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-22T08:45:58Z","receivedAt":"2022-03-22T08:46:10Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Il giorno mar 22 mar 2022 alle ore 07:49 Bagas Sanjaya\n<bagasdotme@gmail.com> ha scritto:\n>\n> On 22/03/22 05.54, Elia Pinto wrote:\n> > Elia Pinto (41):\n> >    archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or\n> >      EXIT_FAILURE exit status\n> >    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n> >      status\n> >    update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n> >      status\n> >    obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or\n> >      EXIT_FAILURE exit status\n> >    git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n> >      exit status\n> >    daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n> >      status\n> >    parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n> >      status\n> >    path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit\n> >      status\n> >    test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE\n> >      exit status\n> >    test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or\n> >      EXIT_FAILURE exit status\n> >    upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >    exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status\n> >\n>\n> I think we should only have 2 patches in this series: the first is to replace\n> with EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.\nSalutations. You can help me ? I'm having trouble continuing the\ncourse and haven't had any answers yet. Or if you can help me figure\nout who to contact. Thank you for your cooperation.\n\nThank you. But there are many sources that include both of them, the\nchoice would then be arbitrary. However, I follow the various reviews.\n> --\n> An old man doll... just what I always wanted! - Clara\n"},{"id":"451833","messageId":"220322.86r16unzer.gmgdl@evledraar.gmail.com","threadId":"57596","inReplyTo":"20220321225523.724509-1-gitter.spiros@gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-22T08:26:39Z","receivedAt":"2022-03-22T08:51:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Mar 21 2022, Elia Pinto wrote:\n\n> EXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but\n> not everywhere. Also in branch.c there is a returns exit(-1), ie 255, when\n> exit(1) might be more appropriate.\n\nOn existing use: That's quite the overstatement :)\n\nWe use EXIT_{SUCCESS,FAILURE} only in:\n\n * contrib/credential/ code.\n * sh-i18n--envsubst.c\n * EXIT_FAILURE in one stray test helper\n\nSo out of \"real git\" that users see only sh-i18n--envsubst.c will ever\nrun by default, and the reason it uses these is because it's as-is\nimported GNU code.\n\nI'd think if anything we'd be better off doing this the other way\naround, and always hardcoding either 0 or 1.\n\nI'm not aware of any platform where EXIT_SUCCESS is non-zero, although\nthat's probably left open by the C standard.\n\nFor EXIT_FAILURE there *are* platforms where it's non-1, but I don't\nknow if we're ported to any of those, e.g. on z/OS it's[1]:\n\n    The argument status can have a value from 0 to 255 inclusive or be\n    one of the macros EXIT_SUCCESS or EXIT_FAILURE. The value of\n    EXIT_SUCCESS is defined in stdlib.h as 0; the value of EXIT_FAILURE\n    is 8.\n\nNow, I don't know z/OS at all, but e.g. if a shellscripts calls a C\nprogram there would $? be 1 if we hardcode 1, but 8 on EXIT_FAILURE?\n\nWe also document for some of these programs that on failure we'll return\n1 specifically, not whatever EXIT_FAILURE is.\n\nThese patches also miss cases where we'll set 0 or 1 in a variable, and\nthen exit(ret). See e.g. builtin/rm.c. You just changed the hardcoded\nexit(1), but missed where we'll return a hardcoded 0 or 1 via a\nvariable.\n\nAnd then there's changing exit(-1) to exit(1). That's existing\nnon-portable use that we really should fix. But I know that you missed a\nlot there, since I instrumented git.c recently to intercept those for\ntesting (it came up in some thread). We have a lot more than you spotted\n(and some will error if mapped to 1 IIRC). Most of those also want to\nexit 128, not 1.\n\nAnyway:\n\nAll in all I think we should just double down on the hardcoding instead,\nbut we should fix the exit(-1) cases, and that's best done with some new\nGIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or whatever.\n\nA lot of these codepaths are also paths we should fix, but not because\nwe exit(N) with a hardcoded N, but because we invoke exit(N) there at\nall. See 338abb0f045 (builtins + test helpers: use return instead of\nexit() in cmd_*, 2021-06-08) for how some of those should be changed.\n\nI think we'd be much better off with something like this in\ngit-compat-util.h:\n\n    #ifndef BYPASS_EXIT_SANITY\n    #ifdef EXIT_SUCCESS\n    #if EXIT_SUCCESS != 0\n    #error \"git assumes EXIT_SUCCESS is 0, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk\"\n    #endif\n    #endif\n    #ifdef EXIT_FAILURE\n    #if EXIT_FAILURE != 0\n    #error \"git assumes EXIT_FAILRE is 1, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk\"\n    #endif\n    #endif\n    #endif\n\nOr *if* we're going to pursue this a twist on that (I really don't think\nthis is worthwhile, just saying) where we'd re-define EXIT_SUCCESS and\nEXIT_FAILURE to some sentinel values like 123 and 124.\n\nThen run our entire test suite and roundtrip-assert that at least we\nourselves handled that properly. I.e. whenever run_command() runs and we\ncheck for success we check 123, not 0, and a \"normal failure\" is 124,\nnot 1.\n\nI know we'll get a *lot of* failures if we do that, so I'm not arguing\nthat we *should*, just that it's rather easy for you to test that and\nsee the resulting test suite dumpster fire.\n\nSo I don't see how a *partial conversion* is really getting us anywhere,\neven if we take the pedantic C portability view of things.\n\nAll we'd have accomplished is a false sense of portability on most OS's,\nas these will be 0 and 1 anyway. And on any stray odd OS's like z/OS\nwe'll just need to deal with e.g. both 1 and 8 for EXIT_FAILURE, since\nwe *will* miss a lot of cases.\n\n1. https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program\n"},{"id":"451841","messageId":"34a387f9-eab2-daa0-0726-cffa3cc266e0@gmail.com","threadId":"57596","inReplyTo":"5dea325c-c80c-c203-c42e-b55e58b717de@gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2022-03-22T11:21:59Z","receivedAt":"2022-03-22T11:22:06Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On 22/03/22 13.49, Bagas Sanjaya wrote:\n> I think we should only have 2 patches in this series: the first is to replace\n> with EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.\n> \n\nOops, I missed [PATCH 00/41] that adds cocci semantics. So actually we should\nhave 3 patches...\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"451858","messageId":"CA+EOSBmKue=z98NnCPENN3uc6NzXXJ7kBBJB8cJ0k_WRozX1sg@mail.gmail.com","threadId":"57596","inReplyTo":"220322.86r16unzer.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2022-03-22T17:47:47Z","receivedAt":"2022-03-22T17:47:59Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Il giorno mar 22 mar 2022 alle ore 09:51 Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> ha scritto:\n>\n\nFirst of all, thanks for the review.\n\n>\n> On Mon, Mar 21 2022, Elia Pinto wrote:\n>\n> > EXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but\n> > not everywhere. Also in branch.c there is a returns exit(-1), ie 255, when\n> > exit(1) might be more appropriate.\n>\n> On existing use: That's quite the overstatement :)\n>\nIt was not a quantitative assessment. I just wanted to point out that\nthe macros stdlib.h EXIT_SUCCESS and EXIT_FAILURE already exist in the\ngit code.\n> We use EXIT_{SUCCESS,FAILURE} only in:\n>\n>  * contrib/credential/ code.\n>  * sh-i18n--envsubst.c\n>  * EXIT_FAILURE in one stray test helper\n>\n> So out of \"real git\" that users see only sh-i18n--envsubst.c will ever\n> run by default, and the reason it uses these is because it's as-is\n> imported GNU code.\n>\n> I'd think if anything we'd be better off doing this the other way\n> around, and always hardcoding either 0 or 1.\n>\n> I'm not aware of any platform where EXIT_SUCCESS is non-zero, although\n> that's probably left open by the C standard.\nNo. It is defined be 0\nhttps://pubs.opengroup.org/onlinepubs/009604599/basedefs/stdlib.h.html\n>\n> For EXIT_FAILURE there *are* platforms where it's non-1, but I don't\n> know if we're ported to any of those, e.g. on z/OS it's[1]:\n>\n>     The argument status can have a value from 0 to 255 inclusive or be\n>     one of the macros EXIT_SUCCESS or EXIT_FAILURE. The value of\n>     EXIT_SUCCESS is defined in stdlib.h as 0; the value of EXIT_FAILURE\n>     is 8.\n>\nEXIT_FAILURE it is not defined what precise value it has by the standard C.\nHowever linux, aix, solaris and windows define it as \"1\". Only Z / OS\ncalls it 8 but I'm sure git  doesn't care about it.\nZ/OS\n\nhttps://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program\n\n\nSOLARIS\nhttps://gitlab.anu.edu.au/mu/x-lcc/blob/24be447de544ed06d490ca0b2304a6531362156a/include/sparc/solaris/stdlib.h\n\nAIX\nhttps://www.rpi.edu/dept/acm/packages/egcs/1.1.2/rs_aix42/lib/gcc-lib/powerpc-ibm-aix4.3.1.0/egcs-2.91.66/include/stdlib.h\n\nWINDOWS\nhttps://docs.microsoft.com/it-it/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170\n> Now, I don't know z/OS at all, but e.g. if a shellscripts calls a C\n> program there would $? be 1 if we hardcode 1, but 8 on EXIT_FAILURE?\nSee the previous answer\n>\n> We also document for some of these programs that on failure we'll return\n> 1 specifically, not whatever EXIT_FAILURE is.\n>\nSee the previous answer.\nEXIT_FAILURE is always 1 on all popular platforms that git has been\nported to. So you don't even have to change the documentation.\n> These patches also miss cases where we'll set 0 or 1 in a variable, and\n> then exit(ret). See e.g. builtin/rm.c. You just changed the hardcoded\n> exit(1), but missed where we'll return a hardcoded 0 or 1 via a\n> variable.\nMy patch was just meant to introduce some standardization into git\nusing the posix/c standard. No more, No less. As other major projects\ndo, I didn't invent anything.\n\nSYSTEMD COCCI\nhttps://github.com/systemd/systemd/blob/main/coccinelle/exit-0.cocci\n\nLxc cocci\nhttps://github.com/lxc/lxc/blob/master/coccinelle/exit.cocci\n\n>\n> And then there's changing exit(-1) to exit(1). That's existing\n> non-portable use that we really should fix. But I know that you missed a\n> lot there, since I instrumented git.c recently to intercept those for\n> testing (it came up in some thread). We have a lot more than you spotted\n> (and some will error if mapped to 1 IIRC). Most of those also want to\n> exit 128, not 1.\nIn fact, these exit codes are more like shell-specific return codes to\nindicate the \"type\" of the error.\nI repeat that it was not the purpose of this patch to fix any problems\nthat may exist with exit codes. Certainly not using coccinelle. But I\nagree it's a job to do. But not in this patch.\n>\n> Anyway:\n>\n> All in all I think we should just double down on the hardcoding instead,\n> but we should fix the exit(-1) cases, and that's best done with some new\n> GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or whatever.\n>\n> A lot of these codepaths are also paths we should fix, but not because\n> we exit(N) with a hardcoded N, but because we invoke exit(N) there at\n> all. See 338abb0f045 (builtins + test helpers: use return instead of\n> exit() in cmd_*, 2021-06-08) for how some of those should be changed.\n>\n> I think we'd be much better off with something like this in\n> git-compat-util.h:\n>\n>     #ifndef BYPASS_EXIT_SANITY\n>     #ifdef EXIT_SUCCESS\n>     #if EXIT_SUCCESS != 0\n>     #error \"git assumes EXIT_SUCCESS is 0, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk\"\n>     #endif\n>     #endif\n>     #ifdef EXIT_FAILURE\n>     #if EXIT_FAILURE != 0\n>     #error \"git assumes EXIT_FAILRE is 1, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk\"\n>     #endif\n>     #endif\n>     #endif\n>\n> Or *if* we're going to pursue this a twist on that (I really don't think\n> this is worthwhile, just saying) where we'd re-define EXIT_SUCCESS and\n> EXIT_FAILURE to some sentinel values like 123 and 124.\n>\n> Then run our entire test suite and roundtrip-assert that at least we\n> ourselves handled that properly. I.e. whenever run_command() runs and we\n> check for success we check 123, not 0, and a \"normal failure\" is 124,\n> not 1.\n>\n> I know we'll get a *lot of* failures if we do that, so I'm not arguing\n> that we *should*, just that it's rather easy for you to test that and\n> see the resulting test suite dumpster fire.\n>\n> So I don't see how a *partial conversion* is really getting us anywhere,\n> even if we take the pedantic C portability view of things.\n>\n> All we'd have accomplished is a false sense of portability on most OS's,\n> as these will be 0 and 1 anyway. And on any stray odd OS's like z/OS\n> we'll just need to deal with e.g. both 1 and 8 for EXIT_FAILURE, since\n> we *will* miss a lot of cases.\nZ / OS is a false problem. git on z / os runs in a linux partition\nhttps://medium.com/theropod/git-on-z-os-f9234cd2a89a#:~:text=On%20z%2FOS%2C%20Git%20plays,added%20feature\n% 20of% 20codepage% 20translation.\nHowever, calling pedantic a solution widely used in other projects and\nprovided by standards (EXIT_SUCCESS and EXIT_FAILURE are reported by\nthe c/posix standard for generic success / error codes) does not seem\nto me an appropriate term. But YMMV .\n\nThanks\n>\n> 1. https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program\n"},{"id":"451973","messageId":"xmqqsfr8udku.fsf@gitster.g","threadId":"57596","inReplyTo":"220322.86r16unzer.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-23T11:13:05Z","receivedAt":"2022-03-23T11:13:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> We also document for some of these programs that on failure we'll\n> return 1 specifically, not whatever EXIT_FAILURE is.\n\nI view this as a real issue.  EXIT_FAILURE could by happenstance be\ndefined to be the same value on all platforms we care about, but if\nit leaves the possibility that the next major thing will break our\nassumption, I do not see much point in adopting it.  Whole-sale\nrewriting of 0 and 1 to EXIT_SUCCESS and EXIT_FAILURE smells like\nadopting a bad standardization without thinking things through, only\nfor the sake of adopting \"standardization\".\n\n> ... but we should fix the exit(-1) cases, and that's best done\n> with some new GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or\n> whatever.\n\nThat is probably a good #leftoverbit, even a candidate for future\n#microprojects.\n\n> I think we'd be much better off with something like this in\n> git-compat-util.h:\n>\n>     #ifndef BYPASS_EXIT_SANITY\n>     #ifdef EXIT_SUCCESS\n>     #if EXIT_SUCCESS != 0\n>     #error \"git assumes EXIT_SUCCESS is 0, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk\"\n\nThis is not a good idea.  EXIT_SUCCESS does not have to be literally\n0.  It only has to be a value that causes the process to exit with 0\nwhen passed to exit().\n\n>     #endif\n>     #endif\n>     #ifdef EXIT_FAILURE\n>     #if EXIT_FAILURE != 0\n\nI think you meant \"!= 1\".  If we were to take these 41 patches, we\nmust have this hunk, as we want our plumbing tools to be drivable by\nshell scripts, i.e. \n\n\tgit foo ||\n\tcase $? in\n\t1) # generic failure\n\t\t...\n\tesac\n\nand we do not want to be forced to write something like\n\n\t. git-stdlib-util.sh ;# for platform-dependent $EXIT_FAILURE\n\n\t...\n\tgit foo ||\n\tcase $? in\n\t$EXIT_FAILURE) # generic failure\n\t\t...\n\tesac\n\t\ninstead.\n"}]}