Patchwork [U-Boot] common/spl: Mark arguments as unused

login
register
mail settings
Submitter Vikram Narayanan
Date Oct. 23, 2012, 10:05 a.m.
Message ID <50866BEC.1030601@gmail.com>
Download mbox | patch
Permalink /patch/193415/
State Superseded
Headers show

Comments

Vikram Narayanan - Oct. 23, 2012, 10:05 a.m.
As dummy{1,2} are not used anywhere, mark it with __maybe_unused

Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
Cc: Stefan Roese <sr@denx.de>
---
 common/spl/spl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Stefan Roese - Oct. 23, 2012, 10:26 a.m.
On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
> As dummy{1,2} are not used anywhere, mark it with __maybe_unused
>
> Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
> Cc: Stefan Roese <sr@denx.de>
> ---
>  common/spl/spl.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 0d829c0..62fd3bd 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
>  }
>  #endif
>  
> -void board_init_r(gd_t *dummy1, ulong dummy2)
> +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused ulong dummy2)
>  {
>  	u32 boot_device;
>  	debug(">>spl:board_init_r()\n");
> 

Perhaps even __always_unused instead of __maybe_unused as these
variables are never used?

Thanks,
Stefan
Vikram Narayanan - Oct. 23, 2012, 10:55 a.m.
On 10/23/2012 3:56 PM, Stefan Roese wrote:
> On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
>> As dummy{1,2} are not used anywhere, mark it with __maybe_unused
>>
>> Signed-off-by: Vikram Narayanan<vikram186@gmail.com>
>> Cc: Stefan Roese<sr@denx.de>
>> ---
>>   common/spl/spl.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index 0d829c0..62fd3bd 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
>>   }
>>   #endif
>>
>> -void board_init_r(gd_t *dummy1, ulong dummy2)
>> +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused ulong dummy2)
>>   {
>>   	u32 boot_device;
>>   	debug(">>spl:board_init_r()\n");
>>
>
> Perhaps even __always_unused instead of __maybe_unused as these
> variables are never used?

Yes. It is better, in the case if it is never used at all.

Thanks,
Vikram
Tom Rini - Oct. 23, 2012, 3:45 p.m.
On Tue, Oct 23, 2012 at 12:26:53PM +0200, Stefan Roese wrote:
> On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
> > As dummy{1,2} are not used anywhere, mark it with __maybe_unused
> >
> > Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
> > Cc: Stefan Roese <sr@denx.de>
> > ---
> >  common/spl/spl.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/common/spl/spl.c b/common/spl/spl.c
> > index 0d829c0..62fd3bd 100644
> > --- a/common/spl/spl.c
> > +++ b/common/spl/spl.c
> > @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
> >  }
> >  #endif
> >  
> > -void board_init_r(gd_t *dummy1, ulong dummy2)
> > +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused ulong dummy2)
> >  {
> >  	u32 boot_device;
> >  	debug(">>spl:board_init_r()\n");
> > 
> 
> Perhaps even __always_unused instead of __maybe_unused as these
> variables are never used?

Also, what does this give us?  Fixing a sparse warning?
Vikram Narayanan - Oct. 23, 2012, 5:15 p.m.
On 10/23/2012 9:15 PM, Tom Rini wrote:
> On Tue, Oct 23, 2012 at 12:26:53PM +0200, Stefan Roese wrote:
>> On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
>>> As dummy{1,2} are not used anywhere, mark it with __maybe_unused
>>>
>>> Signed-off-by: Vikram Narayanan<vikram186@gmail.com>
>>> Cc: Stefan Roese<sr@denx.de>
>>> ---
>>>   common/spl/spl.c |    2 +-
>>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>>> index 0d829c0..62fd3bd 100644
>>> --- a/common/spl/spl.c
>>> +++ b/common/spl/spl.c
>>> @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
>>>   }
>>>   #endif
>>>
>>> -void board_init_r(gd_t *dummy1, ulong dummy2)
>>> +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused ulong dummy2)
>>>   {
>>>   	u32 boot_device;
>>>   	debug(">>spl:board_init_r()\n");
>>>
>>
>> Perhaps even __always_unused instead of __maybe_unused as these
>> variables are never used?
>
> Also, what does this give us?  Fixing a sparse warning?

Not a sparse warning. I noticed this while looking at the code.

~Vikram
Scott Wood - Oct. 24, 2012, 1:52 a.m.
On 10/23/2012 12:15:11 PM, Vikram Narayanan wrote:
> On 10/23/2012 9:15 PM, Tom Rini wrote:
>> On Tue, Oct 23, 2012 at 12:26:53PM +0200, Stefan Roese wrote:
>>> On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
>>>> As dummy{1,2} are not used anywhere, mark it with __maybe_unused
>>>> 
>>>> Signed-off-by: Vikram Narayanan<vikram186@gmail.com>
>>>> Cc: Stefan Roese<sr@denx.de>
>>>> ---
>>>>   common/spl/spl.c |    2 +-
>>>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>>> 
>>>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>>>> index 0d829c0..62fd3bd 100644
>>>> --- a/common/spl/spl.c
>>>> +++ b/common/spl/spl.c
>>>> @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
>>>>   }
>>>>   #endif
>>>> 
>>>> -void board_init_r(gd_t *dummy1, ulong dummy2)
>>>> +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused  
>>>> ulong dummy2)
>>>>   {
>>>>   	u32 boot_device;
>>>>   	debug(">>spl:board_init_r()\n");
>>>> 
>>> 
>>> Perhaps even __always_unused instead of __maybe_unused as these
>>> variables are never used?
>> 
>> Also, what does this give us?  Fixing a sparse warning?
> 
> Not a sparse warning. I noticed this while looking at the code.

If there's no warning, why do we need to ugly up the code with  
__maybe_unused?

Unused arguments are quite common, as a result of implementing a common  
interface where this implementation doesn't need all the information  
that the interface provides.  It should not cause a warning and should  
not require annotation.

-Scott
Vikram Narayanan - Oct. 24, 2012, 4:14 a.m.
On 10/24/2012 7:22 AM, Scott Wood wrote:
> On 10/23/2012 12:15:11 PM, Vikram Narayanan wrote:
>> On 10/23/2012 9:15 PM, Tom Rini wrote:
>>> On Tue, Oct 23, 2012 at 12:26:53PM +0200, Stefan Roese wrote:
>>>> On 10/23/2012 12:05 PM, Vikram Narayanan wrote:
>>>>> As dummy{1,2} are not used anywhere, mark it with __maybe_unused
>>>>>
>>>>> Signed-off-by: Vikram Narayanan<vikram186@gmail.com>
>>>>> Cc: Stefan Roese<sr@denx.de>
>>>>> ---
>>>>> common/spl/spl.c | 2 +-
>>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>>>>> index 0d829c0..62fd3bd 100644
>>>>> --- a/common/spl/spl.c
>>>>> +++ b/common/spl/spl.c
>>>>> @@ -145,7 +145,7 @@ static void spl_ram_load_image(void)
>>>>> }
>>>>> #endif
>>>>>
>>>>> -void board_init_r(gd_t *dummy1, ulong dummy2)
>>>>> +void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused
>>>>> ulong dummy2)
>>>>> {
>>>>> u32 boot_device;
>>>>> debug(">>spl:board_init_r()\n");
>>>>>
>>>>
>>>> Perhaps even __always_unused instead of __maybe_unused as these
>>>> variables are never used?
>>>
>>> Also, what does this give us? Fixing a sparse warning?
>>
>> Not a sparse warning. I noticed this while looking at the code.
>
> If there's no warning, why do we need to ugly up the code with
> __maybe_unused?

I'd rather call this a proper way of coding, than calling it ugly. But 
perceptions differ.

> Unused arguments are quite common, as a result of implementing a common
> interface where this implementation doesn't need all the information
> that the interface provides. It should not cause a warning and should
> not require annotation.

~Vikram

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 0d829c0..62fd3bd 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -145,7 +145,7 @@  static void spl_ram_load_image(void)
 }
 #endif
 
-void board_init_r(gd_t *dummy1, ulong dummy2)
+void board_init_r(__maybe_unused gd_t *dummy1, __maybe_unused ulong dummy2)
 {
 	u32 boot_device;
 	debug(">>spl:board_init_r()\n");