Skip to contentSkip to conversation

ftrace: remove an unneeded NULL check

PATCH In review Dan Carpenter 2 participants 3 messages Jul 12, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ftrace: remove an unneeded NULL check

"func" can't be NULL and it doesn't make sense to check because we've already derefenced it.

kernel/trace/ftrace.c +1 -1
index 2953d558bbee..2a3c45743f54 100644
@@ -3950,7 +3950,7 @@ static int cache_mod(struct trace_array *tr,
 				continue;
 
 			/* no func matches all */
-			if (!func || strcmp(func, "*") = 0 ||
+			if (strcmp(func, "*") = 0 ||
 			    (ftrace_mod->func &&
 			     strcmp(ftrace_mod->func, func) = 0)) {
 				ret = 0;
#1 lore raw

PATCH 2/2 ftrace: silence uninitialized variable warning

My static checker complains that if "func" is NULL then "clear_filter" is uninitialized. This seems like it could be true, although it's possible something subtle is happening that I haven't seen.

kernel/trace/ftrace.c:3844 match_records()
error: uninitialized symbol 'clear_filter'.

---
It does occur to me that I could initialize it to 1 instead of 0 but my guess is that zero is intended. Please review this one carefully.

kernel/trace/ftrace.c +1 -1
index 2a3c45743f54..5e658da91912 100644
@@ -3816,7 +3816,7 @@ match_records(struct ftrace_hash *hash, char *func, int len, char *mod)
 	int exclude_mod = 0;
 	int found = 0;
 	int ret;
-	int clear_filter;
+	int clear_filter = 0;
 
 	if (func) {
 		func_g.type = filter_parse_regex(func, len, &func_g.search,
maintainer
#2 lore raw

Re: [PATCH 2/2] ftrace: silence uninitialized variable warning

Quoted 11 lines · On Wed, 12 Jul 2017 10:35:57 +0300 Dan Carpenter <[email protected]>…

My static checker complains that if "func" is NULL then "clear_filter" is uninitialized. This seems like it could be true, although it's possible something subtle is happening that I haven't seen.

kernel/trace/ftrace.c:3844 match_records()
error: uninitialized symbol 'clear_filter'.

---
It does occur to me that I could initialize it to 1 instead of 0 but my guess is that zero is intended. Please review this one carefully.

Looks like it broke with f0a3b154bd7 ("ftrace: Clarify code for mod command"). Yeah, clear_filter = 0 is the correct default.

Thanks!

-- Steve

Quoted 14 lines
kernel/trace/ftrace.c +1 -1
index 2a3c45743f54..5e658da91912 100644
@@ -3816,7 +3816,7 @@ match_records(struct ftrace_hash *hash, char *func, int len, char *mod)
 	int exclude_mod = 0;
 	int found = 0;
 	int ret;
-	int clear_filter;
+	int clear_filter = 0;
 
 	if (func) {
 		func_g.type = filter_parse_regex(func, len, &func_g.search,