Patchwork [U-Boot,01/12] microblaze: board: Remove compilation warning

login
register
mail settings
Submitter Michal Simek
Date July 9, 2012, 9:20 a.m.
Message ID <1341825639-23475-1-git-send-email-monstr@monstr.eu>
Download mbox | patch
Permalink /patch/169719/
State Accepted
Delegated to: Michal Simek
Headers show

Comments

Michal Simek - July 9, 2012, 9:20 a.m.
Variable is used when CONFIG_SYS_FLASH_CHECKSUM is used.

Warning log:
board.c: In function 'board_init':
board.c:101: warning: unused variable 's'

Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/lib/board.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
Simon Glass - July 9, 2012, 9:08 p.m.
Hi Michal,

On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr@monstr.eu> wrote:

> Variable is used when CONFIG_SYS_FLASH_CHECKSUM is used.
>
> Warning log:
> board.c: In function 'board_init':
> board.c:101: warning: unused variable 's'
>
> Signed-off-by: Michal Simek <monstr@monstr.eu>
> ---
>  arch/microblaze/lib/board.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
> index a8ed7ce..4146f5c 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -98,7 +98,6 @@ void board_init (void)
>         gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
>         bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
>                                                 - GENERATED_BD_INFO_SIZE);
> -       char *s;
>  #if defined(CONFIG_CMD_FLASH)
>         ulong flash_size = 0;
>  #endif
> @@ -157,9 +156,9 @@ void board_init (void)
>         puts ("Flash: ");
>         bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
>         if (0 < (flash_size = flash_init ())) {
> -               bd->bi_flashsize = flash_size;
> -               bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
>  # ifdef CONFIG_SYS_FLASH_CHECKSUM
> +               char *s;
> +
>

Is it a good idea to put declarations in the middle of the code? I don't
think that is U-Boot style.

You could instead use __maybe_unused on the variable, or #ifdef the
declaration :-(


>                 print_size (flash_size, "");
>                 /*
>                  * Compute and print flash CRC if flashchecksum is set to
> 'y'
> @@ -176,6 +175,8 @@ void board_init (void)
>  # else /* !CONFIG_SYS_FLASH_CHECKSUM */
>                 print_size (flash_size, "\n");
>  # endif /* CONFIG_SYS_FLASH_CHECKSUM */
> +               bd->bi_flashsize = flash_size;
> +               bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
>         } else {
>                 puts ("Flash init FAILED");
>                 bd->bi_flashstart = 0;
> --
> 1.7.0.4
>
> Regards,
Simon
Michal Simek - July 10, 2012, 8:17 a.m.
On 07/09/2012 11:08 PM, Simon Glass wrote:
> Hi Michal,
>
> On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr@monstr.eu <mailto:monstr@monstr.eu>> wrote:
>
>     Variable is used when CONFIG_SYS_FLASH_CHECKSUM is used.
>
>     Warning log:
>     board.c: In function 'board_init':
>     board.c:101: warning: unused variable 's'
>
>     Signed-off-by: Michal Simek <monstr@monstr.eu <mailto:monstr@monstr.eu>>
>     ---
>       arch/microblaze/lib/board.c |    7 ++++---
>       1 files changed, 4 insertions(+), 3 deletions(-)
>
>     diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
>     index a8ed7ce..4146f5c 100644
>     --- a/arch/microblaze/lib/board.c
>     +++ b/arch/microblaze/lib/board.c
>     @@ -98,7 +98,6 @@ void board_init (void)
>              gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
>              bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
>                                                      - GENERATED_BD_INFO_SIZE);
>     -       char *s;
>       #if defined(CONFIG_CMD_FLASH)
>              ulong flash_size = 0;
>       #endif
>     @@ -157,9 +156,9 @@ void board_init (void)
>              puts ("Flash: ");
>              bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
>              if (0 < (flash_size = flash_init ())) {
>     -               bd->bi_flashsize = flash_size;
>     -               bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
>       # ifdef CONFIG_SYS_FLASH_CHECKSUM
>     +               char *s;
>     +
>
>
> Is it a good idea to put declarations in the middle of the code? I don't think that is U-Boot style.
>
> You could instead use __maybe_unused on the variable, or #ifdef the declaration :-(

I wanted to avoid that ifdef mess. Will look at __maybe_unused. I wasn't aware about it.

Thanks,
Michal

Patch

diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index a8ed7ce..4146f5c 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -98,7 +98,6 @@  void board_init (void)
 	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
 	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
 						- GENERATED_BD_INFO_SIZE);
-	char *s;
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
@@ -157,9 +156,9 @@  void board_init (void)
 	puts ("Flash: ");
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
 	if (0 < (flash_size = flash_init ())) {
-		bd->bi_flashsize = flash_size;
-		bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
+		char *s;
+
 		print_size (flash_size, "");
 		/*
 		 * Compute and print flash CRC if flashchecksum is set to 'y'
@@ -176,6 +175,8 @@  void board_init (void)
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
 		print_size (flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
+		bd->bi_flashsize = flash_size;
+		bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
 	} else {
 		puts ("Flash init FAILED");
 		bd->bi_flashstart = 0;