* [PATCH BlueZ] btmgmt: fix used without initialization
@ 2011-11-07 16:58 Claudio Takahasi
2011-11-07 19:36 ` Johan Hedberg
0 siblings, 1 reply; 3+ messages in thread
From: Claudio Takahasi @ 2011-11-07 16:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch fixes the following warning being treated as error:
mgmt/main.c: In function 'mgmt_process_data':
mgmt/main.c:508:3: error: 'len' may be used uninitialized in this
function [-Werror=uninitialized]
---
mgmt/main.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/mgmt/main.c b/mgmt/main.c
index c970f62..d939cca 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
@@ -504,8 +504,10 @@ static int mgmt_process_data(int mgmt_sk)
ret = read(mgmt_sk, buf, sizeof(buf));
if (ret < 0) {
- fprintf(stderr, "read: %s\n", strerror(errno));
- return len;
+ int err = errno;
+
+ fprintf(stderr, "read: %s\n", strerror(err));
+ return -err;
}
if (ret < MGMT_HDR_SIZE) {
--
1.7.7.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ] btmgmt: fix used without initialization
2011-11-07 16:58 [PATCH BlueZ] btmgmt: fix used without initialization Claudio Takahasi
@ 2011-11-07 19:36 ` Johan Hedberg
2011-11-07 20:08 ` Anderson Lizardo
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2011-11-07 19:36 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Mon, Nov 07, 2011, Claudio Takahasi wrote:
> This patch fixes the following warning being treated as error:
> mgmt/main.c: In function 'mgmt_process_data':
> mgmt/main.c:508:3: error: 'len' may be used uninitialized in this
> function [-Werror=uninitialized]
> ---
> mgmt/main.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
Thanks for the heads-up. Seems like my gcc is buggy since it doesn't
catch this even when I use bootstrap-configure. The original intent of
the code was to have return ret which is what I pushed as a fix (-errno
would be more sophisticated but then it'd make sense to fix several
other places in the code too). Btw, please keep "int err" variables
negative so that we have consistency in the code-base and avoid stupid
bugs.
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ] btmgmt: fix used without initialization
2011-11-07 19:36 ` Johan Hedberg
@ 2011-11-07 20:08 ` Anderson Lizardo
0 siblings, 0 replies; 3+ messages in thread
From: Anderson Lizardo @ 2011-11-07 20:08 UTC (permalink / raw)
To: Claudio Takahasi, linux-bluetooth
Hi Johan,
On Mon, Nov 7, 2011 at 3:36 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Mon, Nov 07, 2011, Claudio Takahasi wrote:
>> This patch fixes the following warning being treated as error:
>> mgmt/main.c: In function 'mgmt_process_data':
>> mgmt/main.c:508:3: error: 'len' may be used uninitialized in this
>> function [-Werror=uninitialized]
>> ---
>> mgmt/main.c | 6 ++++--
>> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> Thanks for the heads-up. Seems like my gcc is buggy since it doesn't
> catch this even when I use bootstrap-configure. The original intent of
> the code was to have return ret which is what I pushed as a fix (-errno
> would be more sophisticated but then it'd make sense to fix several
> other places in the code too). Btw, please keep "int err" variables
> negative so that we have consistency in the code-base and avoid stupid
> bugs.
Actually we are not consistent yet:
$ grep -r 'int err.*errno;' *
audio/avdtp.c: int err = -errno;
audio/avdtp.c: int err = -errno;
btio/btio.c: int error = -errno;
btio/btio.c: int error = -errno;
btio/btio.c: int error = -errno;
network/common.c: int err = errno;
network/common.c: int err = errno;
network/common.c: int err = errno;
serial/port.c: int err = -errno;
serial/port.c: int err = -errno;
time/server.c: int err = errno; (*)
tools/hcitool.c: int err = errno;
This one is from a patch I sent (not yet applied), will fix.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-07 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-07 16:58 [PATCH BlueZ] btmgmt: fix used without initialization Claudio Takahasi
2011-11-07 19:36 ` Johan Hedberg
2011-11-07 20:08 ` Anderson Lizardo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox