* [Qemu-devel] [RFC, PATCH 2/2] bt-sdp: Fix if statement with empty body, spotted by clang
@ 2010-04-18 8:52 Blue Swirl
2010-04-22 1:58 ` [Qemu-devel] " andrzej zaborowski
0 siblings, 1 reply; 2+ messages in thread
From: Blue Swirl @ 2010-04-18 8:52 UTC (permalink / raw)
To: Andrzej Zaborowski, qemu-devel
Fix clang error:
CC bt-sdp.o
/src/qemu/hw/bt-sdp.c:174:17: error: if statement has empty body [-Wempty-body]
if (len > 1);
However, fixing this means that some code that was previously
ignored by the compiler now gets compiled, resulting in this error:
CC bt-sdp.o
cc1: warnings being treated as errors
/src/qemu/hw/bt-sdp.c: In function 'sdp_svc_search':
/src/qemu/hw/bt-sdp.c:184: error: 'max' may be used uninitialized in
this function
I could not figure out how to calculate max, so I just invented some
figure to suppress the error.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
hw/bt-sdp.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/bt-sdp.c b/hw/bt-sdp.c
index b8732d0..c0bfd4d 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -171,12 +171,14 @@ static ssize_t sdp_svc_search(struct
bt_l2cap_sdp_state_s *sdp,
} else
start = 0;
- if (len > 1);
+ if (len > 1) {
return -SDP_INVALID_SYNTAX;
+ }
/* Output the results */
len = 4;
count = 0;
+ max = INT_MAX; /* XXX: probably horribly incorrect */
end = start;
for (i = 0; i < sdp->services; i ++)
if (sdp->service_list[i].match) {
--
1.6.2.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [RFC, PATCH 2/2] bt-sdp: Fix if statement with empty body, spotted by clang
2010-04-18 8:52 [Qemu-devel] [RFC, PATCH 2/2] bt-sdp: Fix if statement with empty body, spotted by clang Blue Swirl
@ 2010-04-22 1:58 ` andrzej zaborowski
0 siblings, 0 replies; 2+ messages in thread
From: andrzej zaborowski @ 2010-04-22 1:58 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
On 18 April 2010 10:52, Blue Swirl <blauwirbel@gmail.com> wrote:
> Fix clang error:
> CC bt-sdp.o
> /src/qemu/hw/bt-sdp.c:174:17: error: if statement has empty body [-Wempty-body]
> if (len > 1);
>
> However, fixing this means that some code that was previously
> ignored by the compiler now gets compiled, resulting in this error:
> CC bt-sdp.o
> cc1: warnings being treated as errors
> /src/qemu/hw/bt-sdp.c: In function 'sdp_svc_search':
> /src/qemu/hw/bt-sdp.c:184: error: 'max' may be used uninitialized in
> this function
>
> I could not figure out how to calculate max, so I just invented some
> figure to suppress the error.
Thanks, good catches, I applied fixes to both problems.
Turns out we were assigning the value of the "Max" parameter of the
request to the wrong variable, which was later overwritten anyway. I
don't know what I was thinking...
Cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-22 1:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-18 8:52 [Qemu-devel] [RFC, PATCH 2/2] bt-sdp: Fix if statement with empty body, spotted by clang Blue Swirl
2010-04-22 1:58 ` [Qemu-devel] " andrzej zaborowski
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).