[PATCH] perf: fix exit usage

From: jovi zhang
Date: Thu Sep 16 2010 - 00:42:28 EST


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@xxxxxxxxx>
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);
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_