All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ftrace: remove an unneeded NULL check
@ 2017-07-12  7:33 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-07-12  7:33 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

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

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2953d558bbee..2a3c45743f54 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ftrace: remove an unneeded NULL check
@ 2017-07-12  7:33 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-07-12  7:33 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

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

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2953d558bbee..2a3c45743f54 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ftrace: silence uninitialized variable warning
  2017-07-12  7:33 ` Dan Carpenter
@ 2017-07-12  7:35   ` Dan Carpenter
  -1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-07-12  7:35 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

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'.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2a3c45743f54..5e658da91912 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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,

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ftrace: silence uninitialized variable warning
@ 2017-07-12  7:35   ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-07-12  7:35 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

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'.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2a3c45743f54..5e658da91912 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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,

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ftrace: silence uninitialized variable warning
  2017-07-12  7:35   ` Dan Carpenter
@ 2017-07-12 13:45     ` Steven Rostedt
  -1 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2017-07-12 13:45 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

On Wed, 12 Jul 2017 10:35:57 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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'.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> 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

> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 2a3c45743f54..5e658da91912 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -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,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ftrace: silence uninitialized variable warning
@ 2017-07-12 13:45     ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2017-07-12 13:45 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

On Wed, 12 Jul 2017 10:35:57 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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'.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> 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

> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 2a3c45743f54..5e658da91912 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -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,


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-12 13:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12  7:33 [PATCH 1/2] ftrace: remove an unneeded NULL check Dan Carpenter
2017-07-12  7:33 ` Dan Carpenter
2017-07-12  7:35 ` [PATCH 2/2] ftrace: silence uninitialized variable warning Dan Carpenter
2017-07-12  7:35   ` Dan Carpenter
2017-07-12 13:45   ` Steven Rostedt
2017-07-12 13:45     ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.