Commit 2f31ed93 authored by Tom Zanussi's avatar Tom Zanussi Committed by Steven Rostedt (VMware)

tracing: Change strlen to sizeof for hist trigger static strings

There's no need to use strlen() for static strings when the length is
already known, so update trace_events_hist.c with sizeof() for those
cases.

Link: http://lkml.kernel.org/r/e3e754f2bd18e56eaa8baf79bee619316ebf4cfc.1545161087.git.tom.zanussi@linux.intel.comAcked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 6801f0d5
......@@ -507,7 +507,7 @@ static int synth_field_string_size(char *type)
start = strstr(type, "char[");
if (start == NULL)
return -EINVAL;
start += strlen("char[");
start += sizeof("char[") - 1;
end = strchr(type, ']');
if (!end || end < start)
......@@ -1843,8 +1843,8 @@ static int parse_action(char *str, struct hist_trigger_attrs *attrs)
if (attrs->n_actions >= HIST_ACTIONS_MAX)
return ret;
if ((strncmp(str, "onmatch(", strlen("onmatch(")) == 0) ||
(strncmp(str, "onmax(", strlen("onmax(")) == 0)) {
if ((strncmp(str, "onmatch(", sizeof("onmatch(") - 1) == 0) ||
(strncmp(str, "onmax(", sizeof("onmax(") - 1) == 0)) {
attrs->action_str[attrs->n_actions] = kstrdup(str, GFP_KERNEL);
if (!attrs->action_str[attrs->n_actions]) {
ret = -ENOMEM;
......@@ -1861,34 +1861,34 @@ static int parse_assignment(char *str, struct hist_trigger_attrs *attrs)
{
int ret = 0;
if ((strncmp(str, "key=", strlen("key=")) == 0) ||
(strncmp(str, "keys=", strlen("keys=")) == 0)) {
if ((strncmp(str, "key=", sizeof("key=") - 1) == 0) ||
(strncmp(str, "keys=", sizeof("keys=") - 1) == 0)) {
attrs->keys_str = kstrdup(str, GFP_KERNEL);
if (!attrs->keys_str) {
ret = -ENOMEM;
goto out;
}
} else if ((strncmp(str, "val=", strlen("val=")) == 0) ||
(strncmp(str, "vals=", strlen("vals=")) == 0) ||
(strncmp(str, "values=", strlen("values=")) == 0)) {
} else if ((strncmp(str, "val=", sizeof("val=") - 1) == 0) ||
(strncmp(str, "vals=", sizeof("vals=") - 1) == 0) ||
(strncmp(str, "values=", sizeof("values=") - 1) == 0)) {
attrs->vals_str = kstrdup(str, GFP_KERNEL);
if (!attrs->vals_str) {
ret = -ENOMEM;
goto out;
}
} else if (strncmp(str, "sort=", strlen("sort=")) == 0) {
} else if (strncmp(str, "sort=", sizeof("sort=") - 1) == 0) {
attrs->sort_key_str = kstrdup(str, GFP_KERNEL);
if (!attrs->sort_key_str) {
ret = -ENOMEM;
goto out;
}
} else if (strncmp(str, "name=", strlen("name=")) == 0) {
} else if (strncmp(str, "name=", sizeof("name=") - 1) == 0) {
attrs->name = kstrdup(str, GFP_KERNEL);
if (!attrs->name) {
ret = -ENOMEM;
goto out;
}
} else if (strncmp(str, "clock=", strlen("clock=")) == 0) {
} else if (strncmp(str, "clock=", sizeof("clock=") - 1) == 0) {
strsep(&str, "=");
if (!str) {
ret = -EINVAL;
......@@ -1901,7 +1901,7 @@ static int parse_assignment(char *str, struct hist_trigger_attrs *attrs)
ret = -ENOMEM;
goto out;
}
} else if (strncmp(str, "size=", strlen("size=")) == 0) {
} else if (strncmp(str, "size=", sizeof("size=") - 1) == 0) {
int map_bits = parse_map_size(str);
if (map_bits < 0) {
......@@ -3497,7 +3497,7 @@ static struct action_data *onmax_parse(char *str)
if (!onmax_fn_name || !str)
goto free;
if (strncmp(onmax_fn_name, "save", strlen("save")) == 0) {
if (strncmp(onmax_fn_name, "save", sizeof("save") - 1) == 0) {
char *params = strsep(&str, ")");
if (!params) {
......@@ -4302,8 +4302,8 @@ static int parse_actions(struct hist_trigger_data *hist_data)
for (i = 0; i < hist_data->attrs->n_actions; i++) {
str = hist_data->attrs->action_str[i];
if (strncmp(str, "onmatch(", strlen("onmatch(")) == 0) {
char *action_str = str + strlen("onmatch(");
if (strncmp(str, "onmatch(", sizeof("onmatch(") - 1) == 0) {
char *action_str = str + sizeof("onmatch(") - 1;
data = onmatch_parse(tr, action_str);
if (IS_ERR(data)) {
......@@ -4311,8 +4311,8 @@ static int parse_actions(struct hist_trigger_data *hist_data)
break;
}
data->fn = action_trace;
} else if (strncmp(str, "onmax(", strlen("onmax(")) == 0) {
char *action_str = str + strlen("onmax(");
} else if (strncmp(str, "onmax(", sizeof("onmax(") - 1) == 0) {
char *action_str = str + sizeof("onmax(") - 1;
data = onmax_parse(action_str);
if (IS_ERR(data)) {
......@@ -5548,9 +5548,9 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
p++;
continue;
}
if (p >= param + strlen(param) - strlen("if") - 1)
if (p >= param + strlen(param) - (sizeof("if") - 1) - 1)
return -EINVAL;
if (*(p + strlen("if")) != ' ' && *(p + strlen("if")) != '\t') {
if (*(p + sizeof("if") - 1) != ' ' && *(p + sizeof("if") - 1) != '\t') {
p++;
continue;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment