Thread (2 messages) flat view 2 messages, 2 authors, 2012-02-27

Re: [PATCH] hciemu: Always initialize status in hci_host_control

From: Marcel Holtmann <marcel@holtmann.org>
Date: 2012-02-27 17:20:33

Hi Szymon,
Assign 0x00 to status on intialization instead of assigning it in each
switch case. This helps to avoid errors when one forget to proper
intialize status in new case.

This fix following compilation error:

  CC     test/hciemu.o
cc1: warnings being treated as errors
test/hciemu.c: In function ‘hci_host_control’:
test/hciemu.c:786: error: ‘status’ may be used uninitialized in this function
make[1]: *** [test/hciemu.o] Error 1
actually gcc warns here rightfully, but the fix is actually a different
one:
@@ -783,7 +783,7 @@ static void hci_host_control(uint16_t ocf, int plen, uint8_t
                break;
 
        default:
-               command_status(ogf, ocf, status);
+               command_status(ogf, ocf, 0x01);
                break;
        }
Pushed that one upstream.

I am always suspicious if the fix to a compiler warning like this is
just to initialize the variable. We prefer not to do that since then it
starts hiding real bugs. This is a good example.

Regards

Marcel

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help