[sheepdog] [PATCH 1/5] sheep: mute gcc warning about uninitialized var

Liu Yuan namei.unix at gmail.com
Tue Jun 19 05:55:14 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

Add a macro to mute below whining:
...
work.c:84: warning: ‘idx’ may be used uninitialized in this function

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 include/util.h |    2 ++
 sheep/work.c   |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/util.h b/include/util.h
index eafd9ca..d583a2f 100644
--- a/include/util.h
+++ b/include/util.h
@@ -33,6 +33,8 @@
 
 #define notrace __attribute__((no_instrument_function))
 
+#define uninitialized_var(x) x = x
+
 static inline int before(uint32_t seq1, uint32_t seq2)
 {
         return (int32_t)(seq1 - seq2) < 0;
diff --git a/sheep/work.c b/sheep/work.c
index 6bebada..f81c41d 100644
--- a/sheep/work.c
+++ b/sheep/work.c
@@ -81,7 +81,7 @@ static void *worker_routine(void *arg)
 	struct worker_info *wi = arg;
 	struct work *work;
 	eventfd_t value = 1;
-	int i, idx;
+	int i, uninitialized_var(idx);
 
 	for (i = 0; i < wi->nr_threads; i++) {
 		if (wi->worker_thread[i] == pthread_self()) {
-- 
1.7.10.2




More information about the sheepdog mailing list