From 37f1b609ae88f16e0e978836dd0afb245eb0d24c Mon Sep 17 00:00:00 2001 From: Anderson Lizardo Date: Fri, 3 Jan 2014 21:55:27 -0400 Subject: [PATCH] android/client: Fix uninitialized "sock_fd" variable If EXEC() macro is called with the first pointer argument NULL, sock_fd will not be initialized. Given that the NULL check is not fatal, it is a good idea to initialize the variable to -1 so the code has defined behavior on this situation. Detected by clang: android/client/if-sock.c:251:7: error: variable 'sock_fd' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] --- android/client/if-sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/client/if-sock.c b/android/client/if-sock.c index 050bc968c..4c1af822b 100644 --- a/android/client/if-sock.c +++ b/android/client/if-sock.c @@ -207,7 +207,7 @@ static void listen_p(int argc, const char **argv) const char *service_name; bt_uuid_t service_uuid; int channel; - int sock_fd; + int sock_fd = -1; int flags; RETURN_IF_NULL(if_sock); @@ -281,7 +281,7 @@ static void connect_p(int argc, const char **argv) btsock_type_t type; bt_uuid_t uuid; int channel; - int sock_fd; + int sock_fd = -1; int flags; /* Address */ -- 2.47.3