2014-08-13 12:08:45

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH] monitor: Fix use of uninitialized value

From: Andrei Emeltchenko <[email protected]>

Fixes clang warnings below:
...
CC monitor/avctp.o
monitor/avctp.c:600:2: warning: Function call argument is an
uninitialized value
print_indent(indent, ctrl_pdu_data_color, "AVRCP: ",
pdu2str(pduid),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monitor/display.h:47:2: note: expanded from macro 'print_indent'
printf("%*c%s%s%s%s" fmt "%s\n", (indent), ' ', \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
...
---
monitor/avctp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index 9eeac7f..4f87837 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -590,16 +590,14 @@ static void avrcp_pdu_packet(const struct l2cap_frame *frame, uint8_t ctype,
uint16_t len;
int i;
const struct avrcp_ctrl_pdu_data *ctrl_pdu_data = NULL;
- const char *ctrl_pdu_data_color;
struct l2cap_frame avrcp_frame;

pduid = *((uint8_t *) frame->data);
pt = *((uint8_t *) (frame->data + 1));
len = get_be16(frame->data + 2);

- print_indent(indent, ctrl_pdu_data_color, "AVRCP: ", pdu2str(pduid),
- COLOR_OFF, " pt %s len 0x%04x",
- pt2str(pt), len);
+ print_indent(indent, COLOR_OFF, "AVRCP: ", pdu2str(pduid), COLOR_OFF,
+ " pt %s len 0x%04x", pt2str(pt), len);

if ((frame->size < 4) || ((frame->size - 4) != len)) {
print_text(COLOR_ERROR, "PDU malformed");
--
1.9.1



2014-08-13 12:31:33

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] monitor: Fix use of uninitialized value

Hi Andrei,

On Wed, Aug 13, 2014 at 3:08 PM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Fixes clang warnings below:
> ...
> CC monitor/avctp.o
> monitor/avctp.c:600:2: warning: Function call argument is an
> uninitialized value
> print_indent(indent, ctrl_pdu_data_color, "AVRCP: ",
> pdu2str(pduid),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> monitor/display.h:47:2: note: expanded from macro 'print_indent'
> printf("%*c%s%s%s%s" fmt "%s\n", (indent), ' ', \
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 warning generated.
> ...
> ---
> monitor/avctp.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/monitor/avctp.c b/monitor/avctp.c
> index 9eeac7f..4f87837 100644
> --- a/monitor/avctp.c
> +++ b/monitor/avctp.c
> @@ -590,16 +590,14 @@ static void avrcp_pdu_packet(const struct l2cap_frame *frame, uint8_t ctype,
> uint16_t len;
> int i;
> const struct avrcp_ctrl_pdu_data *ctrl_pdu_data = NULL;
> - const char *ctrl_pdu_data_color;
> struct l2cap_frame avrcp_frame;
>
> pduid = *((uint8_t *) frame->data);
> pt = *((uint8_t *) (frame->data + 1));
> len = get_be16(frame->data + 2);
>
> - print_indent(indent, ctrl_pdu_data_color, "AVRCP: ", pdu2str(pduid),
> - COLOR_OFF, " pt %s len 0x%04x",
> - pt2str(pt), len);
> + print_indent(indent, COLOR_OFF, "AVRCP: ", pdu2str(pduid), COLOR_OFF,
> + " pt %s len 0x%04x", pt2str(pt), len);
>
> if ((frame->size < 4) || ((frame->size - 4) != len)) {
> print_text(COLOR_ERROR, "PDU malformed");
> --
> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz