build: remove compile warning
PATCH 1/1 build: remove compile warning
This patch simply remove "variable may be used uninitialized" warning.
--- libcacard/vscclient.c | 2 +- util/iov.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
libcacard/vscclient.c +1 -1
@@ -641,7 +641,7 @@ main(GIOChannel *channel_stdin;char *qemu_host;char *qemu_port; -VSCMsgHeader mhHeader; +VSCMsgHeader mhHeader = {0 };VCardEmulOptions *command_line_options =NULL ;
util/iov.c +1 -1
@@ -146,7 +146,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, {ssize_t total =0 ;ssize_t ret; -size_t orig_len, tail; +size_t orig_len =0 , tail;unsigned niov;while (bytes >0 ) {
Signature · 1 line
1.7.1
Quoted 13 lines · Wenchao Xia
This patch simply remove "variable may be used uninitialized" warning.
Signed-off-by Wenchao Xia <[email protected]>--- libcacard/vscclient.c | 2 +- util/iov.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)libcacard/vscclient.c +0
-0
libcacard/vscclient.c main( · line 646
Quoted 7 lines
libcacard/vscclient.c +1
-1@@ -641,7 +641,7 @@ main(GIOChannel *channel_stdin;char *qemu_host;char *qemu_port; -VSCMsgHeader mhHeader; +VSCMsgHeader mhHeader = {0 };VCardEmulOptions *command_line_options =NULL ;
The code looks broken to me:
main() {
VSCMsgHeader mhHeader;
...
send_msg(VSC_Init, mhHeader.reader_id, &init, sizeof(init));This is really an uninitialized use of mhHeader.read_id. But it gets more interesting:
static int
send_msg(
VSCMsgType type,
uint32_t reader_id,
const void *msg,
unsigned int length
) {
VSCMsgHeader mhHeader;
qemu_mutex_lock(&socket_to_send_lock);
if (verbose > 10) {
printf("sending type=%d id=%u, len =%u (0x%x)\n",
type, reader_id, length, length);
}
mhHeader.type = htonl(type);
mhHeader.reader_id = 0;
mhHeader.length = htonl(length);
g_byte_array_append(socket_to_send, (guint8 *)&mhHeader, sizeof(mhHeader));
g_byte_array_append(socket_to_send, (guint8 *)msg, length);
g_idle_add(socket_prepare_sending, NULL);
qemu_mutex_unlock(&socket_to_send_lock);
return 0;
}This function prints reader_id if verbose > 0 but it doesn't use it! mhHeader.read_id is always set to 0.
This should be cleaned up properly. The other issue you silenced looks okay.
Stefan
Quoted 16 lines · Stefan Hajnoczi
libcacard/vscclient.c main( · line 646
Quoted 12 lines · Wenchao Xia
This patch simply remove "variable may be used uninitialized" warning.
libcacard/vscclient.c +1
-1@@ -641,7 +641,7 @@ main(GIOChannel *channel_stdin;char *qemu_host;char *qemu_port; -VSCMsgHeader mhHeader; +VSCMsgHeader mhHeader = {0 };VCardEmulOptions *command_line_options =NULL ;The code looks broken to me:
Quoted 6 lines
main() { VSCMsgHeader mhHeader; ... send_msg(VSC_Init, mhHeader.reader_id, &init, sizeof(init));This is really an uninitialized use of mhHeader.read_id.
See the patch already on list (and my review comments on it):
http://patchwork.ozlabs.org/patch/248856/
thanks
-- PMM