lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210729062451.1349566-3-irogers@google.com>
Date:   Wed, 28 Jul 2021 23:24:50 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     eranian@...gle.com, Ian Rogers <irogers@...gle.com>
Subject: [PATCH 2/3] tools perf: Prefer exit(EXIT_*) over exit(0|1)

Change exit code to be more intention revealing, replacing exit(0) with
exit(EXIT_SUCCESS) and exit(1) with exit(EXIT_FAILURE).

Signed-off-by: Ian Rogers <irogers@...gle.com>
---
 tools/perf/arch/x86/tests/bp-modify.c | 4 ++--
 tools/perf/bench/inject-buildid.c     | 8 ++++----
 tools/perf/bench/numa.c               | 2 +-
 tools/perf/bench/sched-messaging.c    | 6 +++---
 tools/perf/bench/sched-pipe.c         | 4 ++--
 tools/perf/bench/syscall.c            | 2 +-
 tools/perf/builtin-c2c.c              | 2 +-
 tools/perf/builtin-ftrace.c           | 2 +-
 tools/perf/builtin-mem.c              | 2 +-
 tools/perf/builtin-script.c           | 4 ++--
 tools/perf/perf.c                     | 8 ++++----
 tools/perf/ui/tui/setup.c             | 4 ++--
 tools/perf/util/dlfilter.c            | 2 +-
 tools/perf/util/help-unknown-cmd.c    | 2 +-
 14 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tools/perf/arch/x86/tests/bp-modify.c b/tools/perf/arch/x86/tests/bp-modify.c
index dffcf9b52153..9cf1036d0480 100644
--- a/tools/perf/arch/x86/tests/bp-modify.c
+++ b/tools/perf/arch/x86/tests/bp-modify.c
@@ -41,12 +41,12 @@ static int spawn_child(void)
 
 		if (err) {
 			pr_debug("failed to PTRACE_TRACEME\n");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 
 		raise(SIGCONT);
 		bp_1();
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 
 	return child;
diff --git a/tools/perf/bench/inject-buildid.c b/tools/perf/bench/inject-buildid.c
index 55d373b75791..8fd1ec0d371e 100644
--- a/tools/perf/bench/inject-buildid.c
+++ b/tools/perf/bench/inject-buildid.c
@@ -106,7 +106,7 @@ static void collect_dso(void)
 	dsos = calloc(nr_mmaps * DSO_MMAP_RATIO, sizeof(*dsos));
 	if (dsos == NULL) {
 		printf("  Memory allocation failed\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	if (nftw("/usr/lib/", add_dso, 10, FTW_PHYS) < 0)
@@ -305,7 +305,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all)
 
 		dev_null_fd = open("/dev/null", O_WRONLY);
 		if (dev_null_fd < 0)
-			exit(1);
+			exit(EXIT_FAILURE);
 
 		dup2(dev_null_fd, STDERR_FILENO);
 
@@ -314,7 +314,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all)
 
 		inject_argv = calloc(inject_argc + 1, sizeof(*inject_argv));
 		if (inject_argv == NULL)
-			exit(1);
+			exit(EXIT_FAILURE);
 
 		inject_argv[0] = strdup("inject");
 		inject_argv[1] = strdup("-b");
@@ -326,7 +326,7 @@ static int setup_injection(struct bench_data *data, bool build_id_all)
 
 		cmd_inject(inject_argc, inject_argv);
 
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 
 	pthread_create(&data->th, NULL, data_reader, data);
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index f2640179ada9..a2ee96180444 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1551,7 +1551,7 @@ static int __bench_numa(const char *name)
 			/* Child process: */
 			worker_process(i);
 
-			exit(0);
+			exit(EXIT_SUCCESS);
 		}
 		pids[i] = pid;
 
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 488f6e6ba1a5..d03248837777 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -149,7 +149,7 @@ static pthread_t create_worker(void *ctx, void *(*func)(void *))
 			break;
 		case 0:
 			(*func) (ctx);
-			exit(0);
+			exit(EXIT_SUCCESS);
 			break;
 		default:
 			break;
@@ -182,7 +182,7 @@ static void reap_worker(pthread_t id)
 		/* process mode */
 		wait(&proc_status);
 		if (!WIFEXITED(proc_status))
-			exit(1);
+			exit(EXIT_FAILURE);
 	} else {
 		pthread_join(id, &thread_status);
 	}
@@ -319,7 +319,7 @@ int bench_sched_messaging(int argc, const char **argv)
 	default:
 		/* reaching here is something disaster */
 		fprintf(stderr, "Unknown format:%d\n", bench_format);
