[sheepdog] [PATCH] sheep: fix gcc various warnings
Liu Yuan
namei.unix at gmail.com
Thu May 23 07:54:56 CEST 2013
sheep.c:133:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
...
cluster/shepherd.c:278:7: warning: variable ‘removed’ set but not used [-Wunused-but-set-variable]
...
cluster.c:279:8: warning: ignoring return value of ‘strtol’, declared with attribute warn_unused_result [-Wunused-result]
Fix uninitialized_var() and use it to keep GCC happy.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
collie/cluster.c | 4 ++--
include/util.h | 2 +-
sheep/cluster/shepherd.c | 3 ++-
sheep/sheep.c | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/collie/cluster.c b/collie/cluster.c
index 7bf537a..04d1587 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -274,9 +274,9 @@ static int save_snapshot(int argc, char **argv)
{
char *tag = argv[optind++];
char *path, *p;
- int ret = EXIT_SYSFAIL;
+ int ret = EXIT_SYSFAIL, uninitialized_var(unused);
- strtol(tag, &p, 10);
+ unused = strtol(tag, &p, 10);
if (tag != p) {
fprintf(stderr, "Tag should not start with number.\n");
return EXIT_USAGE;
diff --git a/include/util.h b/include/util.h
index 475c9cd..8b7634f 100644
--- a/include/util.h
+++ b/include/util.h
@@ -42,7 +42,7 @@
#define __printf(a, b) __attribute__((format(printf, a, b)))
-#define uninitialized_var(x) (x = x)
+#define uninitialized_var(x) x = x
static inline int before(uint32_t seq1, uint32_t seq2)
{
diff --git a/sheep/cluster/shepherd.c b/sheep/cluster/shepherd.c
index da28c55..ac57503 100644
--- a/sheep/cluster/shepherd.c
+++ b/sheep/cluster/shepherd.c
@@ -288,7 +288,8 @@ static void remove_one_block_event(void)
removed = ev->removed = true;
break;
}
- assert(removed);
+ if (!removed)
+ panic("removed is not true");
eventfd_write(sph_event_fd, 1);
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 0238a9f..7326b3b 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -130,7 +130,7 @@ static int sigfd;
static void signal_handler(int listen_fd, int events, void *data)
{
struct signalfd_siginfo siginfo;
- int ret;
+ int uninitialized_var(ret);
ret = read(sigfd, &siginfo, sizeof(siginfo));
assert(ret == sizeof(siginfo));
--
1.7.9.5
More information about the sheepdog
mailing list