From 0ccae3bd3eb741b8509b4f1a58837acc644dbfce Mon Sep 17 00:00:00 2001 From: girish Date: Wed, 27 Aug 2008 16:30:15 +0000 Subject: [PATCH] Quiet compiler warnings related to passing "const" pointers to non-const functions. (Andreas) b=15981 i=girish i=rread --- lnet/include/libcfs/kp30.h | 6 +++--- lnet/include/libcfs/libcfs.h | 2 +- lnet/include/libcfs/user-bitops.h | 13 +++++++------ lnet/libcfs/darwin/darwin-debug.c | 6 +++--- lnet/libcfs/debug.c | 16 +++++++++------- lnet/libcfs/linux/linux-debug.c | 8 ++++---- lnet/libcfs/linux/linux-proc.c | 4 ++-- lnet/libcfs/tracefile.c | 2 +- lnet/libcfs/user-prim.c | 2 +- lnet/libcfs/winnt/winnt-debug.c | 18 +++++++++++------- 10 files changed, 42 insertions(+), 35 deletions(-) diff --git a/lnet/include/libcfs/kp30.h b/lnet/include/libcfs/kp30.h index 8e35822..8b7249e 100644 --- a/lnet/include/libcfs/kp30.h +++ b/lnet/include/libcfs/kp30.h @@ -133,7 +133,7 @@ #define KLASSERT(e) LASSERT(e) -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) __attribute__((noreturn)); #define LBUG() lbug_with_loc(__FILE__, __FUNCTION__, __LINE__) @@ -221,12 +221,12 @@ do { \ void libcfs_debug_dumpstack(cfs_task_t *tsk); void libcfs_run_upcall(char **argv); -void libcfs_run_lbug_upcall(char * file, const char *fn, const int line); +void libcfs_run_lbug_upcall(const char * file, const char *fn, const int line); void libcfs_debug_dumplog(void); int libcfs_debug_init(unsigned long bufsize); int libcfs_debug_cleanup(void); int libcfs_debug_clear_buffer(void); -int libcfs_debug_mark_buffer(char *text); +int libcfs_debug_mark_buffer(const char *text); void libcfs_debug_set_level(unsigned int debug_level); diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h index 753774c..8e19a39 100644 --- a/lnet/include/libcfs/libcfs.h +++ b/lnet/include/libcfs/libcfs.h @@ -111,7 +111,7 @@ extern cfs_duration_t libcfs_console_max_delay; extern cfs_duration_t libcfs_console_min_delay; extern unsigned int libcfs_console_backoff; extern unsigned int libcfs_debug_binary; -extern char debug_file_path[1024]; +extern char debug_file_path_arr[1024]; int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys); int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys); diff --git a/lnet/include/libcfs/user-bitops.h b/lnet/include/libcfs/user-bitops.h index cfd6652..0c8aae9 100644 --- a/lnet/include/libcfs/user-bitops.h +++ b/lnet/include/libcfs/user-bitops.h @@ -44,9 +44,9 @@ #define __LIBCFS_USER_BITOPS_H__ /* test if bit nr is set in bitmap addr; returns previous value of bit nr */ -static __inline__ int set_bit(int nr, unsigned long * addr) +static __inline__ int set_bit(int nr, unsigned long *addr) { - long mask; + unsigned long mask; addr += nr / BITS_PER_LONG; mask = 1UL << (nr & (BITS_PER_LONG - 1)); @@ -56,9 +56,9 @@ static __inline__ int set_bit(int nr, unsigned long * addr) } /* clear bit nr in bitmap addr; returns previous value of bit nr*/ -static __inline__ int clear_bit(int nr, unsigned long * addr) +static __inline__ int clear_bit(int nr, unsigned long *addr) { - long mask; + unsigned long mask; addr += nr / BITS_PER_LONG; mask = 1UL << (nr & (BITS_PER_LONG - 1)); @@ -67,9 +67,10 @@ static __inline__ int clear_bit(int nr, unsigned long * addr) return nr; } -static __inline__ int test_bit(int nr, const unsigned long * addr) +static __inline__ int test_bit(int nr, const unsigned long *addr) { - return ((1UL << (nr & (BITS_PER_LONG - 1))) & ((addr)[nr / BITS_PER_LONG])) != 0; + return ((1UL << (nr & (BITS_PER_LONG - 1))) & + ((addr)[nr / BITS_PER_LONG])) != 0; } /* using binary seach */ diff --git a/lnet/libcfs/darwin/darwin-debug.c b/lnet/libcfs/darwin/darwin-debug.c index 13e044c..e51f02e 100644 --- a/lnet/libcfs/darwin/darwin-debug.c +++ b/lnet/libcfs/darwin/darwin-debug.c @@ -41,15 +41,15 @@ #include "tracefile.h" void libcfs_debug_dumpstack(cfs_task_t *tsk) -{ +{ return; } -void libcfs_run_lbug_upcall(char *file, const char *fn, const int line) +void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line) { } -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { libcfs_catastrophe = 1; CEMERG("LBUG: pid: %u thread: %#x\n", diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c index fb2fe5c..6adaa83 100644 --- a/lnet/libcfs/debug.c +++ b/lnet/libcfs/debug.c @@ -116,12 +116,14 @@ EXPORT_SYMBOL(libcfs_kmemory); static cfs_waitq_t debug_ctlwq; #ifdef HAVE_BGL_SUPPORT -char debug_file_path[1024] = "/bgl/ion/tmp/lustre-log"; +char debug_file_path_arr[1024] = "/bgl/ion/tmp/lustre-log"; #elif defined(__arch_um__) -char debug_file_path[1024] = "/r/tmp/lustre-log"; +char debug_file_path_arr[1024] = "/r/tmp/lustre-log"; #else -char debug_file_path[1024] = "/tmp/lustre-log"; +char debug_file_path_arr[1024] = "/tmp/lustre-log"; #endif +/* We need to pass a pointer here, but elsewhere this must be a const */ +static char *debug_file_path = &debug_file_path_arr[0]; CFS_MODULE_PARM(debug_file_path, "s", charp, 0644, "Path for dumping debug logs, " "set 'NONE' to prevent log dumping"); @@ -430,10 +432,10 @@ void libcfs_debug_dumplog_internal(void *arg) CFS_PUSH_JOURNAL; - if (strncmp(debug_file_path, "NONE", 4) != 0) { + if (strncmp(debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, - "%s.%ld.%ld", debug_file_path, cfs_time_current_sec(), - (long)arg); + "%s.%ld.%ld", debug_file_path_arr, + cfs_time_current_sec(), (long)arg); printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name); tracefile_dump_all_pages(debug_file_name); @@ -518,7 +520,7 @@ int libcfs_debug_clear_buffer(void) * should not be be marked as such. */ #undef DEBUG_SUBSYSTEM #define DEBUG_SUBSYSTEM S_UNDEFINED -int libcfs_debug_mark_buffer(char *text) +int libcfs_debug_mark_buffer(const char *text) { CDEBUG(D_TRACE,"***************************************************\n"); CDEBUG(D_WARNING, "DEBUG MARKER: %s\n", text); diff --git a/lnet/libcfs/linux/linux-debug.c b/lnet/libcfs/linux/linux-debug.c index e0eade8..41b8a80 100644 --- a/lnet/libcfs/linux/linux-debug.c +++ b/lnet/libcfs/linux/linux-debug.c @@ -152,7 +152,7 @@ void libcfs_run_upcall(char **argv) } } -void libcfs_run_lbug_upcall(char *file, const char *fn, const int line) +void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line) { char *argv[6]; char buf[32]; @@ -161,7 +161,7 @@ void libcfs_run_lbug_upcall(char *file, const char *fn, const int line) snprintf (buf, sizeof buf, "%d", line); argv[1] = "LBUG"; - argv[2] = file; + argv[2] = (char *)file; argv[3] = (char *)fn; argv[4] = buf; argv[5] = NULL; @@ -170,7 +170,7 @@ void libcfs_run_lbug_upcall(char *file, const char *fn, const int line) } #ifdef __arch_um__ -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { libcfs_catastrophe = 1; libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, @@ -182,7 +182,7 @@ void lbug_with_loc(char *file, const char *func, const int line) } #else /* coverity[+kill] */ -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { libcfs_catastrophe = 1; libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "LBUG\n"); diff --git a/lnet/libcfs/linux/linux-proc.c b/lnet/libcfs/linux/linux-proc.c index cbada7ca..7ef90b7 100644 --- a/lnet/libcfs/linux/linux-proc.c +++ b/lnet/libcfs/linux/linux-proc.c @@ -374,8 +374,8 @@ static cfs_sysctl_table_t lnet_table[] = { { .ctl_name = PSDEV_DEBUG_PATH, .procname = "debug_path", - .data = debug_file_path, - .maxlen = sizeof(debug_file_path), + .data = debug_file_path_arr, + .maxlen = sizeof(debug_file_path_arr), .mode = 0644, .proc_handler = &proc_dostring, }, diff --git a/lnet/libcfs/tracefile.c b/lnet/libcfs/tracefile.c index fac840b..35655d9 100644 --- a/lnet/libcfs/tracefile.c +++ b/lnet/libcfs/tracefile.c @@ -449,7 +449,7 @@ libcfs_assertion_failed(const char *expr, const char *file, { libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "ASSERTION(%s) failed\n", expr); - LBUG(); + lbug_with_loc(file, func, line); } EXPORT_SYMBOL(libcfs_assertion_failed); diff --git a/lnet/libcfs/user-prim.c b/lnet/libcfs/user-prim.c index 82ce150..71ca01e 100644 --- a/lnet/libcfs/user-prim.c +++ b/lnet/libcfs/user-prim.c @@ -394,7 +394,7 @@ void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no) /* __linux__ */ #endif -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { /* No libcfs_catastrophe in userspace! */ libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "LBUG\n"); diff --git a/lnet/libcfs/winnt/winnt-debug.c b/lnet/libcfs/winnt/winnt-debug.c index b06706b..2f6eb07 100644 --- a/lnet/libcfs/winnt/winnt-debug.c +++ b/lnet/libcfs/winnt/winnt-debug.c @@ -41,12 +41,12 @@ #include "tracefile.h" void lnet_debug_dumpstack(cfs_task_t *tsk) -{ +{ return; } cfs_task_t *lnet_current(void) -{ +{ return cfs_current(); } @@ -60,17 +60,21 @@ int lnet_arch_debug_cleanup(void) return 0; } -void lnet_run_lbug_upcall(char *file, const char *fn, const int line) +void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line) +{ +} + +void libcfs_debug_dumplog(void) { } -void lbug_with_loc(char *file, const char *func, const int line) +void lbug_with_loc(const char *file, const char *func, const int line) { libcfs_catastrophe = 1; CEMERG("LBUG: pid: %u thread: %#x\n", - (unsigned)cfs_curproc_pid(), (unsigned)PsGetCurrentThread()); - // portals_debug_dumplog(); - // portals_run_lbug_upcall(file, func, line); + (unsigned)cfs_curproc_pid(), (unsigned)PsGetCurrentThread()); + libcfs_debug_dumplog(); + libcfs_run_lbug_upcall(file, func, line); } #if TDI_LIBCFS_DBG -- 1.8.3.1