diff mbox

[U-Boot,RFC,18/20] sandbox: Remove unused variable warnings

Message ID 1316278139-28635-19-git-send-email-sjg@chromium.org
State Superseded, archived
Headers show

Commit Message

Simon Glass Sept. 17, 2011, 4:48 p.m. UTC
There are a few variables set but not used - this marks these as unused
for the compiler.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_mem.c    |    2 +-
 common/cmd_nvedit.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Mike Frysinger Sept. 18, 2011, 12:25 a.m. UTC | #1
On Saturday, September 17, 2011 12:48:57 Simon Glass wrote:
> There are a few variables set but not used - this marks these as unused
> for the compiler.

summary says "sandbox:" but i dont think this has anything to do with sandbox.  
you're just using a newer compiler.

> --- a/common/cmd_mem.c
> +++ b/common/cmd_mem.c
>
> -	ulong	addr, length, i, junk;
> +	ulong	addr, length, i, junk __attribute__((unused));

this one is tricky as we just want to read the value from the volatile 
pointer.  i'm guessing do "*longp++;" just adds a different warning ?

> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
>
> -	int len;
> +	int len __attribute((unused));

this file though looks like we should just delete "len"
-mike
Simon Glass Sept. 23, 2011, 4:01 p.m. UTC | #2
Hi Mike,

On Sat, Sep 17, 2011 at 5:25 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Saturday, September 17, 2011 12:48:57 Simon Glass wrote:
>> There are a few variables set but not used - this marks these as unused
>> for the compiler.
>
> summary says "sandbox:" but i dont think this has anything to do with sandbox.
> you're just using a newer compiler.
>
>> --- a/common/cmd_mem.c
>> +++ b/common/cmd_mem.c
>>
>> -     ulong   addr, length, i, junk;
>> +     ulong   addr, length, i, junk __attribute__((unused));
>
> this one is tricky as we just want to read the value from the volatile
> pointer.  i'm guessing do "*longp++;" just adds a different warning ?

Isn't that a nop?

Well I can just assign it to a different variable - I will use 'size'
in my new patch set.

>
>> --- a/common/cmd_nvedit.c
>> +++ b/common/cmd_nvedit.c
>>
>> -     int len;
>> +     int len __attribute((unused));
>
> this file though looks like we should just delete "len"

Yes, done. I don't use lint anyway.

Regards,
Simon

> -mike
>
Mike Frysinger Sept. 26, 2011, 4:49 a.m. UTC | #3
On Friday, September 23, 2011 12:01:46 Simon Glass wrote:
> On Sat, Sep 17, 2011 at 5:25 PM, Mike Frysinger wrote:
> > On Saturday, September 17, 2011 12:48:57 Simon Glass wrote:
> >> There are a few variables set but not used - this marks these as unused
> >> for the compiler.
> > 
> > summary says "sandbox:" but i dont think this has anything to do with
> > sandbox. you're just using a newer compiler.
> > 
> >> --- a/common/cmd_mem.c
> >> +++ b/common/cmd_mem.c
> >> 
> >> -     ulong   addr, length, i, junk;
> >> +     ulong   addr, length, i, junk __attribute__((unused));
> > 
> > this one is tricky as we just want to read the value from the volatile
> > pointer.  i'm guessing do "*longp++;" just adds a different warning ?
> 
> Isn't that a nop?

if it's volatile, it shouldn't be

> Well I can just assign it to a different variable - I will use 'size'
> in my new patch set.

Marek Vasut posted a patch which dropped the assignment and it seems to not 
add any warnings

> >> --- a/common/cmd_nvedit.c
> >> +++ b/common/cmd_nvedit.c
> >> 
> >> -     int len;
> >> +     int len __attribute((unused));
> > 
> > this file though looks like we should just delete "len"
> 
> Yes, done. I don't use lint anyway.

he also posted a fix for this :)
-mike
Simon Glass Sept. 26, 2011, 6:07 p.m. UTC | #4
Hi Mike,

On Sun, Sep 25, 2011 at 9:49 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Friday, September 23, 2011 12:01:46 Simon Glass wrote:
>> On Sat, Sep 17, 2011 at 5:25 PM, Mike Frysinger wrote:
>> > On Saturday, September 17, 2011 12:48:57 Simon Glass wrote:
>> >> There are a few variables set but not used - this marks these as unused
>> >> for the compiler.
>> >
>> > summary says "sandbox:" but i dont think this has anything to do with
>> > sandbox. you're just using a newer compiler.
>> >
>> >> --- a/common/cmd_mem.c
>> >> +++ b/common/cmd_mem.c
>> >>
>> >> -     ulong   addr, length, i, junk;
>> >> +     ulong   addr, length, i, junk __attribute__((unused));
>> >
>> > this one is tricky as we just want to read the value from the volatile
>> > pointer.  i'm guessing do "*longp++;" just adds a different warning ?
>>
>> Isn't that a nop?
>
> if it's volatile, it shouldn't be

I missed that. checkpatch warns me so badly on volatile that I assumed
we didn't use it :-)

>
>> Well I can just assign it to a different variable - I will use 'size'
>> in my new patch set.
>
> Marek Vasut posted a patch which dropped the assignment and it seems to not
> add any warnings

Yes, just tried it and it works fine.

Regards,
Simon

>
>> >> --- a/common/cmd_nvedit.c
>> >> +++ b/common/cmd_nvedit.c
>> >>
>> >> -     int len;
>> >> +     int len __attribute((unused));
>> >
>> > this file though looks like we should just delete "len"
>>
>> Yes, done. I don't use lint anyway.
>
> he also posted a fix for this :)
> -mike
>
diff mbox

Patch

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4daa1b3..1168766 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -471,7 +471,7 @@  int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	ulong	addr, length, i, junk;
+	ulong	addr, length, i, junk __attribute__((unused));
 	int	size;
 	volatile uint	*longp;
 	volatile ushort *shortp;
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e8b116d..cf6601d 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -460,7 +460,7 @@  int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 	char *init_val;
-	int len;
+	int len __attribute((unused));
 
 	if (argc < 2)
 		return cmd_usage(cmdtp);