Skip to contentSkip to conversation

cmd: disk: Fix unused variable warning

PATCH In review Marek Vasut 3 participants 4 messages Apr 30, 2016 – May 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: disk: Fix unused variable warning

If serial support is not compiled into U-Boot, which may be the case for some SPL builds, the following warning will be generated in disk.c:

cmd/disk.c: In function 'common_diskboot':
cmd/disk.c:16:6: warning: variable 'dev' set but not used [-Wunused-but-set-variable]

  int dev, part;
      ^

The warning is a result of printf() calls being optimized away, and thus the whole dev variable becomes indeed unused. Mark the variable as __maybe_unused .

---
 cmd/disk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cmd/disk.c +2 -1
index 2fd1717..4c88554 100644
@@ -13,7 +13,8 @@
 int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
 		    char *const argv[])
 {
-	int dev, part;
+	__maybe_unused int dev;
+	int part;
 	ulong addr = CONFIG_SYS_LOAD_ADDR;
 	ulong cnt;
 	disk_partition_t info;
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/1 cmd: disk: Fix unused variable warning

Quoted 11 lines · Marek Vasut

If serial support is not compiled into U-Boot, which may be the case for some SPL builds, the following warning will be generated in disk.c:

cmd/disk.c: In function 'common_diskboot':
cmd/disk.c:16:6: warning: variable 'dev' set but not used [-Wunused-but-set-variable]

  int dev, part;
      ^

The warning is a result of printf() calls being optimized away, and thus the whole dev variable becomes indeed unused. Mark the variable as __maybe_unused .

Quoted 6 lines
---
 cmd/disk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#2 lore raw

PATCH 1/1 cmd: disk: Fix unused variable warning

In reply to Marek Vasut
Quoted 7 lines · Marek Vasut

If serial support is not compiled into U-Boot, which may be the case for some SPL builds, the following warning will be generated in disk.c:

cmd/disk.c: In function 'common_diskboot':
cmd/disk.c:16:6: warning: variable 'dev' set but not used [-Wunused-but-set-variable]

  int dev, part;
      ^
Quoted 7 lines

The warning is a result of printf() calls being optimized away, and thus the whole dev variable becomes indeed unused. Mark the variable as __maybe_unused .

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160502/1214ec1a/attachment.sig>
#3 lore raw
In reply to Marek Vasut
Quoted 11 lines · Marek Vasut

If serial support is not compiled into U-Boot, which may be the case for some SPL builds, the following warning will be generated in disk.c:

cmd/disk.c: In function 'common_diskboot':
cmd/disk.c:16:6: warning: variable 'dev' set but not used [-Wunused-but-set-variable]

  int dev, part;
      ^

The warning is a result of printf() calls being optimized away, and thus the whole dev variable becomes indeed unused. Mark the variable as __maybe_unused .

Quoted 5 lines

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/fbc3c74c/attachment.sig>