diff mbox

[5/5] libcacard/vscclient.c: fix use of uninitialized variable

Message ID 1370377419-31788-5-git-send-email-alevy@redhat.com
State New
Headers show

Commit Message

Alon Levy June 4, 2013, 8:23 p.m. UTC
Found by Coverity.

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 libcacard/vscclient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell June 4, 2013, 9:12 p.m. UTC | #1
On 4 June 2013 21:23, Alon Levy <alevy@redhat.com> wrote:
> Found by Coverity.
>
> Signed-off-by: Alon Levy <alevy@redhat.com>
> ---
>  libcacard/vscclient.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
> index 5180d29..4275c23 100644
> --- a/libcacard/vscclient.c
> +++ b/libcacard/vscclient.c
> @@ -645,7 +645,7 @@ main(
>      GIOChannel *channel_stdin;
>      char *qemu_host;
>      char *qemu_port;
> -    VSCMsgHeader mhHeader;
> +    VSCMsgHeader mhHeader = {0,};

As far as I can see we only use this variable once:

    send_msg(VSC_Init, mhHeader.reader_id, &init, sizeof(init));

so wouldn't it be better just to directly pass a constant
"0" to the send_msg() call? Hiding a single uint32_t in
a struct seems a bit obscure.

thanks
-- PMM
diff mbox

Patch

diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 5180d29..4275c23 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -645,7 +645,7 @@  main(
     GIOChannel *channel_stdin;
     char *qemu_host;
     char *qemu_port;
-    VSCMsgHeader mhHeader;
+    VSCMsgHeader mhHeader = {0,};
 
     VCardEmulOptions *command_line_options = NULL;