[<prev] [next>] [day] [month] [year] [list]
Message-ID: <AANLkTi=K1xnqt5MAX2uAr+h7t9Hv4e8kaHOn-K_mRjCa@mail.gmail.com>
Date: Thu, 16 Sep 2010 12:42:17 +0800
From: jovi zhang <bookjovi@...il.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] perf: fix exit usage
unify some exit code(using -1), and fix one bug(not exit when fork
error in builtin-stat.c).
Signed-off-by: jovi zhang <bookjovi@...il.com>
tools/perf/builtin-stat.c | 7 +++++--
tools/perf/builtin-top.c | 6 +++---
tools/perf/perf.c | 4 ++--
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a6b4d44..fe3e044 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -285,12 +285,15 @@ static int run_perf_stat(int argc __used, const
char **argv)
if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
perror("failed to create pipes");
- exit(1);
+ exit(-1);
}
if (forks) {
- if ((child_pid = fork()) < 0)
+ child_pid = fork();
+ if (child_pid < 0) {
perror("failed to fork");
+ exit(-1);
+ }
if (!child_pid) {
close(child_ready_pipe[0]);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b513e40..d0e646c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1047,7 +1047,7 @@ static void event__process_sample(const event_t *self,
RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) {
pr_err("The %s file can't be used\n",
symbol_conf.vmlinux_name);
- exit(1);
+ exit(-1);
}
return;
@@ -1066,7 +1066,7 @@ static void event__process_sample(const event_t *self,
machine__fprintf_vmlinux_path(machine, stderr);
} else
pr_err(".\n");
- exit(1);
+ exit(-1);
}
}
@@ -1439,7 +1439,7 @@ int cmd_top(int argc, const char **argv, const
char *prefix __used)
default_interval = freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
- exit(EXIT_FAILURE);
+ exit(-1);
}
/*
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index cdd6c03..2d4601f 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -468,7 +468,7 @@ int main(int argc, const char **argv)
printf("\n usage: %s\n\n", perf_usage_string);
list_common_cmds_help();
printf("\n %s\n\n", perf_more_info_string);
- exit(1);
+ exit(-1);
}
cmd = argv[0];
@@ -492,7 +492,7 @@ int main(int argc, const char **argv)
fprintf(stderr, "Expansion of alias '%s' failed; "
"'%s' is not a perf-command\n",
cmd, argv[0]);
- exit(1);
+ exit(-1);
}
if (!done_help) {
cmd = argv[0] = help_unknown_cmd(cmd);
Powered by blists - more mailing lists