diff mbox

[U-Boot,02/11] MIPS: board.c: fix warning if CONFIG_CMD_NET is not defined

Message ID 1322143076-20349-3-git-send-email-daniel.schwierzeck@googlemail.com
State Superseded
Headers show

Commit Message

Daniel Schwierzeck Nov. 24, 2011, 1:57 p.m. UTC
board.c: In function 'board_init_r':
board.c:280:8: warning: unused variable 's'

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
 arch/mips/lib/board.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Comments

Marek Vasut Nov. 25, 2011, 8:39 a.m. UTC | #1
> board.c: In function 'board_init_r':
> board.c:280:8: warning: unused variable 's'
> 
> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
> ---
>  arch/mips/lib/board.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> index 9585db7..aac7690 100644
> --- a/arch/mips/lib/board.c
> +++ b/arch/mips/lib/board.c
> @@ -266,7 +266,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  #ifndef CONFIG_ENV_IS_NOWHERE
>  	extern char *env_name_spec;
>  #endif
> -	char *s;
>  	bd_t *bd;
> 
>  	gd = id;
> @@ -347,7 +346,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* Initialize from environment */
>  	load_addr = getenv_ulong("loadaddr", 16, load_addr);
>  #if defined(CONFIG_CMD_NET)
> -	s = getenv("bootfile");
> +	const char *s = getenv("bootfile");
>  	if (s)
>  		copy_filename(BootFile, s, sizeof(BootFile));
>  #endif

Are you sure about this "const" thing? Also, try compiling the stuff with 
gcc4.6, it'll reveal more errors.
Daniel Schwierzeck Nov. 25, 2011, 12:37 p.m. UTC | #2
On Fri, Nov 25, 2011 at 9:39 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
>> board.c: In function 'board_init_r':
>> board.c:280:8: warning: unused variable 's'
>>
>> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
>> ---
>>  arch/mips/lib/board.c |    3 +--
>>  1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
>> index 9585db7..aac7690 100644
>> --- a/arch/mips/lib/board.c
>> +++ b/arch/mips/lib/board.c
>> @@ -266,7 +266,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
>>  #ifndef CONFIG_ENV_IS_NOWHERE
>>       extern char *env_name_spec;
>>  #endif
>> -     char *s;
>>       bd_t *bd;
>>
>>       gd = id;
>> @@ -347,7 +346,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
>>       /* Initialize from environment */
>>       load_addr = getenv_ulong("loadaddr", 16, load_addr);
>>  #if defined(CONFIG_CMD_NET)
>> -     s = getenv("bootfile");
>> +     const char *s = getenv("bootfile");
>>       if (s)
>>               copy_filename(BootFile, s, sizeof(BootFile));
>>  #endif
>
> Are you sure about this "const" thing? Also, try compiling the stuff with
> gcc4.6, it'll reveal more errors.
>

yes, s is only used in the if and as parameter for copy_filename. The
function signature
also have const:

extern void	copy_filename (char *dst, const char *src, int size);

And gcc-4.6.2 compiles that part without warnings.
Marek Vasut Nov. 25, 2011, 1:41 p.m. UTC | #3
> On Fri, Nov 25, 2011 at 9:39 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> >> board.c: In function 'board_init_r':
> >> board.c:280:8: warning: unused variable 's'
> >> 
> >> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
> >> ---
> >>  arch/mips/lib/board.c |    3 +--
> >>  1 files changed, 1 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> >> index 9585db7..aac7690 100644
> >> --- a/arch/mips/lib/board.c
> >> +++ b/arch/mips/lib/board.c
> >> @@ -266,7 +266,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
> >>  #ifndef CONFIG_ENV_IS_NOWHERE
> >>       extern char *env_name_spec;
> >>  #endif
> >> -     char *s;
> >>       bd_t *bd;
> >> 
> >>       gd = id;
> >> @@ -347,7 +346,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
> >>       /* Initialize from environment */
> >>       load_addr = getenv_ulong("loadaddr", 16, load_addr);
> >>  #if defined(CONFIG_CMD_NET)
> >> -     s = getenv("bootfile");
> >> +     const char *s = getenv("bootfile");
> >>       if (s)
> >>               copy_filename(BootFile, s, sizeof(BootFile));
> >>  #endif
> > 
> > Are you sure about this "const" thing? Also, try compiling the stuff with
> > gcc4.6, it'll reveal more errors.
> 
> yes, s is only used in the if and as parameter for copy_filename. The
> function signature
> also have const:
> 
> extern void	copy_filename (char *dst, const char *src, int size);
> 
> And gcc-4.6.2 compiles that part without warnings.

Ok, that's good then! :)
Wolfgang Denk Dec. 9, 2011, 9:50 a.m. UTC | #4
Dear Daniel Schwierzeck,

In message <1322143076-20349-3-git-send-email-daniel.schwierzeck@googlemail.com> you wrote:
> board.c: In function 'board_init_r':
> board.c:280:8: warning: unused variable 's'
...
>  	/* Initialize from environment */
>  	load_addr = getenv_ulong("loadaddr", 16, load_addr);
>  #if defined(CONFIG_CMD_NET)
> -	s = getenv("bootfile");
> +	const char *s = getenv("bootfile");
>  	if (s)
>  		copy_filename(BootFile, s, sizeof(BootFile));

We don't allow declarations in the middle of the code.

[This issue has also been fixed since, so no further actiuvity needed.]

Best regards,

Wolfgang Denk
Daniel Schwierzeck Dec. 9, 2011, 12:34 p.m. UTC | #5
Hi Wolfgang,

On Fri, Dec 9, 2011 at 10:50 AM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Daniel Schwierzeck,
>
> In message <1322143076-20349-3-git-send-email-daniel.schwierzeck@googlemail.com> you wrote:
>> board.c: In function 'board_init_r':
>> board.c:280:8: warning: unused variable 's'
> ...
>>       /* Initialize from environment */
>>       load_addr = getenv_ulong("loadaddr", 16, load_addr);
>>  #if defined(CONFIG_CMD_NET)
>> -     s = getenv("bootfile");
>> +     const char *s = getenv("bootfile");
>>       if (s)
>>               copy_filename(BootFile, s, sizeof(BootFile));
>
> We don't allow declarations in the middle of the code.
>
> [This issue has also been fixed since, so no further actiuvity needed.]

ok, I marked my patch in patchwork as superseded.
diff mbox

Patch

diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index 9585db7..aac7690 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -266,7 +266,6 @@  void board_init_r(gd_t *id, ulong dest_addr)
 #ifndef CONFIG_ENV_IS_NOWHERE
 	extern char *env_name_spec;
 #endif
-	char *s;
 	bd_t *bd;
 
 	gd = id;
@@ -347,7 +346,7 @@  void board_init_r(gd_t *id, ulong dest_addr)
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
 #if defined(CONFIG_CMD_NET)
-	s = getenv("bootfile");
+	const char *s = getenv("bootfile");
 	if (s)
 		copy_filename(BootFile, s, sizeof(BootFile));
 #endif