cluster: master - qdisk: fix build warnings spotted by paranoia cflags

Fabio M. Di Nitto fabbione@fedoraproject.org
Tue May 5 03:38:00 GMT 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e5ebfeb2433bb3b1c0dea6f02f36c04a5fe88c30
Commit:        e5ebfeb2433bb3b1c0dea6f02f36c04a5fe88c30
Parent:        8d9c236ae53edbc5866b9f357ce082a26772ff10
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Tue May 5 05:35:39 2009 +0200
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue May 5 05:38:20 2009 +0200

qdisk: fix build warnings spotted by paranoia cflags

missing function declarations
make some functions static
void-math
const strings

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/qdisk/bitmap.c      |    3 +++
 cman/qdisk/daemon_init.c |    1 +
 cman/qdisk/disk.c        |    5 +++--
 cman/qdisk/disk_util.c   |    3 +++
 cman/qdisk/main.c        |   31 ++++++++++++++++++-------------
 cman/qdisk/proc.c        |    4 +++-
 cman/qdisk/score.c       |    9 ++++++---
 7 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/cman/qdisk/bitmap.c b/cman/qdisk/bitmap.c
index 37ff969..094ad2f 100644
--- a/cman/qdisk/bitmap.c
+++ b/cman/qdisk/bitmap.c
@@ -3,6 +3,9 @@
  */
 #include <stdint.h>
 
+int clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
+int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
+int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
 
 /**
  * Clear a bit in a bitmap / bitmask.
diff --git a/cman/qdisk/daemon_init.c b/cman/qdisk/daemon_init.c
index 33e8339..d5926f9 100644
--- a/cman/qdisk/daemon_init.c
+++ b/cman/qdisk/daemon_init.c
@@ -29,6 +29,7 @@
  * This should ultimately go in a header file.
  */
 void daemon_init(char *prog);
+void daemon_cleanup(void);
 int check_process_running(char *prog, pid_t * pid);
 
 /*
diff --git a/cman/qdisk/disk.c b/cman/qdisk/disk.c
index 12202d5..e349698 100644
--- a/cman/qdisk/disk.c
+++ b/cman/qdisk/disk.c
@@ -37,7 +37,7 @@ static int diskRawRead(target_info_t *disk, char *buf, int len);
  * @param count		Size of data set, in bytes.
  * @return 		CRC32 of data set.
  */
-uint32_t clu_crc32(const char *data, size_t count)
+static uint32_t clu_crc32(const char *data, size_t count)
 {
 	return (uint32_t)crc32(0L, (const Bytef *)data, (uInt)count);
 }
