diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2012-01-31 10:02:52 +0000 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2012-01-31 10:03:24 +0000 |
commit | 54f752c09233cdb8e6149ac1e73b989bed367179 (patch) | |
tree | 13bc34eb28ff7fa6db01c77d131dafdc0393bd98 | |
parent | 689b6b2121e09d08437aab87b528e4c1de327d1c (diff) |
Avoid hacking around argc / argv.
-rw-r--r-- | cli/cli_diff.cpp | 2 | ||||
-rw-r--r-- | cli/cli_diff_images.cpp | 8 | ||||
-rw-r--r-- | cli/cli_diff_state.cpp | 2 | ||||
-rw-r--r-- | cli/cli_dump.cpp | 6 | ||||
-rw-r--r-- | cli/cli_main.cpp | 6 | ||||
-rw-r--r-- | cli/cli_pickle.cpp | 2 | ||||
-rw-r--r-- | cli/cli_repack.cpp | 2 | ||||
-rw-r--r-- | cli/cli_trace.cpp | 2 | ||||
-rw-r--r-- | cli/cli_trim.cpp | 2 | ||||
-rwxr-xr-x | scripts/tracediff.sh | 2 |
10 files changed, 15 insertions, 19 deletions
diff --git a/cli/cli_diff.cpp b/cli/cli_diff.cpp index 0bd1b31f..9f6efefa 100644 --- a/cli/cli_diff.cpp +++ b/cli/cli_diff.cpp @@ -50,7 +50,7 @@ command(int argc, char *argv[]) { int i; - for (i = 0; i < argc; ++i) { + for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/cli/cli_diff_images.cpp b/cli/cli_diff_images.cpp index 42aaaff0..626a34fc 100644 --- a/cli/cli_diff_images.cpp +++ b/cli/cli_diff_images.cpp @@ -68,12 +68,12 @@ command(int argc, char *argv[]) return 1; } - char **args = new char* [argc + 2]; + char **args = new char* [argc + 1]; args[0] = (char *) command.str(); - for (i = 0; i < argc; i++) { - args[i + 1] = argv[i]; + for (i = 1; i < argc; i++) { + args[i] = argv[i]; } - args[i + 1] = NULL; + args[argc] = NULL; ret = os::execute(args); diff --git a/cli/cli_diff_state.cpp b/cli/cli_diff_state.cpp index 8918d582..8536e323 100644 --- a/cli/cli_diff_state.cpp +++ b/cli/cli_diff_state.cpp @@ -50,7 +50,7 @@ command(int argc, char *argv[]) { int i; - for (i = 0; i < argc; ++i) { + for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/cli/cli_dump.cpp b/cli/cli_dump.cpp index 3f393ce1..d6f50141 100644 --- a/cli/cli_dump.cpp +++ b/cli/cli_dump.cpp @@ -117,10 +117,6 @@ command(int argc, char *argv[]) trace::DumpFlags dumpFlags = 0; bool dumpThreadIds = false; - // FIXME: avoid hacking around argc / argv - argc += 1; - argv = &argv[-1]; - int opt; while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) { switch (opt) { @@ -154,7 +150,7 @@ command(int argc, char *argv[]) } break; case THREAD_IDS_OPT: - dumpThreadIds = boolOption(optarg, true); + dumpThreadIds = boolOption(optarg); break; default: std::cerr << "error: unexpected option `" << opt << "`\n"; diff --git a/cli/cli_main.cpp b/cli/cli_main.cpp index a776107f..cff6a05d 100644 --- a/cli/cli_main.cpp +++ b/cli/cli_main.cpp @@ -122,12 +122,12 @@ do_help_command(int argc, char *argv[]) const Command *command; int i; - if (argc != 1) { + if (argc != 2) { help_usage(); return 0; } - char *command_name = argv[0]; + char *command_name = argv[1]; for (i = 0; i < ARRAY_SIZE(commands); i++) { command = commands[i]; @@ -172,7 +172,7 @@ main(int argc, char **argv) return 1; } - command_name = argv[i++]; + command_name = argv[i]; argc -= i; argv = &argv[i]; diff --git a/cli/cli_pickle.cpp b/cli/cli_pickle.cpp index 8535b18d..6af879fa 100644 --- a/cli/cli_pickle.cpp +++ b/cli/cli_pickle.cpp @@ -166,7 +166,7 @@ command(int argc, char *argv[]) { int i; - for (i = 0; i < argc;) { + for (i = 1; i < argc;) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/cli/cli_repack.cpp b/cli/cli_repack.cpp index 918f54a8..a92723d6 100644 --- a/cli/cli_repack.cpp +++ b/cli/cli_repack.cpp @@ -80,7 +80,7 @@ command(int argc, char *argv[]) { int i; - for (i = 0; i < argc; ++i) { + for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/cli/cli_trace.cpp b/cli/cli_trace.cpp index 92251b4b..68526cb4 100644 --- a/cli/cli_trace.cpp +++ b/cli/cli_trace.cpp @@ -64,7 +64,7 @@ command(int argc, char *argv[]) const char *output = NULL; int i; - for (i = 0; i < argc; ) { + for (i = 1; i < argc; ) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/cli/cli_trim.cpp b/cli/cli_trim.cpp index 8fdd93c3..515b4b61 100644 --- a/cli/cli_trim.cpp +++ b/cli/cli_trim.cpp @@ -56,7 +56,7 @@ command(int argc, char *argv[]) trace::CallSet calls(trace::FREQUENCY_ALL); int i; - for (i = 0; i < argc;) { + for (i = 1; i < argc;) { const char *arg = argv[i]; if (arg[0] != '-') { diff --git a/scripts/tracediff.sh b/scripts/tracediff.sh index 9f9633d2..819a2512 100755 --- a/scripts/tracediff.sh +++ b/scripts/tracediff.sh @@ -31,7 +31,7 @@ APITRACE=${APITRACE:-apitrace} $APITRACE dump stripdump () { - $APITRACE dump --color=never --no-arg-names "$1" \ + $APITRACE dump --color=never --arg-names=no "$1" \ | sed \ -e 's/\r$//g' \ -e 's/^[0-9]\+ //' \ |