public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Christine Caulfield <chrissie@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: dlm: master - Fix some compile warnings. Date: Tue, 23 Jun 2009 10:26:00 -0000 [thread overview] Message-ID: <20090623102559.8925812037F@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=1889f9256d0e19855cd31fc180a6219d27b8764e Commit: 1889f9256d0e19855cd31fc180a6219d27b8764e Parent: 9df61209a5f430b3a7a0c3884bd8649b0ea1ac7b Author: Christine Caulfield <ccaulfie@redhat.com> AuthorDate: Tue Jun 23 11:25:14 2009 +0100 Committer: Christine Caulfield <ccaulfie@redhat.com> CommitterDate: Tue Jun 23 11:25:14 2009 +0100 Fix some compile warnings. Thanks to Fabio for most of this patch Signed-off-by: Christine Caulfield <ccaulfie@redhat.com> --- dlm/tests/usertest/alternate-lvb.c | 10 +++++----- dlm/tests/usertest/asttest.c | 14 +++++++------- dlm/tests/usertest/dlmtest.c | 6 ++---- dlm/tests/usertest/dlmtest2.c | 7 +++---- dlm/tests/usertest/joinleave.c | 2 +- dlm/tests/usertest/lstest.c | 12 ++++++------ dlm/tests/usertest/lvb.c | 11 +++++++---- dlm/tests/usertest/pingtest.c | 8 ++++---- dlm/tests/usertest/threads.c | 34 ++++++++++------------------------ 9 files changed, 45 insertions(+), 59 deletions(-) diff --git a/dlm/tests/usertest/alternate-lvb.c b/dlm/tests/usertest/alternate-lvb.c index e8f2270..6e4df0b 100644 --- a/dlm/tests/usertest/alternate-lvb.c +++ b/dlm/tests/usertest/alternate-lvb.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { unsigned long long offset; unsigned long long num, last_num = 0; - unsigned int id, clients, sleep = 0; + unsigned int id, clients, sleeptime = 0; unsigned long long skip = 0; char *name; int rv; @@ -58,13 +58,13 @@ int main(int argc, char *argv[]) clients = atoi(argv[4]); if (argc > 5) - sleep = atoi(argv[5]); + sleeptime = atoi(argv[5]); printf("Joining \"alternate\" lockspace...\n"); dh = dlm_create_lockspace("alternate", 0600); if (!dh) { - printf("dlm_create_lockspace error %d %d\n", (int) dh, errno); + printf("dlm_create_lockspace error %p %d\n",dh, errno); return -ENOTCONN; } @@ -155,8 +155,8 @@ int main(int argc, char *argv[]) lksb.sb_status); } - if (sleep) - usleep(sleep); + if (sleeptime) + usleep(sleeptime); } dlm_ls_unlock_wait(dh, lksb.sb_lkid, 0, &lksb); diff --git a/dlm/tests/usertest/asttest.c b/dlm/tests/usertest/asttest.c index afe985c..4b07f6d 100644 --- a/dlm/tests/usertest/asttest.c +++ b/dlm/tests/usertest/asttest.c @@ -55,7 +55,7 @@ static int modetonum(char *modestr) return mode; } -static char *numtomode(int mode) +static const char *numtomode(int mode) { switch (mode) { @@ -90,10 +90,10 @@ static void usage(char *prog, FILE *file) static void ast_routine(void *arg) { - struct dlm_lksb *lksb = arg; + struct dlm_lksb *alksb = arg; if (!quiet) - printf("ast called, status = %d, lkid=%x\n", lksb->sb_status, lksb->sb_lkid); + printf("ast called, status = %d, lkid=%x\n", alksb->sb_status, alksb->sb_lkid); /* Wake the main thread */ if (use_threads) @@ -110,14 +110,14 @@ static void ast_routine(void *arg) static void bast_routine(void *arg) { - struct dlm_lksb *lksb = arg; + struct dlm_lksb *blksb = arg; if (!quiet) - printf("\nblocking ast called, status = %d, lkid=%x\n", lksb->sb_status, lksb->sb_lkid); + printf("\nblocking ast called, status = %d, lkid=%x\n", blksb->sb_status, blksb->sb_lkid); } /* Using poll(2) to wait for and dispatch ASTs */ -static int poll_for_ast() +static int poll_for_ast(void) { struct pollfd pfd; @@ -138,7 +138,7 @@ static int poll_for_ast() int main(int argc, char *argv[]) { - char *resource = "LOCK-NAME"; + const char *resource = "LOCK-NAME"; int flags = 0; int delay = 0; int status; diff --git a/dlm/tests/usertest/dlmtest.c b/dlm/tests/usertest/dlmtest.c index 40fd3d3..02f8f07 100644 --- a/dlm/tests/usertest/dlmtest.c +++ b/dlm/tests/usertest/dlmtest.c @@ -21,7 +21,6 @@ #include "libdlm.h" -static struct dlm_lksb lksb; static int modetonum(char *modestr) { int mode = LKM_EXMODE; @@ -36,7 +35,7 @@ static int modetonum(char *modestr) return mode; } -static char *numtomode(int mode) +static const char *numtomode(int mode) { switch (mode) { @@ -138,7 +137,7 @@ struct dlm_lksb tmplksb; int main(int argc, char *argv[]) { - char *resource = "LOCK-NAME"; + const char *resource = "LOCK-NAME"; int flags = 0; int status; int delay = 5; @@ -150,7 +149,6 @@ int main(int argc, char *argv[]) int do_query = 0; int do_expedite = 0; signed char opt; - int i; /* Deal with command-line arguments */ opterr = 0; diff --git a/dlm/tests/usertest/dlmtest2.c b/dlm/tests/usertest/dlmtest2.c index 04532c4..6160d4a 100644 --- a/dlm/tests/usertest/dlmtest2.c +++ b/dlm/tests/usertest/dlmtest2.c @@ -123,7 +123,7 @@ static int rand_int(int a, int b) return a + (int) (((float)(b - a + 1)) * random() / (RAND_MAX+1.0)); } -static char *status_str(int status) +static const char *status_str(int status) { static char sts_str[8]; @@ -148,7 +148,7 @@ static char *status_str(int status) } } -static char *op_str(int op) +static const char *op_str(int op) { switch (op) { case Op_lock: @@ -461,7 +461,7 @@ static void lock_all(int mode) lock(i, mode); } -static char *uflags(uint32_t flags) +static const char *uflags(uint32_t flags) { if (flags == LKF_FORCEUNLOCK) return "FORCEUNLOCK"; @@ -1450,7 +1450,6 @@ int main(int argc, char *argv[]) break; } - out: if (openclose_ls) { printf("dlm_close_lockspace\n"); diff --git a/dlm/tests/usertest/joinleave.c b/dlm/tests/usertest/joinleave.c index 50ade83..c2ae659 100644 --- a/dlm/tests/usertest/joinleave.c +++ b/dlm/tests/usertest/joinleave.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) gettimeofday(&begin, NULL); dh = dlm_create_lockspace(name, 0600); if (!dh) { - printf("dlm_create_lockspace error %d %d\n", (int) dh, errno); + printf("dlm_create_lockspace error %p %d\n", dh, errno); return -ENOTCONN; } gettimeofday(&end, NULL); diff --git a/dlm/tests/usertest/lstest.c b/dlm/tests/usertest/lstest.c index eb4d558..c84843a 100644 --- a/dlm/tests/usertest/lstest.c +++ b/dlm/tests/usertest/lstest.c @@ -50,7 +50,7 @@ static int modetonum(char *modestr) return mode; } -static char *numtomode(int mode) +static const char *numtomode(int mode) { switch (mode) { @@ -86,10 +86,10 @@ static void usage(char *prog, FILE *file) static void ast_routine(void *arg) { - struct dlm_lksb *lksb = arg; + struct dlm_lksb *alksb = arg; if (!quiet) - printf("ast called, status = %d, lkid=%x\n", lksb->sb_status, lksb->sb_lkid); + printf("ast called, status = %d, lkid=%x\n", alksb->sb_status, alksb->sb_lkid); /* Wake the main thread */ if (use_threads) @@ -106,10 +106,10 @@ static void ast_routine(void *arg) static void bast_routine(void *arg) { - struct dlm_lksb *lksb = arg; + struct dlm_lksb *blksb = arg; if (!quiet) - printf("\nblocking ast called, status = %d, lkid=%x\n", lksb->sb_status, lksb->sb_lkid); + printf("\nblocking ast called, status = %d, lkid=%x\n", blksb->sb_status, blksb->sb_lkid); } /* Using poll(2) to wait for and dispatch ASTs */ @@ -134,7 +134,7 @@ static int poll_for_ast(dlm_lshandle_t ls) int main(int argc, char *argv[]) { - char *resource = "LOCK-NAME"; + const char *resource = "LOCK-NAME"; int flags = 0; int status; int mode = LKM_EXMODE; diff --git a/dlm/tests/usertest/lvb.c b/dlm/tests/usertest/lvb.c index 1a55a43..4fe656d 100644 --- a/dlm/tests/usertest/lvb.c +++ b/dlm/tests/usertest/lvb.c @@ -32,6 +32,7 @@ struct lksb #include <stdlib.h> #include <string.h> #include <libdlm.h> +#include <unistd.h> #define LCK$M_VALBLK LKF_VALBLK #define LCK$M_CONVERT LKF_CONVERT #define LCK$K_CRMODE LKM_CRMODE @@ -96,7 +97,7 @@ static struct lksb our_lksb; static int cur_mode; static void compast_routine(void *arg); static void blockast_routine(void *arg, int mode); -static char *name = "TESTLOCK"; +static const char *name = "TESTLOCK"; #ifdef __linux__ static char lksb_lvb[DLM_LVB_LEN]; @@ -112,7 +113,7 @@ static void start_lock(int mode) /* Make a descriptor of the name */ memset(&name_s, 0, sizeof(struct dsc$descriptor_s)); name_s.dsc$w_length = strlen(name); - name_s.dsc$a_pointer = name; + name_s.dsc$a_pointer = (char *)name; /* Lock it */ status = sys$enq(0, @@ -170,7 +171,7 @@ static int convert_lock(int mode, char *lvb) return status; } -static void unlock() +static void unlock(void) { int status; @@ -228,8 +229,10 @@ int main(int argc, char *argv[]) start_lock(LCK$K_CRMODE); do { + char cmd; + fgets(buf, sizeof(buf), stdin); - char cmd = buf[0] & 0x5F; + cmd = buf[0] & 0x5F; if (cmd == 'W') convert_lock(LCK$K_CRMODE, &buf[1]); diff --git a/dlm/tests/usertest/pingtest.c b/dlm/tests/usertest/pingtest.c index fee9689..bc797b1 100644 --- a/dlm/tests/usertest/pingtest.c +++ b/dlm/tests/usertest/pingtest.c @@ -11,6 +11,7 @@ #include <stdio.h> #include <sys/types.h> #include <netdb.h> +#include <unistd.h> #include <libdlm.h> @@ -60,7 +61,7 @@ static int *lvb_int = (int *)&our_lksb.sb_lvb; #define SUCCESS SS$_NORMAL #endif -static char *lockname="ping"; +static const char *lockname="ping"; static int us = 1; static int maxnode = 2; static int cur_mode; @@ -72,7 +73,6 @@ static void blockast_routine(void *arg); #ifdef __linux__ static int convert_lock(int mode) { - int old_mode = cur_mode; int status; printf("pinglock: convert to %d starting\n", mode); @@ -98,7 +98,7 @@ static int convert_lock(int mode) return status; } -static void unlock() +static void unlock(void) { int status; status = dlm_unlock( our_lksb.sb_lkid, @@ -110,7 +110,7 @@ static void unlock() } -static void start_lock() +static void start_lock(void) { int status; cur_mode = LKM_EXMODE; diff --git a/dlm/tests/usertest/threads.c b/dlm/tests/usertest/threads.c index 2d12c67..8137004 100644 --- a/dlm/tests/usertest/threads.c +++ b/dlm/tests/usertest/threads.c @@ -56,20 +56,6 @@ static int modetonum(char *modestr) return mode; } -static char *numtomode(int mode) -{ - switch (mode) - { - case LKM_NLMODE: return "NL"; - case LKM_CRMODE: return "CR"; - case LKM_CWMODE: return "CW"; - case LKM_PRMODE: return "PR"; - case LKM_PWMODE: return "PW"; - case LKM_EXMODE: return "EX"; - default: return "??"; - } -} - static void usage(char *prog, FILE *file) { fprintf(file, "Usage:\n"); @@ -174,11 +160,11 @@ static int sync_unlock(dlm_lshandle_t lockspace, int lockid) static void *thread_fn(void *arg) { struct thread_args *ta = arg; - int lockid; + int lockid=0; int status; if (ta->verbose > 1) - fprintf(stderr, "Locking in thread %d\n", pthread_self); + fprintf(stderr, "Locking in thread %lx\n", pthread_self()); status = sync_lock(ta->lockspace, ta->resource, ta->mode, ta->flags, &lockid); @@ -186,20 +172,20 @@ static void *thread_fn(void *arg) if (status) { if (ta->verbose) - fprintf(stderr, "Lock in thread %x failed: %s\n", pthread_self, strerror(errno)); + fprintf(stderr, "Lock in thread %lx failed: %s\n", pthread_self(), strerror(errno)); return NULL; } sleep(ta->delay); if (ta->verbose > 1) - fprintf(stderr, "Unlocking in thread %x\n", pthread_self()); + fprintf(stderr, "Unlocking in thread %lx\n", pthread_self()); status = sync_unlock(ta->lockspace,lockid); if (status) { if (ta->verbose) - fprintf(stderr, "Unlock in thread %x failed: %s\n", pthread_self(), strerror(errno)); + fprintf(stderr, "Unlock in thread %lx failed: %s\n", pthread_self(), strerror(errno)); } return NULL; @@ -208,14 +194,14 @@ static void *thread_fn(void *arg) int main(int argc, char *argv[]) { - char *resource = "LOCK-NAME"; - char *lockspace_name = "threadtest"; + char const *resource = "LOCK-NAME"; + char const *lockspace_name = "threadtest"; dlm_lshandle_t *lockspace; int flags = 0; int num_threads = 5; int delay = 1; - int mode; - int verbose; + int mode = LKM_EXMODE; + int verbose = 0; int i; signed char opt; pthread_t *threads; @@ -299,7 +285,7 @@ int main(int argc, char *argv[]) ta.flags = flags; ta.delay = delay; ta.verbose = verbose; - ta.resource = resource; + ta.resource = (char *)resource; for (i=0; i<num_threads; i++) {
reply other threads:[~2009-06-23 10:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090623102559.8925812037F@lists.fedorahosted.org \ --to=chrissie@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).