All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
@ 2022-03-21 22:54 Elia Pinto
  2022-03-21 22:54 ` [PATCH 01/41] archive.c: " Elia Pinto
                   ` (42 more replies)
  0 siblings, 43 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

EXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but
not everywhere. Also in branch.c there is a returns exit(-1), ie 255, when
exit(1) might be more appropriate.

T$his patch series adds a coccinelle semantic patch exit.cocci in
contrib/coccinelle to rewrite:
- exit(0) in exit(EXIT_SUCCESS)
- exit(1) in exit(EXIT_FAILURE)
- exit(-1) in exit(EXIT_FAILURE)

The patch treats the status code in _exit equivalently.



Elia Pinto (41):
  archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or
    EXIT_FAILURE exit status
  help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
    status
  update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
    status
  obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or
    EXIT_FAILURE exit status
  git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
    exit status
  daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
    status
  parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
    status
  path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
    status
  test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
    exit status
  test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or
    EXIT_FAILURE exit status
  upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status

 archive.c                                     |  2 +-
 branch.c                                      |  4 ++--
 builtin/am.c                                  |  4 ++--
 builtin/blame.c                               |  2 +-
 builtin/commit.c                              | 10 ++++----
 builtin/credential-cache--daemon.c            |  2 +-
 builtin/help.c                                |  2 +-
 builtin/init-db.c                             |  2 +-
 builtin/mailsplit.c                           |  2 +-
 builtin/merge-index.c                         |  2 +-
 builtin/merge.c                               |  4 ++--
 builtin/pull.c                                |  2 +-
 builtin/rebase.c                              | 12 +++++-----
 builtin/remote-ext.c                          |  2 +-
 builtin/rev-parse.c                           |  2 +-
 builtin/rm.c                                  |  2 +-
 builtin/shortlog.c                            |  2 +-
 builtin/show-branch.c                         |  4 ++--
 builtin/stash.c                               |  2 +-
 builtin/tag.c                                 |  2 +-
 builtin/unpack-objects.c                      |  6 ++---
 builtin/update-index.c                        |  4 ++--
 compat/obstack.c                              |  2 +-
 contrib/coccinelle/exit.cocci                 | 24 +++++++++++++++++++
 .../osxkeychain/git-credential-osxkeychain.c  |  4 ++--
 .../wincred/git-credential-wincred.c          |  2 +-
 daemon.c                                      |  2 +-
 git.c                                         | 14 +++++------
 help.c                                        |  8 +++----
 http-backend.c                                | 12 +++++-----
 parse-options.c                               |  2 +-
 path.c                                        |  2 +-
 remote-curl.c                                 |  2 +-
 run-command.c                                 |  2 +-
 setup.c                                       |  2 +-
 shell.c                                       |  2 +-
 t/helper/test-json-writer.c                   |  2 +-
 t/helper/test-reach.c                         |  2 +-
 t/helper/test-submodule-config.c              |  2 +-
 t/helper/test-submodule-nested-repo-config.c  |  2 +-
 upload-pack.c                                 |  2 +-
 41 files changed, 95 insertions(+), 71 deletions(-)
 create mode 100644 contrib/coccinelle/exit.cocci

-- 
2.35.1


^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 01/41] archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 02/41] branch.c: " Elia Pinto
                   ` (41 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 archive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/archive.c b/archive.c
index e29d0e00f6..c8c1df59de 100644
--- a/archive.c
+++ b/archive.c
@@ -590,7 +590,7 @@ static int parse_archive_args(int argc, const char **argv,
 		for (i = 0; i < nr_archivers; i++)
 			if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)
 				printf("%s\n", archivers[i]->name);
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 
 	if (!format && name_hint)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 02/41] branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
  2022-03-21 22:54 ` [PATCH 01/41] archive.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 03/41] am.c: " Elia Pinto
                   ` (40 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 branch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/branch.c b/branch.c
index 6b31df539a..7a28ccdbd2 100644
--- a/branch.c
+++ b/branch.c
@@ -260,7 +260,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
 		string_list_append(tracking.srcs, orig_ref);
 	if (install_branch_config_multiple_remotes(config_flags, new_ref,
 				tracking.remote, tracking.srcs) < 0)
-		exit(-1);
+		exit(EXIT_FAILURE);
 
 cleanup:
 	string_list_clear(&tracking_srcs, 0);
@@ -388,7 +388,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
 			if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
 				error(_(upstream_missing), start_name);
 				advise(_(upstream_advice));
-				exit(1);
+				exit(EXIT_FAILURE);
 			}
 			die(_(upstream_missing), start_name);
 		}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 03/41] am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
  2022-03-21 22:54 ` [PATCH 01/41] archive.c: " Elia Pinto
  2022-03-21 22:54 ` [PATCH 02/41] branch.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 04/41] blame.c: " Elia Pinto
                   ` (39 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/am.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 0f4111bafa..ac74bce555 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1638,7 +1638,7 @@ static void do_commit(const struct am_state *state)
 	struct strbuf sb = STRBUF_INIT;
 
 	if (run_hooks("pre-applypatch"))
-		exit(1);
+		exit(EXIT_FAILURE);
 
 	if (write_cache_as_tree(&tree, 0, NULL))
 		die(_("git write-tree failed to write a tree"));
@@ -1841,7 +1841,7 @@ static void am_run(struct am_state *state, int resume)
 		}
 
 		if (run_applypatch_msg_hook(state))
-			exit(1);
+			exit(EXIT_FAILURE);
 		if (to_keep)
 			goto commit;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 04/41] blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (2 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 03/41] am.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 05/41] commit.c: " Elia Pinto
                   ` (38 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/blame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 8d15b68afc..9866e6c911 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -921,7 +921,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		case PARSE_OPT_ERROR:
 			exit(129);
 		case PARSE_OPT_COMPLETE:
-			exit(0);
+			exit(EXIT_SUCCESS);
 		case PARSE_OPT_DONE:
 			if (ctx.argv[0])
 				dashdash_pos = ctx.cpidx;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 05/41] commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (3 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 04/41] blame.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 06/41] credential-cache--daemon.c: " Elia Pinto
                   ` (37 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/commit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 009a1de0a3..13af49fdd2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -496,7 +496,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
 	}
 
 	if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
