tracing: initialize variable in create_dyn_event()
diff mbox series

Message ID 1548382670-30266-1-git-send-email-frowand.list@gmail.com
State New, archived
Headers show
Series
  • tracing: initialize variable in create_dyn_event()
Related show

Commit Message

Frank Rowand Jan. 25, 2019, 2:17 a.m. UTC
From: Frank Rowand <frank.rowand@sony.com>

Fix compile warning in create_dyn_event(): 'ret' may be used uninitialized
in this function [-Wuninitialized].

Fixes: 5448d44c3855 ("tracing: Add unified dynamic event framework")

Signed-off-by: Frank Rowand <frank.rowand@sony.com>
---

Compile and boot tested only.  Please verify the initialization value
of zero is correct.

There is also a sparse warning you might want to check into (when
ARCH=arm, so 32 bit):

   include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0)


 kernel/trace/trace_dynevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Frank Rowand March 14, 2019, 9:05 p.m. UTC | #1
Hi Steve,

Ping.

-Frank


On 1/24/19 6:17 PM, frowand.list@gmail.com wrote:
> From: Frank Rowand <frank.rowand@sony.com>
> 
> Fix compile warning in create_dyn_event(): 'ret' may be used uninitialized
> in this function [-Wuninitialized].
> 
> Fixes: 5448d44c3855 ("tracing: Add unified dynamic event framework")
> 
> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
> ---
> 
> Compile and boot tested only.  Please verify the initialization value
> of zero is correct.
> 
> There is also a sparse warning you might want to check into (when
> ARCH=arm, so 32 bit):
> 
>    include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0)
> 
> 
>  kernel/trace/trace_dynevent.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c
> index dd1f43588d70..4f633476c307 100644
> --- a/kernel/trace/trace_dynevent.c
> +++ b/kernel/trace/trace_dynevent.c
> @@ -74,7 +74,7 @@ int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type)
>  static int create_dyn_event(int argc, char **argv)
>  {
>  	struct dyn_event_operations *ops;
> -	int ret;
> +	int ret = 0;
>  
>  	if (argv[0][0] == '-' || argv[0][0] == '!')
>  		return dyn_event_release(argc, argv, NULL);
>
Steven Rostedt March 14, 2019, 10:19 p.m. UTC | #2
On Thu, 14 Mar 2019 14:05:02 -0700
Frank Rowand <frowand.list@gmail.com> wrote:

> Hi Steve,
> 
> Ping.

Thanks, this got buried.

> >  static int create_dyn_event(int argc, char **argv)
> >  {
> >  	struct dyn_event_operations *ops;
> > -	int ret;
> > +	int ret = 0;

Probably should be ret = -ENODEV;

As if ret doesn't get set, then no dynamic code has been registered,
and something is truly wrong.

-- Steve


> >  
> >  	if (argv[0][0] == '-' || argv[0][0] == '!')
> >  		return dyn_event_release(argc, argv, NULL);
> >
Masami Hiramatsu March 14, 2019, 11:26 p.m. UTC | #3
Hi Frank and Steve,

Thank you for pointing it out :)

On Thu, 14 Mar 2019 18:19:08 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 14 Mar 2019 14:05:02 -0700
> Frank Rowand <frowand.list@gmail.com> wrote:
> 
> > Hi Steve,
> > 
> > Ping.
> 
> Thanks, this got buried.
> 
> > >  static int create_dyn_event(int argc, char **argv)
> > >  {
> > >  	struct dyn_event_operations *ops;
> > > -	int ret;
> > > +	int ret = 0;
> 
> Probably should be ret = -ENODEV;
> 
> As if ret doesn't get set, then no dynamic code has been registered,
> and something is truly wrong.

I Agreed to return -ENODEV instead of 0.

Thank you,

> 
> -- Steve
> 
> 
> > >  
> > >  	if (argv[0][0] == '-' || argv[0][0] == '!')
> > >  		return dyn_event_release(argc, argv, NULL);
> > >   
>
Frank Rowand March 15, 2019, 3:56 p.m. UTC | #4
On 3/14/19 4:26 PM, Masami Hiramatsu wrote:
> Hi Frank and Steve,
> 
> Thank you for pointing it out :)
> 
> On Thu, 14 Mar 2019 18:19:08 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
>> On Thu, 14 Mar 2019 14:05:02 -0700
>> Frank Rowand <frowand.list@gmail.com> wrote:
>>
>>> Hi Steve,
>>>
>>> Ping.
>>
>> Thanks, this got buried.
>>
>>>>  static int create_dyn_event(int argc, char **argv)
>>>>  {
>>>>  	struct dyn_event_operations *ops;
>>>> -	int ret;
>>>> +	int ret = 0;
>>
>> Probably should be ret = -ENODEV;
>>
>> As if ret doesn't get set, then no dynamic code has been registered,
>> and something is truly wrong.
> 
> I Agreed to return -ENODEV instead of 0.
> 
> Thank you,
> 
>>
>> -- Steve
>>
>>
>>>>  
>>>>  	if (argv[0][0] == '-' || argv[0][0] == '!')
>>>>  		return dyn_event_release(argc, argv, NULL);
>>>>   
>>
> 
> 

Thanks, I'll fix and resend.

Patch
diff mbox series

diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c
index dd1f43588d70..4f633476c307 100644
--- a/kernel/trace/trace_dynevent.c
+++ b/kernel/trace/trace_dynevent.c
@@ -74,7 +74,7 @@  int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type)
 static int create_dyn_event(int argc, char **argv)
 {
 	struct dyn_event_operations *ops;
-	int ret;
+	int ret = 0;
 
 	if (argv[0][0] == '-' || argv[0][0] == '!')
 		return dyn_event_release(argc, argv, NULL);