From: Marcel Holtmann <marcel@holtmann.org>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org, kanak.gupta@stericsson.com
Subject: Re: [PATCH] hciemu: Always initialize status in hci_host_control
Date: Mon, 27 Feb 2012 09:20:33 -0800 [thread overview]
Message-ID: <1330363233.3392.50.camel@aeonflux> (raw)
In-Reply-To: <1330344231-22823-1-git-send-email-szymon.janc@tieto.com>
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
prev parent reply other threads:[~2012-02-27 17:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-27 12:03 [PATCH] hciemu: Always initialize status in hci_host_control Szymon Janc
2012-02-27 17:20 ` Marcel Holtmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330363233.3392.50.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=kanak.gupta@stericsson.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).