-		exit(1);
+		exit(EXIT_FAILURE);
 
 	discard_cache();
 	if (read_cache() < 0)
@@ -1081,7 +1081,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		strvec_clear(&env);
 	}
@@ -1785,12 +1785,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (message_is_empty(&sb, cleanup_mode) && !allow_empty_message) {
 		rollback_index_files();
 		fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	if (template_untouched(&sb, template_file, cleanup_mode) && !allow_empty_message) {
 		rollback_index_files();
 		fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	if (fixup_message && starts_with(sb.buf, "amend! ") &&
@@ -1801,7 +1801,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		if (message_is_empty(&body, cleanup_mode)) {
 			rollback_index_files();
 			fprintf(stderr, _("Aborting commit due to empty commit message body.\n"));
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		strbuf_release(&body);
 	}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 06/41] credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (4 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 05/41] commit.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 07/41] help.c: " Elia Pinto
                   ` (36 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/credential-cache--daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 4c6c89ab0d..83441cad5e 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -138,7 +138,7 @@ static void serve_one_client(FILE *in, FILE *out)
 		 * process actually ends, which closes the socket and gives
 		 * them EOF.
 		 */
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 	else if (!strcmp(action.buf, "erase"))
 		remove_credential(&c);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 07/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (5 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 06/41] credential-cache--daemon.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 08/41] init-db.c: " Elia Pinto
                   ` (35 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/help.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/help.c b/builtin/help.c
index 222f994f86..e5ca9d4a6e 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -554,7 +554,7 @@ static const char *check_git_cmd(const char* cmd)
 		if (!exclude_guides || alias[0] == '!') {
 			printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
 			free(alias);
-			exit(0);
+			exit(EXIT_SUCCESS);
 		}
 		/*
 		 * Otherwise, we pretend that the command was "git
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 08/41] init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (6 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 07/41] help.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 09/41] mailsplit.c: " Elia Pinto
                   ` (34 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/init-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 546f9c595e..d8ddc04b96 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -264,7 +264,7 @@ static int create_default_files(const char *template_path,
 			    initial_branch);
 
 		if (create_symref("HEAD", ref, NULL) < 0)
-			exit(1);
+			exit(EXIT_FAILURE);
 		free(ref);
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 09/41] mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (7 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 08/41] init-db.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 10/41] merge-index.c: " Elia Pinto
                   ` (33 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/mailsplit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 7baef30569..9127ac49e3 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -73,7 +73,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
 
 	if (is_bare && !allow_bare) {
 		fprintf(stderr, "corrupt mailbox\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	fd = xopen(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
 	output = xfdopen(fd, "w");
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 10/41] merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (8 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 09/41] mailsplit.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 11/41] merge.c: " Elia Pinto
                   ` (32 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/merge-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index c0383fe9df..efa7ceaa35 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -37,7 +37,7 @@ static int merge_entry(int pos, const char *path)
 		else {
 			if (!quiet)
 				die("merge program failed");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}
 	return found;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 11/41] merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (9 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 10/41] merge-index.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 12/41] pull.c: " Elia Pinto
                   ` (31 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/merge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index f178f5a3ee..3bb6f902f0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -209,7 +209,7 @@ static struct strategy *get_strategy(const char *name)
 				fprintf(stderr, " %s", other_cmds.names[i]->name);
 			fprintf(stderr, ".\n");
 		}
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	CALLOC_ARRAY(ret, 1);
@@ -824,7 +824,7 @@ static void abort_commit(struct commit_list *remoteheads, const char *err_msg)
 	fprintf(stderr,
 		_("Not committing merge; use 'git commit' to complete the merge.\n"));
 	write_merge_state(remoteheads);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 static const char merge_editor_comment[] =
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 12/41] pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (10 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 11/41] merge.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 13/41] rebase.c: " Elia Pinto
                   ` (30 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/pull.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/pull.c b/builtin/pull.c
index 4d667abc19..3b16e891ea 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -489,7 +489,7 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs
 		fprintf_ln(stderr, _("Your configuration specifies to merge with the ref '%s'\n"
 			"from the remote, but no such ref was fetched."),
 			*curr_branch->merge_name);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 /**
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 13/41] rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (11 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 12/41] pull.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 14/41] remote-ext.c: " Elia Pinto
                   ` (29 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/rebase.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/rebase.c b/builtin/rebase.c
index b29ad2b65e..cafacc87f8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -988,7 +988,7 @@ static void NORETURN error_on_missing_default_upstream(void)
 			 "\n"),
 		       remote, current_branch->name);
 	}
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 static void set_reflog_action(struct rebase_options *options)
@@ -1266,10 +1266,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		if (has_unstaged_changes(the_repository, 1)) {
 			puts(_("You must edit all merge conflicts and then\n"
 			       "mark them as resolved using git add"));
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		if (read_basic_state(&options))
-			exit(1);
+			exit(EXIT_FAILURE);
 		goto run_rebase;
 	}
 	case ACTION_SKIP: {
@@ -1285,7 +1285,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			die(_("could not discard worktree changes"));
 		remove_branch_state(the_repository, 0);
 		if (read_basic_state(&options))
-			exit(1);
+			exit(EXIT_FAILURE);
 		goto run_rebase;
 	}
 	case ACTION_ABORT: {
@@ -1297,7 +1297,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		string_list_clear(&merge_rr, 1);
 
 		if (read_basic_state(&options))
-			exit(1);
+			exit(EXIT_FAILURE);
 		ropts.oid = &options.orig_head;
 		ropts.branch = options.head_name;
 		ropts.flags = RESET_HEAD_HARD;
@@ -1388,7 +1388,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 
 	for (i = 0; i < exec.nr; i++)
 		if (check_exec_cmd(exec.items[i].string))
-			exit(1);
+			exit(EXIT_FAILURE);
 
 	if (!(options.flags & REBASE_NO_QUIET))
 		strvec_push(&options.git_am_opts, "-q");
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 14/41] remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (12 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 13/41] rebase.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 15/41] rev-parse.c: " Elia Pinto
                   ` (28 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/remote-ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/remote-ext.c b/builtin/remote-ext.c
index fd3538d4f0..3b32d68ed5 100644
--- a/builtin/remote-ext.c
+++ b/builtin/remote-ext.c
@@ -172,7 +172,7 @@ static int command_loop(const char *child)
 		if (!fgets(buffer, MAXCOMMAND - 1, stdin)) {
 			if (ferror(stdin))
 				die("Command input error");
-			exit(0);
+			exit(EXIT_SUCCESS);
 		}
 		/* Strip end of line characters. */
 		i = strlen(buffer);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 15/41] rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (13 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 14/41] remote-ext.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 16/41] rm.c: " Elia Pinto
                   ` (27 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/rev-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8480a59f57..e313b64fcd 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -543,7 +543,7 @@ static int cmd_sq_quote(int argc, const char **argv)
 static void die_no_single_rev(int quiet)
 {
 	if (quiet)
-		exit(1);
+		exit(EXIT_FAILURE);
 	else
 		die(_("Needed a single revision"));
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 16/41] rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (14 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 15/41] rev-parse.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:54 ` [PATCH 17/41] shortlog.c: " Elia Pinto
                   ` (26 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/rm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rm.c b/builtin/rm.c
index 84a935a16e..4c4546bad8 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -369,7 +369,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 		if (get_oid("HEAD", &oid))
 			oidclr(&oid);
 		if (check_local_mod(&oid, index_only))
-			exit(1);
+			exit(EXIT_FAILURE);
 	}
 
 	/*
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 17/41] shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (15 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 16/41] rm.c: " Elia Pinto
@ 2022-03-21 22:54 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 18/41] show-branch.c: " Elia Pinto
                   ` (25 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:54 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/shortlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 26c5c0cf93..0763c94df6 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -381,7 +381,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 		case PARSE_OPT_ERROR:
 			exit(129);
 		case PARSE_OPT_COMPLETE:
-			exit(0);
+			exit(EXIT_SUCCESS);
 		case PARSE_OPT_DONE:
 			goto parse_done;
 		}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 18/41] show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (16 preceding siblings ...)
  2022-03-21 22:54 ` [PATCH 17/41] shortlog.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 19/41] stash.c: " Elia Pinto
                   ` (24 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/show-branch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 330b0553b9..04a99aa7b2 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -820,7 +820,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
 	if (!ref_name_cnt) {
 		fprintf(stderr, "No revs to be shown.\n");
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 
 	for (num_rev = 0; ref_name[num_rev]; num_rev++) {
@@ -898,7 +898,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		}
 	}
 	if (extra < 0)
-		exit(0);
+		exit(EXIT_SUCCESS);
 
 	/* Sort topologically */
 	sort_in_topological_order(&seen, sort_order);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 19/41] stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (17 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 18/41] show-branch.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 20/41] tag.c: " Elia Pinto
                   ` (23 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/stash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/stash.c b/builtin/stash.c
index 0c7b6a9588..9315ff74ce 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -656,7 +656,7 @@ static void assert_stash_ref(struct stash_info *info)
 	if (!info->is_stash_ref) {
 		error(_("'%s' is not a stash reference"), info->revision.buf);
 		free_stash_info(info);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 20/41] tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (18 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 19/41] stash.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 21/41] unpack-objects.c: " Elia Pinto
                   ` (22 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/tag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index e5a8f85693..55a808873c 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -315,7 +315,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
 		if (launch_editor(path, buf, NULL)) {
 			fprintf(stderr,
 			_("Please supply the message using either -m or -F option.\n"));
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 21/41] unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (19 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 20/41] tag.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 22/41] update-index.c: " Elia Pinto
                   ` (21 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/unpack-objects.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index dbeb0680a5..d5838bfad1 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -118,7 +118,7 @@ static void *get_data(unsigned long size)
 			error("inflate returned %d", ret);
 			FREE_AND_NULL(buf);
 			if (!recover)
-				exit(1);
+				exit(EXIT_FAILURE);
 			has_errors = 1;
 			break;
 		}
@@ -435,7 +435,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 		error("failed to read delta-pack base object %s",
 		      oid_to_hex(&base_oid));
 		if (!recover)
-			exit(1);
+			exit(EXIT_FAILURE);
 		has_errors = 1;
 		return;
 	}
@@ -482,7 +482,7 @@ static void unpack_one(unsigned nr)
 		has_errors = 1;
 		if (recover)
 			return;
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 22/41] update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (20 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 21/41] unpack-objects.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 23/41] obstack.c: " Elia Pinto
                   ` (20 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/update-index.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index aafe7eeac2..9e4c15e846 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -699,7 +699,7 @@ static void read_head_pointers(void)
 		die("No HEAD -- no initial commit yet?");
 	if (read_ref("MERGE_HEAD", &merge_head_oid)) {
 		fprintf(stderr, "Not in the middle of a merge.\n");
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 }
 
@@ -1127,7 +1127,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 		case PARSE_OPT_ERROR:
 			exit(129);
 		case PARSE_OPT_COMPLETE:
-			exit(0);
+			exit(EXIT_SUCCESS);
 		case PARSE_OPT_NON_OPTION:
 		case PARSE_OPT_DONE:
 		{
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 23/41] obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (21 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 22/41] update-index.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 24/41] git-credential-osxkeychain.c: " Elia Pinto
                   ` (19 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 compat/obstack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/obstack.c b/compat/obstack.c
index 27cd5c1ea1..e8641816f7 100644
--- a/compat/obstack.c
+++ b/compat/obstack.c
@@ -407,7 +407,7 @@ print_and_abort (void)
 # else
   fprintf (stderr, "%s\n", _("memory exhausted"));
 # endif
-  exit (1);
+  exit(EXIT_FAILURE);
 }
 
 #endif	/* !ELIDE_CODE */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 24/41] git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (22 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 23/41] obstack.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 25/41] git-credential-wincred.c: " Elia Pinto
                   ` (18 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 contrib/credential/osxkeychain/git-credential-osxkeychain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/credential/osxkeychain/git-credential-osxkeychain.c b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
index 0b44a9b7cc..169cbff821 100644
--- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c
+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
@@ -19,7 +19,7 @@ static void die(const char *err, ...)
 	vsnprintf(msg, sizeof(msg), err, params);
 	fprintf(stderr, "%s\n", msg);
 	va_end(params);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 static void *xstrdup(const char *s1)
@@ -143,7 +143,7 @@ static void read_credential(void)
 			else if (!strcmp(v, "smtp"))
 				protocol = kSecProtocolTypeSMTP;
 			else /* we don't yet handle other protocols */
-				exit(0);
+				exit(EXIT_SUCCESS);
 		}
 		else if (!strcmp(buf, "host")) {
 			char *colon = strchr(v, ':');
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 25/41] git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (23 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 24/41] git-credential-osxkeychain.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 26/41] daemon.c: " Elia Pinto
                   ` (17 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 contrib/credential/wincred/git-credential-wincred.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
index 5091048f9c..25028cd39c 100644
--- a/contrib/credential/wincred/git-credential-wincred.c
+++ b/contrib/credential/wincred/git-credential-wincred.c
@@ -20,7 +20,7 @@ static void die(const char *err, ...)
 	vsnprintf(msg, sizeof(msg), err, params);
 	fprintf(stderr, "%s\n", msg);
 	va_end(params);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 static void *xmalloc(size_t size)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 26/41] daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (24 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 25/41] git-credential-wincred.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 27/41] git.c: " Elia Pinto
                   ` (16 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon.c b/daemon.c
index 94a5b8a364..cd07ae1643 100644
--- a/daemon.c
+++ b/daemon.c
@@ -134,7 +134,7 @@ static void loginfo(const char *err, ...)
 static void NORETURN daemon_die(const char *err, va_list params)
 {
 	logreport(LOG_ERR, err, params);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 struct expand_path_context {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 27/41] git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (25 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 26/41] daemon.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 28/41] help.c: " Elia Pinto
                   ` (15 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 git.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/git.c b/git.c
index a25940d72e..7b75e6e720 100644
--- a/git.c
+++ b/git.c
@@ -158,20 +158,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			else {
 				puts(git_exec_path());
 				trace2_cmd_name("_query_");
-				exit(0);
+				exit(EXIT_SUCCESS);
 			}
 		} else if (!strcmp(cmd, "--html-path")) {
 			puts(system_path(GIT_HTML_PATH));
 			trace2_cmd_name("_query_");
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "--man-path")) {
 			puts(system_path(GIT_MAN_PATH));
 			trace2_cmd_name("_query_");
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "--info-path")) {
 			puts(system_path(GIT_INFO_PATH));
 			trace2_cmd_name("_query_");
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			use_pager = 1;
 		} else if (!strcmp(cmd, "-P") || !strcmp(cmd, "--no-pager")) {
@@ -318,7 +318,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				for (i = 0; i < list.nr; i++)
 					printf("%s ", list.items[i].string);
 				string_list_clear(&list, 0);
-				exit(0);
+				exit(EXIT_SUCCESS);
 			} else {
 				exit(list_cmds(cmd));
 			}
@@ -900,7 +900,7 @@ int cmd_main(int argc, const char **argv)
 		printf(_("usage: %s\n\n"), git_usage_string);
 		list_common_cmds_help();
 		printf("\n%s\n", _(git_more_info_string));
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	cmd = argv[0];
 
@@ -920,7 +920,7 @@ int cmd_main(int argc, const char **argv)
 			fprintf(stderr, _("expansion of alias '%s' failed; "
 					  "'%s' is not a git command\n"),
 				cmd, argv[0]);
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		if (!done_help) {
 			cmd = argv[0] = help_unknown_cmd(cmd);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 28/41] help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (26 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 27/41] git.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 29/41] http-backend.c: " Elia Pinto
                   ` (14 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

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

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


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 29/41] http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (27 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 28/41] help.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 30/41] parse-options.c: " Elia Pinto
                   ` (13 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 http-backend.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/http-backend.c b/http-backend.c
index 81a7229ece..932d92d70b 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -137,7 +137,7 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)
 	if (err && *err)
 		vfprintf(stderr, err, params);
 	va_end(params);
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 __attribute__((format (printf, 2, 3)))
@@ -153,7 +153,7 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)
 	if (err && *err)
 		vfprintf(stderr, err, params);
 	va_end(params);
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 static void select_getanyfile(struct strbuf *hdr)
@@ -488,7 +488,7 @@ static void run_service(const char **argv, int buffer_input)
 	cld.clean_on_exit = 1;
 	cld.wait_after_clean = 1;
 	if (start_command(&cld))
-		exit(1);
+		exit(EXIT_FAILURE);
 
 	close(1);
 	if (gzipped_request)
@@ -501,7 +501,7 @@ static void run_service(const char **argv, int buffer_input)
 		close(0);
 
 	if (finish_command(&cld))
-		exit(1);
+		exit(EXIT_FAILURE);
 }
 
 static int show_text_ref(const char *name, const struct object_id *oid,
@@ -628,7 +628,7 @@ static void check_content_type(struct strbuf *hdr, const char *accepted_type)
 			"Expected POST with Content-Type '%s',"
 			" but received '%s' instead.\n",
 			accepted_type, actual_type);
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 }
 
@@ -668,7 +668,7 @@ static NORETURN void die_webcgi(const char *err, va_list params)
 		hdr_nocache(&hdr);
 		end_headers(&hdr);
 	}
-	exit(0); /* we successfully reported a failure ;-) */
+	exit(EXIT_SUCCESS); /* we successfully reported a failure ;-) */
 }
 
 static int die_webcgi_recursing(void)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 30/41] parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (28 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 29/41] http-backend.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 31/41] path.c: " Elia Pinto
                   ` (12 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 parse-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-options.c b/parse-options.c
index 6e57744fd2..0ee82fb760 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -883,7 +883,7 @@ int parse_options(int argc, const char **argv,
 	case PARSE_OPT_ERROR:
 		exit(129);
 	case PARSE_OPT_COMPLETE:
-		exit(0);
+		exit(EXIT_SUCCESS);
 	case PARSE_OPT_NON_OPTION:
 	case PARSE_OPT_DONE:
 		break;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 31/41] path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (29 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 30/41] parse-options.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 32/41] remote-curl.c: " Elia Pinto
                   ` (11 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/path.c b/path.c
index 2c895471d9..6639bab7b4 100644
--- a/path.c
+++ b/path.c
@@ -915,7 +915,7 @@ void safe_create_dir(const char *dir, int share)
 	if (mkdir(dir, 0777) < 0) {
 		if (errno != EEXIST) {
 			perror(dir);
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 32/41] remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (30 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 31/41] path.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 33/41] run-command.c: " Elia Pinto
                   ` (10 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 remote-curl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/remote-curl.c b/remote-curl.c
index ff44f41011..da61168c6f 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1063,7 +1063,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
 	client.git_cmd = 1;
 	strvec_pushv(&client.args, client_argv);
 	if (start_command(&client))
-		exit(1);
+		exit(EXIT_FAILURE);
 	write_or_die(client.in, preamble->buf, preamble->len);
 	if (heads)
 		write_or_die(client.in, heads->buf, heads->len);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 33/41] run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (31 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 32/41] remote-curl.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 34/41] setup.c: " Elia Pinto
                   ` (9 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 run-command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run-command.c b/run-command.c
index a8501e38ce..5a5d865716 100644
--- a/run-command.c
+++ b/run-command.c
@@ -319,7 +319,7 @@ static void child_die(enum child_errcode err)
 
 	/* write(2) on buf smaller than PIPE_BUF (min 512) is atomic: */
 	xwrite(child_notifier, &buf, sizeof(buf));
-	_exit(1);
+	_exit(EXIT_FAILURE);
 }
 
 static void child_dup2(int fd, int to)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 34/41] setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (32 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 33/41] run-command.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 35/41] shell.c: " Elia Pinto
                   ` (8 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.c b/setup.c
index 04ce33cdcd..f5cb3f30a4 100644
--- a/setup.c
+++ b/setup.c
@@ -1508,7 +1508,7 @@ int daemonize(void)
 		case -1:
 			die_errno(_("fork failed"));
 		default:
-			exit(0);
+			exit(EXIT_SUCCESS);
 	}
 	if (setsid() == -1)
 		die_errno(_("setsid failed"));
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 35/41] shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (33 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 34/41] setup.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 36/41] test-json-writer.c: " Elia Pinto
                   ` (7 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell.c b/shell.c
index 811e13b9c9..d2d1718e9c 100644
--- a/shell.c
+++ b/shell.c
@@ -146,7 +146,7 @@ int cmd_main(int argc, const char **argv)
 			    "and have read and execute access.");
 		}
 		run_shell();
-		exit(0);
+		exit(EXIT_SUCCESS);
 	} else if (argc != 3 || strcmp(argv[1], "-c")) {
 		/*
 		 * We do not accept any other modes except "-c" followed by
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 36/41] test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (34 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 35/41] shell.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 37/41] test-reach.c: " Elia Pinto
                   ` (6 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/helper/test-json-writer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/helper/test-json-writer.c b/t/helper/test-json-writer.c
index 37c452535f..61c5a3dac1 100644
--- a/t/helper/test-json-writer.c
+++ b/t/helper/test-json-writer.c
@@ -322,7 +322,7 @@ static void cmp(const char *test, const struct json_writer *jw, const char *exp)
 
 	printf("error[%s]: observed '%s' expected '%s'\n",
 	       test, jw->json.buf, exp);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 #define t(v) do { make_##v(0); cmp(#v, &v, expect_##v); } while (0)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 37/41] test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (35 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 36/41] test-json-writer.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 38/41] test-submodule-config.c: " Elia Pinto
                   ` (5 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/helper/test-reach.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 2f65c7f6a5..b5c4cbf6cc 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -40,7 +40,7 @@ int cmd__reach(int ac, const char **av)
 	setup_git_directory();
 
 	if (ac < 2)
-		exit(1);
+		exit(EXIT_FAILURE);
 
 	A = B = NULL;
 	X = Y = NULL;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 38/41] test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (36 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 37/41] test-reach.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 39/41] test-submodule-nested-repo-config.c: " Elia Pinto
                   ` (4 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/helper/test-submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index e2692746df..d4608300d5 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -8,7 +8,7 @@ static void die_usage(int argc, const char **argv, const char *msg)
 {
 	fprintf(stderr, "%s\n", msg);
 	fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 int cmd__submodule_config(int argc, const char **argv)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 39/41] test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (37 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 38/41] test-submodule-config.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 40/41] upload-pack.c: " Elia Pinto
                   ` (3 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/helper/test-submodule-nested-repo-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index dc1c14bde3..e32b68ceac 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -5,7 +5,7 @@ static void die_usage(const char **argv, const char *msg)
 {
 	fprintf(stderr, "%s\n", msg);
 	fprintf(stderr, "Usage: %s <submodulepath> <config name>\n", argv[0]);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 int cmd__submodule_nested_repo_config(int argc, const char **argv)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 40/41] upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (38 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 39/41] test-submodule-nested-repo-config.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-21 22:55 ` [PATCH 41/41] exit.cocci: " Elia Pinto
                   ` (2 subsequent siblings)
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/upload-pack.c b/upload-pack.c
index 3a851b3606..1683d80c4d 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -543,7 +543,7 @@ static int get_common_commits(struct upload_pack_data *data,
 				return 0;
 			}
 			if (data->stateless_rpc)
-				exit(0);
+				exit(EXIT_SUCCESS);
 			got_common = 0;
 			got_other = 0;
 			continue;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 41/41] exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (39 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 40/41] upload-pack.c: " Elia Pinto
@ 2022-03-21 22:55 ` Elia Pinto
  2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
  2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
  42 siblings, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-21 22:55 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

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

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

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 contrib/coccinelle/exit.cocci | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 contrib/coccinelle/exit.cocci

diff --git a/contrib/coccinelle/exit.cocci b/contrib/coccinelle/exit.cocci
new file mode 100644
index 0000000000..ea5c243061
--- /dev/null
+++ b/contrib/coccinelle/exit.cocci
@@ -0,0 +1,24 @@
+@@
+@@
+- exit(0);
++ exit(EXIT_SUCCESS);
+@@
+@@
+- _exit(0);
++ _exit(EXIT_SUCCESS);
+@@
+@@
+- exit(1);
++ exit(EXIT_FAILURE);
+@@
+@@
+- _exit(1);
++ _exit(EXIT_FAILURE);
+@@
+@@
+- exit(-1);
++ exit(EXIT_FAILURE);
+@@
+@@
+- _exit(-1);
++ _exit(EXIT_FAILURE);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (40 preceding siblings ...)
  2022-03-21 22:55 ` [PATCH 41/41] exit.cocci: " Elia Pinto
@ 2022-03-22  6:49 ` Bagas Sanjaya
  2022-03-22  8:45   ` Elia Pinto
  2022-03-22 11:21   ` Bagas Sanjaya
  2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
  42 siblings, 2 replies; 48+ messages in thread
From: Bagas Sanjaya @ 2022-03-22  6:49 UTC (permalink / raw)
  To: Elia Pinto, git

On 22/03/22 05.54, Elia Pinto wrote:
> Elia Pinto (41):
>    archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or
>      EXIT_FAILURE exit status
>    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
>      status
>    update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
>      status
>    obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or
>      EXIT_FAILURE exit status
>    git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
>      exit status
>    daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
>      status
>    parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
>      status
>    path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
>      status
>    test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
>      exit status
>    test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or
>      EXIT_FAILURE exit status
>    upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
>    exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> 

I think we should only have 2 patches in this series: the first is to replace
with EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
                   ` (41 preceding siblings ...)
  2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
@ 2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
  2022-03-22 17:47   ` Elia Pinto
  2022-03-23 11:13   ` Junio C Hamano
  42 siblings, 2 replies; 48+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-03-22  8:26 UTC (permalink / raw)
  To: Elia Pinto; +Cc: git


On Mon, Mar 21 2022, Elia Pinto wrote:

> EXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but
> not everywhere. Also in branch.c there is a returns exit(-1), ie 255, when
> exit(1) might be more appropriate.

On existing use: That's quite the overstatement :)

We use EXIT_{SUCCESS,FAILURE} only in:

 * contrib/credential/ code.
 * sh-i18n--envsubst.c
 * EXIT_FAILURE in one stray test helper

So out of "real git" that users see only sh-i18n--envsubst.c will ever
run by default, and the reason it uses these is because it's as-is
imported GNU code.

I'd think if anything we'd be better off doing this the other way
around, and always hardcoding either 0 or 1.

I'm not aware of any platform where EXIT_SUCCESS is non-zero, although
that's probably left open by the C standard.

For EXIT_FAILURE there *are* platforms where it's non-1, but I don't
know if we're ported to any of those, e.g. on z/OS it's[1]:

    The argument status can have a value from 0 to 255 inclusive or be
    one of the macros EXIT_SUCCESS or EXIT_FAILURE. The value of
    EXIT_SUCCESS is defined in stdlib.h as 0; the value of EXIT_FAILURE
    is 8.

Now, I don't know z/OS at all, but e.g. if a shellscripts calls a C
program there would $? be 1 if we hardcode 1, but 8 on EXIT_FAILURE?

We also document for some of these programs that on failure we'll return
1 specifically, not whatever EXIT_FAILURE is.

These patches also miss cases where we'll set 0 or 1 in a variable, and
then exit(ret). See e.g. builtin/rm.c. You just changed the hardcoded
exit(1), but missed where we'll return a hardcoded 0 or 1 via a
variable.

And then there's changing exit(-1) to exit(1). That's existing
non-portable use that we really should fix. But I know that you missed a
lot there, since I instrumented git.c recently to intercept those for
testing (it came up in some thread). We have a lot more than you spotted
(and some will error if mapped to 1 IIRC). Most of those also want to
exit 128, not 1.

Anyway:

All in all I think we should just double down on the hardcoding instead,
but we should fix the exit(-1) cases, and that's best done with some new
GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or whatever.

A lot of these codepaths are also paths we should fix, but not because
we exit(N) with a hardcoded N, but because we invoke exit(N) there at
all. See 338abb0f045 (builtins + test helpers: use return instead of
exit() in cmd_*, 2021-06-08) for how some of those should be changed.

I think we'd be much better off with something like this in
git-compat-util.h:

    #ifndef BYPASS_EXIT_SANITY
    #ifdef EXIT_SUCCESS
    #if EXIT_SUCCESS != 0
    #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"
    #endif
    #endif
    #ifdef EXIT_FAILURE
    #if EXIT_FAILURE != 0
    #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"
    #endif
    #endif
    #endif

Or *if* we're going to pursue this a twist on that (I really don't think
this is worthwhile, just saying) where we'd re-define EXIT_SUCCESS and
EXIT_FAILURE to some sentinel values like 123 and 124.

Then run our entire test suite and roundtrip-assert that at least we
ourselves handled that properly. I.e. whenever run_command() runs and we
check for success we check 123, not 0, and a "normal failure" is 124,
not 1.

I know we'll get a *lot of* failures if we do that, so I'm not arguing
that we *should*, just that it's rather easy for you to test that and
see the resulting test suite dumpster fire.

So I don't see how a *partial conversion* is really getting us anywhere,
even if we take the pedantic C portability view of things.

All we'd have accomplished is a false sense of portability on most OS's,
as these will be 0 and 1 anyway. And on any stray odd OS's like z/OS
we'll just need to deal with e.g. both 1 and 8 for EXIT_FAILURE, since
we *will* miss a lot of cases.

1. https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
@ 2022-03-22  8:45   ` Elia Pinto
  2022-03-22 11:21   ` Bagas Sanjaya
  1 sibling, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-22  8:45 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: git

Il giorno mar 22 mar 2022 alle ore 07:49 Bagas Sanjaya
<bagasdotme@gmail.com> ha scritto:
>
> On 22/03/22 05.54, Elia Pinto wrote:
> > Elia Pinto (41):
> >    archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or
> >      EXIT_FAILURE exit status
> >    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
> >      status
> >    update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
> >      status
> >    obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or
> >      EXIT_FAILURE exit status
> >    git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
> >      exit status
> >    daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
> >      status
> >    parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
> >      status
> >    path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit
> >      status
> >    test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE
> >      exit status
> >    test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or
> >      EXIT_FAILURE exit status
> >    upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >    exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
> >
>
> I think we should only have 2 patches in this series: the first is to replace
> with EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.
Salutations. You can help me ? I'm having trouble continuing the
course and haven't had any answers yet. Or if you can help me figure
out who to contact. Thank you for your cooperation.

Thank you. But there are many sources that include both of them, the
choice would then be arbitrary. However, I follow the various reviews.
> --
> An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
  2022-03-22  8:45   ` Elia Pinto
@ 2022-03-22 11:21   ` Bagas Sanjaya
  1 sibling, 0 replies; 48+ messages in thread
From: Bagas Sanjaya @ 2022-03-22 11:21 UTC (permalink / raw)
  To: Elia Pinto, git

On 22/03/22 13.49, Bagas Sanjaya wrote:
> I think we should only have 2 patches in this series: the first is to replace
> with EXIT_SUCCESS, and second is to replace with EXIT_FAILURE.
> 

Oops, I missed [PATCH 00/41] that adds cocci semantics. So actually we should
have 3 patches...

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
@ 2022-03-22 17:47   ` Elia Pinto
  2022-03-23 11:13   ` Junio C Hamano
  1 sibling, 0 replies; 48+ messages in thread
From: Elia Pinto @ 2022-03-22 17:47 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git

Il giorno mar 22 mar 2022 alle ore 09:51 Ævar Arnfjörð Bjarmason
<avarab@gmail.com> ha scritto:
>

First of all, thanks for the review.

>
> On Mon, Mar 21 2022, Elia Pinto wrote:
>
> > EXIT_SUCCESS or EXIT_FAILURE are already used in some functions in git but
> > not everywhere. Also in branch.c there is a returns exit(-1), ie 255, when
> > exit(1) might be more appropriate.
>
> On existing use: That's quite the overstatement :)
>
It was not a quantitative assessment. I just wanted to point out that
the macros stdlib.h EXIT_SUCCESS and EXIT_FAILURE already exist in the
git code.
> We use EXIT_{SUCCESS,FAILURE} only in:
>
>  * contrib/credential/ code.
>  * sh-i18n--envsubst.c
>  * EXIT_FAILURE in one stray test helper
>
> So out of "real git" that users see only sh-i18n--envsubst.c will ever
> run by default, and the reason it uses these is because it's as-is
> imported GNU code.
>
> I'd think if anything we'd be better off doing this the other way
> around, and always hardcoding either 0 or 1.
>
> I'm not aware of any platform where EXIT_SUCCESS is non-zero, although
> that's probably left open by the C standard.
No. It is defined be 0
https://pubs.opengroup.org/onlinepubs/009604599/basedefs/stdlib.h.html
>
> For EXIT_FAILURE there *are* platforms where it's non-1, but I don't
> know if we're ported to any of those, e.g. on z/OS it's[1]:
>
>     The argument status can have a value from 0 to 255 inclusive or be
>     one of the macros EXIT_SUCCESS or EXIT_FAILURE. The value of
>     EXIT_SUCCESS is defined in stdlib.h as 0; the value of EXIT_FAILURE
>     is 8.
>
EXIT_FAILURE it is not defined what precise value it has by the standard C.
However linux, aix, solaris and windows define it as "1". Only Z / OS
calls it 8 but I'm sure git  doesn't care about it.
Z/OS

https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program


SOLARIS
https://gitlab.anu.edu.au/mu/x-lcc/blob/24be447de544ed06d490ca0b2304a6531362156a/include/sparc/solaris/stdlib.h

AIX
https://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

WINDOWS
https://docs.microsoft.com/it-it/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170
> Now, I don't know z/OS at all, but e.g. if a shellscripts calls a C
> program there would $? be 1 if we hardcode 1, but 8 on EXIT_FAILURE?
See the previous answer
>
> We also document for some of these programs that on failure we'll return
> 1 specifically, not whatever EXIT_FAILURE is.
>
See the previous answer.
EXIT_FAILURE is always 1 on all popular platforms that git has been
ported to. So you don't even have to change the documentation.
> These patches also miss cases where we'll set 0 or 1 in a variable, and
> then exit(ret). See e.g. builtin/rm.c. You just changed the hardcoded
> exit(1), but missed where we'll return a hardcoded 0 or 1 via a
> variable.
My patch was just meant to introduce some standardization into git
using the posix/c standard. No more, No less. As other major projects
do, I didn't invent anything.

SYSTEMD COCCI
https://github.com/systemd/systemd/blob/main/coccinelle/exit-0.cocci

Lxc cocci
https://github.com/lxc/lxc/blob/master/coccinelle/exit.cocci

>
> And then there's changing exit(-1) to exit(1). That's existing
> non-portable use that we really should fix. But I know that you missed a
> lot there, since I instrumented git.c recently to intercept those for
> testing (it came up in some thread). We have a lot more than you spotted
> (and some will error if mapped to 1 IIRC). Most of those also want to
> exit 128, not 1.
In fact, these exit codes are more like shell-specific return codes to
indicate the "type" of the error.
I repeat that it was not the purpose of this patch to fix any problems
that may exist with exit codes. Certainly not using coccinelle. But I
agree it's a job to do. But not in this patch.
>
> Anyway:
>
> All in all I think we should just double down on the hardcoding instead,
> but we should fix the exit(-1) cases, and that's best done with some new
> GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or whatever.
>
> A lot of these codepaths are also paths we should fix, but not because
> we exit(N) with a hardcoded N, but because we invoke exit(N) there at
> all. See 338abb0f045 (builtins + test helpers: use return instead of
> exit() in cmd_*, 2021-06-08) for how some of those should be changed.
>
> I think we'd be much better off with something like this in
> git-compat-util.h:
>
>     #ifndef BYPASS_EXIT_SANITY
>     #ifdef EXIT_SUCCESS
>     #if EXIT_SUCCESS != 0
>     #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"
>     #endif
>     #endif
>     #ifdef EXIT_FAILURE
>     #if EXIT_FAILURE != 0
>     #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"
>     #endif
>     #endif
>     #endif
>
> Or *if* we're going to pursue this a twist on that (I really don't think
> this is worthwhile, just saying) where we'd re-define EXIT_SUCCESS and
> EXIT_FAILURE to some sentinel values like 123 and 124.
>
> Then run our entire test suite and roundtrip-assert that at least we
> ourselves handled that properly. I.e. whenever run_command() runs and we
> check for success we check 123, not 0, and a "normal failure" is 124,
> not 1.
>
> I know we'll get a *lot of* failures if we do that, so I'm not arguing
> that we *should*, just that it's rather easy for you to test that and
> see the resulting test suite dumpster fire.
>
> So I don't see how a *partial conversion* is really getting us anywhere,
> even if we take the pedantic C portability view of things.
>
> All we'd have accomplished is a false sense of portability on most OS's,
> as these will be 0 and 1 anyway. And on any stray odd OS's like z/OS
> we'll just need to deal with e.g. both 1 and 8 for EXIT_FAILURE, since
> we *will* miss a lot of cases.
Z / OS is a false problem. git on z / os runs in a linux partition
https://medium.com/theropod/git-on-z-os-f9234cd2a89a#:~:text=On%20z%2FOS%2C%20Git%20plays,added%20feature
% 20of% 20codepage% 20translation.
However, calling pedantic a solution widely used in other projects and
provided by standards (EXIT_SUCCESS and EXIT_FAILURE are reported by
the c/posix standard for generic success / error codes) does not seem
to me an appropriate term. But YMMV .

Thanks
>
> 1. https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-exit-end-program

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
  2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
  2022-03-22 17:47   ` Elia Pinto
@ 2022-03-23 11:13   ` Junio C Hamano
  1 sibling, 0 replies; 48+ messages in thread
From: Junio C Hamano @ 2022-03-23 11:13 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Elia Pinto, git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> We also document for some of these programs that on failure we'll
> return 1 specifically, not whatever EXIT_FAILURE is.

I view this as a real issue.  EXIT_FAILURE could by happenstance be
defined to be the same value on all platforms we care about, but if
it leaves the possibility that the next major thing will break our
assumption, I do not see much point in adopting it.  Whole-sale
rewriting of 0 and 1 to EXIT_SUCCESS and EXIT_FAILURE smells like
adopting a bad standardization without thinking things through, only
for the sake of adopting "standardization".

> ... but we should fix the exit(-1) cases, and that's best done
> with some new GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or
> whatever.

That is probably a good #leftoverbit, even a candidate for future
#microprojects.

> I think we'd be much better off with something like this in
> git-compat-util.h:
>
>     #ifndef BYPASS_EXIT_SANITY
>     #ifdef EXIT_SUCCESS
>     #if EXIT_SUCCESS != 0
>     #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"

This is not a good idea.  EXIT_SUCCESS does not have to be literally
0.  It only has to be a value that causes the process to exit with 0
when passed to exit().

>     #endif
>     #endif
>     #ifdef EXIT_FAILURE
>     #if EXIT_FAILURE != 0

I think you meant "!= 1".  If we were to take these 41 patches, we
must have this hunk, as we want our plumbing tools to be drivable by
shell scripts, i.e. 

	git foo ||
	case $? in
	1) # generic failure
		...
	esac

and we do not want to be forced to write something like

	. git-stdlib-util.sh ;# for platform-dependent $EXIT_FAILURE

	...
	git foo ||
	case $? in
	$EXIT_FAILURE) # generic failure
		...
	esac
	
instead.

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2022-03-23 11:13 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
2022-03-21 22:54 ` [PATCH 01/41] archive.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 02/41] branch.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 03/41] am.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 04/41] blame.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 05/41] commit.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 06/41] credential-cache--daemon.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 07/41] help.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 08/41] init-db.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 09/41] mailsplit.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 10/41] merge-index.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 11/41] merge.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 12/41] pull.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 13/41] rebase.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 14/41] remote-ext.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 15/41] rev-parse.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 16/41] rm.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 17/41] shortlog.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 18/41] show-branch.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 19/41] stash.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 20/41] tag.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 21/41] unpack-objects.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 22/41] update-index.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 23/41] obstack.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 24/41] git-credential-osxkeychain.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 25/41] git-credential-wincred.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 26/41] daemon.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 27/41] git.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 28/41] help.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 29/41] http-backend.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 30/41] parse-options.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 31/41] path.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 32/41] remote-curl.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 33/41] run-command.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 34/41] setup.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 35/41] shell.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 36/41] test-json-writer.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 37/41] test-reach.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 38/41] test-submodule-config.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 39/41] test-submodule-nested-repo-config.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 40/41] upload-pack.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 41/41] exit.cocci: " Elia Pinto
2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
2022-03-22  8:45   ` Elia Pinto
2022-03-22 11:21   ` Bagas Sanjaya
2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
2022-03-22 17:47   ` Elia Pinto
2022-03-23 11:13   ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.