diff options
author | Vincent Legoll <vincent.legoll@gmail.com> | 2009-10-13 04:18:16 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-13 05:55:31 -0400 |
commit | cfed95a693e1ea5d08b9c9019bc30e448437ee2f (patch) | |
tree | 1334775a5b22a0b430e7616d2020bec4593565df /tools/perf/perf.c | |
parent | 9dbdd6c41c12fb42ee7188eafa7e1917b192af3a (diff) |
perf tools: Do not manually count string lengths
Use strlen & macros instead of manually counting string lengths as
this is error prone and may lend to bugs.
Signed-off-by: Vincent Legoll <vincent.legoll@gmail.com>
Cc: Linus Torvalds <torvalds@osdl.org>
LKML-Reference: <4727185d0910130118m5387058dndb02ac9b384af9f0@mail.gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/perf.c')
-rw-r--r-- | tools/perf/perf.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 19fc7feb9d59..624e62d9d1e0 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -89,8 +89,8 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) | |||
89 | /* | 89 | /* |
90 | * Check remaining flags. | 90 | * Check remaining flags. |
91 | */ | 91 | */ |
92 | if (!prefixcmp(cmd, "--exec-path")) { | 92 | if (!prefixcmp(cmd, CMD_EXEC_PATH)) { |
93 | cmd += 11; | 93 | cmd += strlen(CMD_EXEC_PATH); |
94 | if (*cmd == '=') | 94 | if (*cmd == '=') |
95 | perf_set_argv_exec_path(cmd + 1); | 95 | perf_set_argv_exec_path(cmd + 1); |
96 | else { | 96 | else { |
@@ -117,8 +117,8 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) | |||
117 | (*argv)++; | 117 | (*argv)++; |
118 | (*argc)--; | 118 | (*argc)--; |
119 | handled++; | 119 | handled++; |
120 | } else if (!prefixcmp(cmd, "--perf-dir=")) { | 120 | } else if (!prefixcmp(cmd, CMD_PERF_DIR)) { |
121 | setenv(PERF_DIR_ENVIRONMENT, cmd + 10, 1); | 121 | setenv(PERF_DIR_ENVIRONMENT, cmd + strlen(CMD_PERF_DIR), 1); |
122 | if (envchanged) | 122 | if (envchanged) |
123 | *envchanged = 1; | 123 | *envchanged = 1; |
124 | } else if (!strcmp(cmd, "--work-tree")) { | 124 | } else if (!strcmp(cmd, "--work-tree")) { |
@@ -131,8 +131,8 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) | |||
131 | *envchanged = 1; | 131 | *envchanged = 1; |
132 | (*argv)++; | 132 | (*argv)++; |
133 | (*argc)--; | 133 | (*argc)--; |
134 | } else if (!prefixcmp(cmd, "--work-tree=")) { | 134 | } else if (!prefixcmp(cmd, CMD_WORK_TREE)) { |
135 | setenv(PERF_WORK_TREE_ENVIRONMENT, cmd + 12, 1); | 135 | setenv(PERF_WORK_TREE_ENVIRONMENT, cmd + strlen(CMD_WORK_TREE), 1); |
136 | if (envchanged) | 136 | if (envchanged) |
137 | *envchanged = 1; | 137 | *envchanged = 1; |
138 | } else if (!strcmp(cmd, "--debugfs-dir")) { | 138 | } else if (!strcmp(cmd, "--debugfs-dir")) { |
@@ -146,8 +146,8 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) | |||
146 | *envchanged = 1; | 146 | *envchanged = 1; |
147 | (*argv)++; | 147 | (*argv)++; |
148 | (*argc)--; | 148 | (*argc)--; |
149 | } else if (!prefixcmp(cmd, "--debugfs-dir=")) { | 149 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { |
150 | strncpy(debugfs_mntpt, cmd + 14, MAXPATHLEN); | 150 | strncpy(debugfs_mntpt, cmd + strlen(CMD_DEBUGFS_DIR), MAXPATHLEN); |
151 | debugfs_mntpt[MAXPATHLEN - 1] = '\0'; | 151 | debugfs_mntpt[MAXPATHLEN - 1] = '\0'; |
152 | if (envchanged) | 152 | if (envchanged) |
153 | *envchanged = 1; | 153 | *envchanged = 1; |