LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] trace/ftrace: fix maybe-uninitialized compiler warning
@ 2020-05-23 15:53 Kaitao Cheng
  2020-05-28 23:49 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Kaitao Cheng @ 2020-05-23 15:53 UTC (permalink / raw)
  To: rostedt; +Cc: mingo, linux-kernel, songmuchun, Kaitao Cheng

During build compiler reports some 'false positive' warnings about
variables {'seq_ops', 'filtered_pids', 'other_pids'} may be used
uninitialized. This patch silences these warnings.
Also delete some useless spaces

Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
---
 kernel/trace/ftrace.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7d0ebd104706..01a61bdc4e63 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2260,7 +2260,7 @@ ftrace_find_tramp_ops_next(struct dyn_ftrace *rec,
 
 		if (hash_contains_ip(ip, op->func_hash))
 			return op;
-	} 
+	}
 
 	return NULL;
 }
@@ -3599,7 +3599,7 @@ static int t_show(struct seq_file *m, void *v)
 			if (direct)
 				seq_printf(m, "\n\tdirect-->%pS", (void *)direct);
 		}
-	}	
+	}
 
 	seq_putc(m, '\n');
 
@@ -7151,6 +7151,9 @@ static int pid_open(struct inode *inode, struct file *file, int type)
 	case TRACE_NO_PIDS:
 		seq_ops = &ftrace_no_pid_sops;
 		break;
+	default:
+		trace_array_put(tr);
+		return -EINVAL;
 	}
 
 	ret = seq_open(file, seq_ops);
@@ -7229,6 +7232,9 @@ pid_write(struct file *filp, const char __user *ubuf,
 		other_pids = rcu_dereference_protected(tr->function_pids,
 					     lockdep_is_held(&ftrace_lock));
 		break;
+	default:
+		ret = -EINVAL;
+		goto out;
 	}
 
 	ret = trace_pid_write(filtered_pids, &pid_list, ubuf, cnt);
-- 
2.20.1


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

* Re: [PATCH] trace/ftrace: fix maybe-uninitialized compiler warning
  2020-05-23 15:53 [PATCH] trace/ftrace: fix maybe-uninitialized compiler warning Kaitao Cheng
@ 2020-05-28 23:49 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2020-05-28 23:49 UTC (permalink / raw)
  To: Kaitao Cheng; +Cc: mingo, linux-kernel, songmuchun

Hi Kaitao,

Sorry for the late response, I've been a bit swamped.

On Sat, 23 May 2020 23:53:04 +0800
Kaitao Cheng <pilgrimtao@gmail.com> wrote:

> During build compiler reports some 'false positive' warnings about
> variables {'seq_ops', 'filtered_pids', 'other_pids'} may be used
> uninitialized. This patch silences these warnings.
> Also delete some useless spaces
> 
> Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
> ---
>  kernel/trace/ftrace.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 7d0ebd104706..01a61bdc4e63 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -2260,7 +2260,7 @@ ftrace_find_tramp_ops_next(struct dyn_ftrace *rec,
>  
>  		if (hash_contains_ip(ip, op->func_hash))
>  			return op;
> -	} 
> +	}
>  
>  	return NULL;
>  }
> @@ -3599,7 +3599,7 @@ static int t_show(struct seq_file *m, void *v)
>  			if (direct)
>  				seq_printf(m, "\n\tdirect-->%pS", (void *)direct);
>  		}
> -	}	
> +	}
>  
>  	seq_putc(m, '\n');
>  
> @@ -7151,6 +7151,9 @@ static int pid_open(struct inode *inode, struct file *file, int type)
>  	case TRACE_NO_PIDS:
>  		seq_ops = &ftrace_no_pid_sops;
>  		break;
> +	default:
> +		trace_array_put(tr);
> +		return -EINVAL;
>  	}
>  
>  	ret = seq_open(file, seq_ops);
> @@ -7229,6 +7232,9 @@ pid_write(struct file *filp, const char __user *ubuf,
>  		other_pids = rcu_dereference_protected(tr->function_pids,
>  					     lockdep_is_held(&ftrace_lock));
>  		break;
> +	default:
> +		ret = -EINVAL;

As these are anomalies, and should never happen, we should probably add
a WARN_ON_ONCE(1); here as well.

Care to send a v2?

Thanks!

-- Steve


> +		goto out;
>  	}
>  
>  	ret = trace_pid_write(filtered_pids, &pid_list, ubuf, cnt);


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 15:53 [PATCH] trace/ftrace: fix maybe-uninitialized compiler warning Kaitao Cheng
2020-05-28 23:49 ` Steven Rostedt

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git