-		exit(1);
+		exit(EXIT_FAILURE);
 		break;
 	}
 
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index a960e7a93aec..0f5c00a29199 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -135,7 +135,7 @@ int bench_sched_pipe(int argc, const char **argv)
 
 		if (!pid) {
 			worker_thread(threads + 0);
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else {
 			worker_thread(threads + 1);
 		}
@@ -175,7 +175,7 @@ int bench_sched_pipe(int argc, const char **argv)
 	default:
 		/* reaching here is something disaster */
 		fprintf(stderr, "Unknown format:%d\n", bench_format);
-		exit(1);
+		exit(EXIT_FAILURE);
 		break;
 	}
 
diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c
index 9b751016f4b6..abd49c45ce3b 100644
--- a/tools/perf/bench/syscall.c
+++ b/tools/perf/bench/syscall.c
@@ -73,7 +73,7 @@ int bench_syscall_basic(int argc, const char **argv)
 	default:
 		/* reaching here is something disaster */
 		fprintf(stderr, "Unknown format:%d\n", bench_format);
-		exit(1);
+		exit(EXIT_FAILURE);
 		break;
 	}
 
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 6dea37f141b2..21ef021b8bbf 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2889,7 +2889,7 @@ static int parse_record_events(const struct option *opt,
 
 	if (!strcmp(str, "list")) {
 		perf_mem_events__list();
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 	if (perf_mem_events__parse(str))
 		exit(-1);
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 87cb11a7a3ee..2411aa4443e0 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -750,7 +750,7 @@ static int opt_list_avail_functions(const struct option *opt __maybe_unused,
 	if (ret < 0)
 		return ret;
 
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 static int parse_filter_func(const struct option *opt, const char *str,
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 0fd2a74dbaca..5d96b6e15992 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -45,7 +45,7 @@ static int parse_record_events(const struct option *opt,
 
 	if (!strcmp(str, "list")) {
 		perf_mem_events__list();
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 	if (perf_mem_events__parse(str))
 		exit(-1);
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8c03a9862872..f4763830c7a4 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2774,7 +2774,7 @@ static int parse_scriptname(const struct option *opt __maybe_unused,
 
 	if (strcmp(str, "lang") == 0) {
 		list_available_languages();
-		exit(0);
+		exit(EXIT_SUCCESS);
 	}
 
 	script = strchr(str, ':');
@@ -3175,7 +3175,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
 			desc->half_liner ? desc->half_liner : "");
 	}
 
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 static int add_dlarg(const struct option *opt __maybe_unused,
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 2f6b67189b42..ec45dd645030 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -214,11 +214,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				set_argv_exec_path(cmd + 1);
 			else {
 				puts(get_argv_exec_path());
-				exit(0);
+				exit(EXIT_SUCCESS);
 			}
 		} else if (!strcmp(cmd, "--html-path")) {
 			puts(system_path(PERF_HTML_PATH));
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			use_pager = 1;
 		} else if (!strcmp(cmd, "--no-pager")) {
@@ -258,7 +258,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				printf("%s ", p->cmd);
 			}
 			putchar('\n');
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "--list-opts")) {
 			unsigned int i;
 
@@ -267,7 +267,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				printf("--%s ", p->long_name);
 			}
 			putchar('\n');
-			exit(0);
+			exit(EXIT_SUCCESS);
 		} else if (!strcmp(cmd, "--debug")) {
 			if (*argc < 2) {
 				fprintf(stderr, "No variable specified for --debug.\n");
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index e9bfe856a5de..867c128d1f22 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -109,7 +109,7 @@ static void ui__signal_backtrace(int sig)
 	size = backtrace(stackdump, ARRAY_SIZE(stackdump));
 	backtrace_symbols_fd(stackdump, size, STDOUT_FILENO);
 
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 #else
 # define ui__signal_backtrace  ui__signal
@@ -119,7 +119,7 @@ static void ui__signal(int sig)
 {
 	ui__exit(false);
 	psignal(sig, "perf");
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 int ui__init(void)
diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c
index ca33fbc5efde..11cf84ef30b1 100644
--- a/tools/perf/util/dlfilter.c
+++ b/tools/perf/util/dlfilter.c
@@ -611,5 +611,5 @@ int list_available_dlfilters(const struct option *opt __maybe_unused,
 
 	free(exec_path);
 out:
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index ab9e16123626..fac794d75b14 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -114,5 +114,5 @@ const char *help_unknown_cmd(const char *cmd)
 			fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
 	}
 end:
-	exit(1);
+	exit(EXIT_FAILURE);
 }
-- 
2.32.0.432.gabb21c7263-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