Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2aba66d authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Greg Kroah-Hartman
Browse files

tracing: Use str_has_prefix() instead of using fixed sizes



commit b6b2735514bcd70ad1556a33892a636b20ece671 upstream.

There are several instances of strncmp(str, "const", 123), where 123 is the
strlen of the const string to check if "const" is the prefix of str. But
this can be error prone. Use str_has_prefix() instead.

Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarGeorge Guo <guodongtai@kylinos.cn>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 03aacb90
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4470,7 +4470,7 @@ static int trace_set_options(struct trace_array *tr, char *option)

	cmp = strstrip(option);

	if (strncmp(cmp, "no", 2) == 0) {
	if (str_has_prefix(cmp, "no")) {
		neg = 1;
		cmp += 2;
	}
+1 −1
Original line number Diff line number Diff line
@@ -1249,7 +1249,7 @@ static int f_show(struct seq_file *m, void *v)
	 */
	array_descriptor = strchr(field->type, '[');

	if (!strncmp(field->type, "__data_loc", 10))
	if (str_has_prefix(field->type, "__data_loc"))
		array_descriptor = NULL;

	if (!array_descriptor)
+1 −1
Original line number Diff line number Diff line
@@ -484,7 +484,7 @@ static int synth_event_define_fields(struct trace_event_call *call)

static bool synth_field_signed(char *type)
{
	if (strncmp(type, "u", 1) == 0)
	if (str_has_prefix(type, "u"))
		return false;
	if (strcmp(type, "gfp_t") == 0)
		return false;
+1 −1
Original line number Diff line number Diff line
@@ -342,7 +342,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
			f->fn = t->fetch[FETCH_MTD_retval];
		else
			ret = -EINVAL;
	} else if (strncmp(arg, "stack", 5) == 0) {
	} else if (str_has_prefix(arg, "stack")) {
		if (arg[5] == '\0') {
			if (strcmp(t->name, DEFAULT_FETCH_TYPE_STR))
				return -EINVAL;
+1 −1
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata;

static __init int enable_stacktrace(char *str)
{
	if (strncmp(str, "_filter=", 8) == 0)
	if (str_has_prefix(str, "_filter="))
		strncpy(stack_trace_filter_buf, str+8, COMMAND_LINE_SIZE);

	stack_tracer_enabled = 1;