From: girish Date: Wed, 27 Aug 2008 12:27:57 +0000 (+0000) Subject: Quiet compiler warnings related to passing "const" pointers to non-const X-Git-Tag: v1_7_110~41 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7d1ace7a1ef928de77bd459dfd83f48889454e50 Quiet compiler warnings related to passing "const" pointers to non-const functions. (Andreas) b=15981 i=girish i=rread --- diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 49d819e..87037f0 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -54,7 +54,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/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 3620355..05254ea 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -135,7 +135,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__) @@ -223,12 +223,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/libcfs/include/libcfs/user-bitops.h b/libcfs/include/libcfs/user-bitops.h index 5ed4a74..b6889f7 100644 --- a/libcfs/include/libcfs/user-bitops.h +++ b/libcfs/include/libcfs/user-bitops.h @@ -42,9 +42,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)); @@ -54,9 +54,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)); @@ -65,9 +65,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/libcfs/libcfs/darwin/darwin-debug.c b/libcfs/libcfs/darwin/darwin-debug.c index fc10f9c..34bd02c 100644 --- a/libcfs/libcfs/darwin/darwin-debug.c +++ b/libcfs/libcfs/darwin/darwin-debug.c @@ -40,15 +40,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/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 41848c2..12ec7a9 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -113,15 +113,15 @@ 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 -char *debug_file_path_p = &debug_file_path[0]; - -CFS_MODULE_PARM(debug_file_path_p, "s", charp, 0644, +/* 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"); @@ -427,10 +427,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); @@ -515,7 +515,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/libcfs/libcfs/linux/linux-debug.c b/libcfs/libcfs/linux/linux-debug.c index e405ceb..2ecdba5 100644 --- a/libcfs/libcfs/linux/linux-debug.c +++ b/libcfs/libcfs/linux/linux-debug.c @@ -151,7 +151,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]; @@ -160,7 +160,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; @@ -169,7 +169,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, @@ -181,7 +181,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/libcfs/libcfs/linux/linux-proc.c b/libcfs/libcfs/linux/linux-proc.c index a6b10f0..1d24167 100644 --- a/libcfs/libcfs/linux/linux-proc.c +++ b/libcfs/libcfs/linux/linux-proc.c @@ -375,8 +375,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/libcfs/libcfs/posix/posix-debug.c b/libcfs/libcfs/posix/posix-debug.c index 18317f6..6a8a4f2 100644 --- a/libcfs/libcfs/posix/posix-debug.c +++ b/libcfs/libcfs/posix/posix-debug.c @@ -216,7 +216,7 @@ int libcfs_debug_clear_buffer(void) return 0; } -int libcfs_debug_mark_buffer(char *text) +int libcfs_debug_mark_buffer(const char *text) { fprintf(debug_file_fd, "*******************************************************************************\n"); diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 9107ebb..5530832 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -448,7 +448,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/libcfs/libcfs/user-prim.c b/libcfs/libcfs/user-prim.c index 7b23ba9..07678e0 100644 --- a/libcfs/libcfs/user-prim.c +++ b/libcfs/libcfs/user-prim.c @@ -356,7 +356,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/libcfs/libcfs/winnt/winnt-debug.c b/libcfs/libcfs/winnt/winnt-debug.c index dff082b..e226608 100644 --- a/libcfs/libcfs/winnt/winnt-debug.c +++ b/libcfs/libcfs/winnt/winnt-debug.c @@ -40,12 +40,12 @@ #include "tracefile.h" void lnet_debug_dumpstack(cfs_task_t *tsk) -{ +{ return; } cfs_task_t *lnet_current(void) -{ +{ return cfs_current(); } @@ -59,17 +59,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