* [PATCH 1/3] Fix uninitialized variable warning
@ 2011-03-29 11:36 luiz.dentz
2011-03-29 11:36 ` [PATCH 2/3] " luiz.dentz
2011-03-29 11:36 ` [PATCH 3/3] Fix uninitialized variables warnings luiz.dentz
0 siblings, 2 replies; 6+ messages in thread
From: luiz.dentz @ 2011-03-29 11:36 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
audio/unix.c: In function ‘client_cb’:
audio/unix.c:1078:20: error: ‘a2dp’ may be used uninitialized in this function
audio/unix.c:1154:20: error: ‘a2dp’ may be used uninitialized in this function
make[1]: *** [audio/unix.o] Error 1
---
audio/unix.c | 51 ++++++++++++++++++++++++++++-----------------------
1 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/audio/unix.c b/audio/unix.c
index 3c47510..37c772d 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -1075,31 +1075,30 @@ failed:
static void start_resume(struct audio_device *dev, struct unix_client *client)
{
- struct a2dp_data *a2dp;
+ struct a2dp_data *a2dp = NULL;
struct headset_data *hs;
unsigned int id;
- gboolean unref_avdtp_on_fail = FALSE;
+ struct avdtp *session = NULL;
switch (client->type) {
case TYPE_SINK:
case TYPE_SOURCE:
a2dp = &client->d.a2dp;
- if (!a2dp->session) {
- a2dp->session = avdtp_get(&dev->src, &dev->dst);
- unref_avdtp_on_fail = TRUE;
- }
-
- if (!a2dp->session) {
- error("Unable to get a session");
- goto failed;
- }
-
if (!a2dp->sep) {
error("seid not opened");
goto failed;
}
+ if (!a2dp->session) {
+ session = avdtp_get(&dev->src, &dev->dst);
+ if (!session) {
+ error("Unable to get a session");
+ goto failed;
+ }
+ a2dp->session = session;
+ }
+
id = a2dp_resume(a2dp->session, a2dp->sep, a2dp_resume_complete,
client);
client->cancel = a2dp_cancel;
@@ -1142,33 +1141,38 @@ static void start_resume(struct audio_device *dev, struct unix_client *client)
return;
failed:
- if (unref_avdtp_on_fail && a2dp->session) {
- avdtp_unref(a2dp->session);
+ if (session) {
+ avdtp_unref(session);
a2dp->session = NULL;
}
+
unix_ipc_error(client, BT_START_STREAM, EIO);
}
static void start_suspend(struct audio_device *dev, struct unix_client *client)
{
- struct a2dp_data *a2dp;
+ struct a2dp_data *a2dp = NULL;
struct headset_data *hs;
unsigned int id;
- gboolean unref_avdtp_on_fail = FALSE;
+ struct avdtp *session = NULL;
switch (client->type) {
case TYPE_SINK:
case TYPE_SOURCE:
a2dp = &client->d.a2dp;
- if (!a2dp->session) {
- a2dp->session = avdtp_get(&dev->src, &dev->dst);
- unref_avdtp_on_fail = TRUE;
+ if (!a2dp->sep) {
+ error("seid not opened");
+ goto failed;
}
if (!a2dp->session) {
- error("Unable to get a session");
- goto failed;
+ session = avdtp_get(&dev->src, &dev->dst);
+ if (!session) {
+ error("Unable to get a session");
+ goto failed;
+ }
+ a2dp->session = session;
}
if (!a2dp->sep) {
@@ -1214,10 +1218,11 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client)
return;
failed:
- if (unref_avdtp_on_fail && a2dp->session) {
- avdtp_unref(a2dp->session);
+ if (session) {
+ avdtp_unref(session);
a2dp->session = NULL;
}
+
unix_ipc_error(client, BT_STOP_STREAM, EIO);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] Fix uninitialized variable warning
2011-03-29 11:36 [PATCH 1/3] Fix uninitialized variable warning luiz.dentz
@ 2011-03-29 11:36 ` luiz.dentz
2011-03-29 11:36 ` [PATCH 3/3] Fix uninitialized variables warnings luiz.dentz
1 sibling, 0 replies; 6+ messages in thread
From: luiz.dentz @ 2011-03-29 11:36 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
health/mcap.c: In function ‘proc_req_pending’:
health/mcap.c:1119:25: error: ‘abrt’ may be used uninitialized in this function
make[1]: *** [health/mcap.o] Error 1
---
health/mcap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/health/mcap.c b/health/mcap.c
index 81fd8df..a36f2c0 100644
--- a/health/mcap.c
+++ b/health/mcap.c
@@ -1116,7 +1116,7 @@ static void process_md_abort_mdl_req(struct mcap_mcl *mcl, void *cmd,
{
mcap_md_req *req;
GSList *l;
- struct mcap_mdl *mdl, *abrt;
+ struct mcap_mdl *mdl, *abrt = NULL;
uint16_t mdl_id;
if (!check_cmd_req_length(mcl, cmd, len, sizeof(mcap_md_req),
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] Fix uninitialized variables warnings
2011-03-29 11:36 [PATCH 1/3] Fix uninitialized variable warning luiz.dentz
2011-03-29 11:36 ` [PATCH 2/3] " luiz.dentz
@ 2011-03-29 11:36 ` luiz.dentz
2011-03-29 13:10 ` Anderson Lizardo
2011-03-29 13:20 ` Anderson Lizardo
1 sibling, 2 replies; 6+ messages in thread
From: luiz.dentz @ 2011-03-29 11:36 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
src/attrib-server.c: In function ‘channel_handler’:
src/attrib-server.c:297:21: error: ‘cur’ may be used uninitialized in this function
src/attrib-server.c:502:10: error: ‘format’ may be used uninitialized in this function
src/attrib-server.c:503:11: error: ‘length’ may be used uninitialized in this function
make[1]: *** [src/attrib-server.o] Error 1
---
src/attrib-server.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index dc05d7e..fb89ea5 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -294,7 +294,7 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start,
{
struct att_data_list *adl;
struct attribute *a;
- struct group_elem *cur, *old = NULL;
+ struct group_elem *cur = NULL, *old = NULL;
GSList *l, *groups;
uint16_t length, last_handle, last_size = 0;
uint8_t status;
@@ -499,8 +499,8 @@ static int find_info(uint16_t start, uint16_t end, uint8_t *pdu, int len)
struct attribute *a;
struct att_data_list *adl;
GSList *l, *info;
- uint8_t format, last_type = BT_UUID_UNSPEC;
- uint16_t length, num;
+ uint8_t format = 0, last_type = BT_UUID_UNSPEC;
+ uint16_t length = 0, num;
int i;
if (start > end || start == 0x0000)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 3/3] Fix uninitialized variables warnings
2011-03-29 11:36 ` [PATCH 3/3] Fix uninitialized variables warnings luiz.dentz
@ 2011-03-29 13:10 ` Anderson Lizardo
2011-03-29 13:18 ` Luiz Augusto von Dentz
2011-03-29 13:20 ` Anderson Lizardo
1 sibling, 1 reply; 6+ messages in thread
From: Anderson Lizardo @ 2011-03-29 13:10 UTC (permalink / raw)
To: luiz.dentz; +Cc: linux-bluetooth
Hi Luiz,
On Tue, Mar 29, 2011 at 7:36 AM, <luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>
> src/attrib-server.c: In function ‘channel_handler’:
> src/attrib-server.c:297:21: error: ‘cur’ may be used uninitialized in this function
> src/attrib-server.c:502:10: error: ‘format’ may be used uninitialized in this function
> src/attrib-server.c:503:11: error: ‘length’ may be used uninitialized in this function
> make[1]: *** [src/attrib-server.o] Error 1
Can you mention which compiler are you using ? Is it the just released
4.6.1 ? Or clang ? I'd like to use it as well.
Also I think that at least for this attrib-server.c patch, it is
hiding some real bugs (missing checks). I can't talk for the other
files though :)
E.g., if the attribute database is empty (highly unlikely, as it will
contain at least the GAP attributes), this will dereference a NULL
pointer:
if (l == NULL)
cur->end = a->handle;
else
cur->end = last_handle;
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 3/3] Fix uninitialized variables warnings
2011-03-29 13:10 ` Anderson Lizardo
@ 2011-03-29 13:18 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2011-03-29 13:18 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi,
On Tue, Mar 29, 2011 at 4:10 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Luiz,
>
> On Tue, Mar 29, 2011 at 7:36 AM, <luiz.dentz@gmail.com> wrote:
>> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>>
>> src/attrib-server.c: In function ‘channel_handler’:
>> src/attrib-server.c:297:21: error: ‘cur’ may be used uninitialized in this function
>> src/attrib-server.c:502:10: error: ‘format’ may be used uninitialized in this function
>> src/attrib-server.c:503:11: error: ‘length’ may be used uninitialized in this function
>> make[1]: *** [src/attrib-server.o] Error 1
>
> Can you mention which compiler are you using ? Is it the just released
> 4.6.1 ? Or clang ? I'd like to use it as well.
gcc 4.5.2
> Also I think that at least for this attrib-server.c patch, it is
> hiding some real bugs (missing checks). I can't talk for the other
> files though :)
Yep, I think it needs some rework, things like when format unknown it
should probably return an error.
> E.g., if the attribute database is empty (highly unlikely, as it will
> contain at least the GAP attributes), this will dereference a NULL
> pointer:
>
> if (l == NULL)
> cur->end = a->handle;
> else
> cur->end = last_handle;
True, let me rework this patch since apparently there is more things missing.
>
> Regards,
> --
> Anderson Lizardo
> Instituto Nokia de Tecnologia - INdT
> Manaus - Brazil
>
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] Fix uninitialized variables warnings
2011-03-29 11:36 ` [PATCH 3/3] Fix uninitialized variables warnings luiz.dentz
2011-03-29 13:10 ` Anderson Lizardo
@ 2011-03-29 13:20 ` Anderson Lizardo
1 sibling, 0 replies; 6+ messages in thread
From: Anderson Lizardo @ 2011-03-29 13:20 UTC (permalink / raw)
To: luiz.dentz; +Cc: linux-bluetooth
Hi Luiz,
On Tue, Mar 29, 2011 at 7:36 AM, <luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>
> src/attrib-server.c: In function ‘channel_handler’:
> src/attrib-server.c:297:21: error: ‘cur’ may be used uninitialized in this function
> src/attrib-server.c:502:10: error: ‘format’ may be used uninitialized in this function
> src/attrib-server.c:503:11: error: ‘length’ may be used uninitialized in this function
> make[1]: *** [src/attrib-server.o] Error 1
> ---
> src/attrib-server.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/attrib-server.c b/src/attrib-server.c
> index dc05d7e..fb89ea5 100644
> --- a/src/attrib-server.c
> +++ b/src/attrib-server.c
> @@ -294,7 +294,7 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start,
> {
> struct att_data_list *adl;
> struct attribute *a;
> - struct group_elem *cur, *old = NULL;
> + struct group_elem *cur = NULL, *old = NULL;
> GSList *l, *groups;
> uint16_t length, last_handle, last_size = 0;
> uint8_t status;
> @@ -499,8 +499,8 @@ static int find_info(uint16_t start, uint16_t end, uint8_t *pdu, int len)
> struct attribute *a;
> struct att_data_list *adl;
> GSList *l, *info;
> - uint8_t format, last_type = BT_UUID_UNSPEC;
> - uint16_t length, num;
> + uint8_t format = 0, last_type = BT_UUID_UNSPEC;
> + uint16_t length = 0, num;
This is due to this block:
///
if (last_type == BT_UUID16) {
length = 2;
format = 0x01;
} else if (last_type == BT_UUID128) {
length = 16;
format = 0x02;
}
///
I would rather either use an g_assert() for last_type here (because it
is a programming error to have other UUID types on the Attribute
database) , or "return 0" (taking care to move this block to before
the if (info == NULL) check, to avoid a leak).
> int i;
>
> if (start > end || start == 0x0000)
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-29 13:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-29 11:36 [PATCH 1/3] Fix uninitialized variable warning luiz.dentz
2011-03-29 11:36 ` [PATCH 2/3] " luiz.dentz
2011-03-29 11:36 ` [PATCH 3/3] Fix uninitialized variables warnings luiz.dentz
2011-03-29 13:10 ` Anderson Lizardo
2011-03-29 13:18 ` Luiz Augusto von Dentz
2011-03-29 13:20 ` Anderson Lizardo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox