grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix gcc 4.7 warning in usbtest.c


From: Andreas Jaeger
Subject: Fix gcc 4.7 warning in usbtest.c
Date: Fri, 16 Mar 2012 10:10:32 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0

Building grub2 with gcc 4.7 snapshot, I see:
commands/usbtest.c: In function 'usb_print_str':
commands/usbtest.c:126:19: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors

line 121 is:
121:   err = grub_usb_get_string (dev, idx, 0x0409, &name);

gcc does not seem to understand that name is only set if grub_usb_get_string returns without an error.

Here's the obvious patch to fix this,
Andreas

Index: grub-1.99/grub-core/commands/usbtest.c
===================================================================
--- grub-1.99.orig/grub-core/commands/usbtest.c
+++ grub-1.99/grub-core/commands/usbtest.c
@@ -111,7 +111,7 @@ grub_usb_get_string (grub_usb_device_t d
 static void
 usb_print_str (const char *description, grub_usb_device_t dev, int idx)
 {
-  char *name;
+  char *name = NULL;
   grub_usb_err_t err;
   /* XXX: LANGID  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]