@@ -553,13 +553,14 @@ diskRawWriteShadow(target_info_t *disk, __off64_t writeOffset, char *buf, int le
 
 
 int
-qdisk_read(target_info_t *disk, __off64_t offset, void *buf, int count)
+qdisk_read(target_info_t *disk, __off64_t offset, void *bufin, int count)
 {
 	shared_header_t *hdrp;
 	void *ptr;
 	char *data;
 	size_t total;
 	int rv;
+	char *buf = (char *)bufin;
 
 	/*
 	 * Calculate the total length of the buffer, including the header.
diff --git a/cman/qdisk/disk_util.c b/cman/qdisk/disk_util.c
index 3743618..6d6e93e 100644
--- a/cman/qdisk/disk_util.c
+++ b/cman/qdisk/disk_util.c
@@ -17,6 +17,9 @@
 #include <time.h>
 #include <liblogthread.h>
 
+inline void _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end);
+inline int get_time(struct timeval *tv, int use_uptime);
+
 inline void
 _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end)
 {
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index ad03003..8e7e5b9 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -29,13 +29,16 @@
 #define LOG_DAEMON_NAME  "qdiskd"
 #define LOG_MODE_DEFAULT LOG_MODE_OUTPUT_SYSLOG|LOG_MODE_OUTPUT_FILE
 
+/* from main.c */
+void set_priority(int queue, int prio);
+
 /* from daemon_init.c */
-int daemon_init(char *);
-void daemon_cleanup(void);
-int check_process_running(char *, pid_t *);
+extern int daemon_init(char *);
+extern void daemon_cleanup(void);
+extern int check_process_running(char *, pid_t *);
 
 /* from proc.c */
-char *state_str(disk_node_state_t s);
+extern const char *state_str(disk_node_state_t s);
 
 /*
   TODO:
@@ -46,11 +49,13 @@ char *state_str(disk_node_state_t s);
  */
 
 /* From bitmap.c */
-int clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-inline int get_time(struct timeval *tv, int use_uptime);
-inline void _diff_tv(struct timeval *dest, struct timeval *start,
+extern int clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
+extern int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
+extern int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
+
+/* From disk_utils.c */
+extern inline int get_time(struct timeval *tv, int use_uptime);
+extern inline void _diff_tv(struct timeval *dest, struct timeval *start,
 		     struct timeval *end);
 
 static int _running = 1, _reconfig = 0, _cman_shutdown = 0;
@@ -150,7 +155,7 @@ check_self(qd_ctx *ctx, status_block_t *sb)
   or has not updated their timestamp recently.  See check_transitions as
   well.
  */
-int
+static int
 read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
 {
 	int x, errors = 0;
@@ -800,7 +805,7 @@ set_priority(int queue, int prio)
 {
 	struct sched_param s;
 	int ret;
-	char *func = "nice";
+	const char *func = "nice";
 	
 	if (queue == SCHED_OTHER) {
 		s.sched_priority = 0;
@@ -1160,7 +1165,7 @@ quorum_logout(qd_ctx *ctx)
 }
 
 
-void
+static void
 conf_logging(int debug, int logmode, int facility, int loglevel,
 	     int filelevel, char *fname)
 {
@@ -1188,7 +1193,7 @@ conf_logging(int debug, int logmode, int facility, int loglevel,
 }
 
 
-int
+static int
 ccs_read_old_logging(int ccsfd, int *facility, int *priority)
 {
 	char query[256];
diff --git a/cman/qdisk/proc.c b/cman/qdisk/proc.c
index a59613b..1b7471e 100644
--- a/cman/qdisk/proc.c
+++ b/cman/qdisk/proc.c
@@ -12,6 +12,8 @@
 #include <liblogthread.h>
 #include "scandisk.h"
 
+const char *state_str(disk_node_state_t s);
+
 struct device_args {
 	char *label;
 	struct devnode *devnode;
@@ -103,7 +105,7 @@ filter_devs(struct devnode *node, void *v_args)
 }
 
 
-char *
+const char *
 state_str(disk_node_state_t s)
 {
 	switch (s) {
diff --git a/cman/qdisk/score.c b/cman/qdisk/score.c
index 1ba1506..26dc88d 100644
--- a/cman/qdisk/score.c
+++ b/cman/qdisk/score.c
@@ -20,7 +20,7 @@
 static pthread_mutex_t sc_lock = PTHREAD_MUTEX_INITIALIZER;
 static int _score = 0, _maxscore = 0, _score_thread_running = 0;
 static pthread_t score_thread = (pthread_t)0;
-void set_priority(int, int);
+extern void set_priority(int, int);
 
 struct h_arg {
 	struct h_data *h;
@@ -116,8 +116,8 @@ fork_heuristic(struct h_data *h)
 	munlockall();
 	restore_signals();
 
-	argv[0] = "/bin/sh";
-	argv[1] = "-c";
+	argv[0] = strdup("/bin/sh");
+	argv[1] = strdup("-c");
 	argv[2] = h->program;
 	argv[3] = NULL;
 
@@ -125,6 +125,9 @@ fork_heuristic(struct h_data *h)
 
 	execv("/bin/sh", argv);
 
+	free(argv[0]);
+	free(argv[1]);
+
 	logt_print(LOG_ERR, "Execv failed\n");
 	return 0;
 }



More information about the Cluster-cvs mailing list