tools include: Adopt strstarts() from the kernel
Replacing prefixcmp(), same purpose, inverted result, so standardize on the kernel variant, to reduce silly differences among tools/ and the kernel sources, making it easier for people to work in both codebases. And then doing: if (strstarts(option, "no-")) Looks clearer than doing: if (!prefixcmp(option, "no-")) To figure out if option starts witn "no-". Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-kaei42gi7lpa8subwtv7eug8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -89,7 +89,7 @@ struct pager_config {
|
||||
static int pager_command_config(const char *var, const char *value, void *data)
|
||||
{
|
||||
struct pager_config *c = data;
|
||||
if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd))
|
||||
if (strstarts(var, "pager.") && !strcmp(var + 6, c->cmd))
|
||||
c->val = perf_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
@@ -108,9 +108,9 @@ static int check_pager_config(const char *cmd)
|
||||
static int browser_command_config(const char *var, const char *value, void *data)
|
||||
{
|
||||
struct pager_config *c = data;
|
||||
if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd))
|
||||
if (strstarts(var, "tui.") && !strcmp(var + 4, c->cmd))
|
||||
c->val = perf_config_bool(var, value);
|
||||
if (!prefixcmp(var, "gtk.") && !strcmp(var + 4, c->cmd))
|
||||
if (strstarts(var, "gtk.") && !strcmp(var + 4, c->cmd))
|
||||
c->val = perf_config_bool(var, value) ? 2 : 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
|
||||
/*
|
||||
* Check remaining flags.
|
||||
*/
|
||||
if (!prefixcmp(cmd, CMD_EXEC_PATH)) {
|
||||
if (strstarts(cmd, CMD_EXEC_PATH)) {
|
||||
cmd += strlen(CMD_EXEC_PATH);
|
||||
if (*cmd == '=')
|
||||
set_argv_exec_path(cmd + 1);
|
||||
@@ -229,7 +229,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
|
||||
*envchanged = 1;
|
||||
(*argv)++;
|
||||
(*argc)--;
|
||||
} else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
|
||||
} else if (strstarts(cmd, CMD_DEBUGFS_DIR)) {
|
||||
tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
|
||||
fprintf(stderr, "dir: %s\n", tracing_path);
|
||||
if (envchanged)
|
||||
@@ -470,14 +470,14 @@ int main(int argc, const char **argv)
|
||||
* So we just directly call the internal command handler, and
|
||||
* die if that one cannot handle it.
|
||||
*/
|
||||
if (!prefixcmp(cmd, "perf-")) {
|
||||
if (strstarts(cmd, "perf-")) {
|
||||
cmd += 5;
|
||||
argv[0] = cmd;
|
||||
handle_internal_command(argc, argv);
|
||||
fprintf(stderr, "cannot handle %s internally", cmd);
|
||||
goto out;
|
||||
}
|
||||
if (!prefixcmp(cmd, "trace")) {
|
||||
if (strstarts(cmd, "trace")) {
|
||||
#ifdef HAVE_LIBAUDIT_SUPPORT
|
||||
setup_path();
|
||||
argv[0] = "trace";
|
||||
@@ -495,7 +495,7 @@ int main(int argc, const char **argv)
|
||||
commit_pager_choice();
|
||||
|
||||
if (argc > 0) {
|
||||
if (!prefixcmp(argv[0], "--"))
|
||||
if (strstarts(argv[0], "--"))
|
||||
argv[0] += 2;
|
||||
} else {
|
||||
/* The user didn't specify a command; give them help */
|
||||
|
||||
Reference in New Issue
Block a user