[sheepdog] [PATCH] sockfd cache: fix a uninit warning

Liu Yuan namei.unix at gmail.com
Fri Aug 9 07:14:34 CEST 2013


sockfd_cache.c:379:16: warning: ‘idx’ may be used uninitialized in this function [-Wuninitialized]
...

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 lib/sockfd_cache.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/sockfd_cache.c b/lib/sockfd_cache.c
index b1973ba..f965a37 100644
--- a/lib/sockfd_cache.c
+++ b/lib/sockfd_cache.c
@@ -356,7 +356,7 @@ static struct sockfd *sockfd_cache_get_long(const struct node_id *nid)
 	bool use_io = nid->io_port ? true : false;
 	const uint8_t *addr = use_io ? nid->io_addr : nid->addr;
 	char name[INET6_ADDRSTRLEN];
-	int fd, idx, port = use_io ? nid->io_port : nid->port;
+	int fd, idx = -1, port = use_io ? nid->io_port : nid->port;
 
 	addr_to_str(name, sizeof(name), addr, 0);
 grab:
-- 
1.7.9.5




More information about the sheepdog mailing list