diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 49d819ece46f8b1180b0dcb94a270c136e73615e..87037f0f50eb41c96505a8ca19ff21eaca0a9826 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 36203554276073dfda253a642bf44aeff9667a25..05254eaba85ee088998c5607ed1b8cb92ffc2528 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 5ed4a74f94deb20663a416b4fd9313f52c1d2f9c..b6889f753c1f52492faaba66fcfa6685397d20d9 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 fc10f9c376370342e3a98ac414884fdd84672066..34bd02cb327e54805620d4641642380d24b989e7 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 41848c2bd1f110cc6311d6fc148572b4a79631a6..12ec7a9d8445178296fe13feafba6f9e95d43de2 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 e405ceb24c2196629f5025b69020ada7282e6b97..2ecdba5cff861ead75b9f9f014c01740df35830a 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 a6b10f0c9373c49d1499cd60bd9eaaf700416d23..1d2416755940b4946ca9c94e1390fb72dbc62b1f 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 18317f662c4d6f5ed3079eff569f86446ddaa099..6a8a4f2fa149b4a56bf37eaeba7e643cf9bdb817 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 9107ebbea368a74dfd213df8374b8c0dd6d07541..5530832d080cb94bf2a49bc327daf1e9cdc63db3 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 7b23ba987f174ca2092f2edd33684a63065e8308..07678e0920ab45c7860eb90f314af1125066b601 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 dff082b10e3a8fd44dcbf912da8a211d6d208596..e226608fdf56afdd2b86bb4357b6cd3dbc547488 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