From 336f628d5ea17cb0afe26cd966e333e40755b38b Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Sun, 7 Sep 2014 13:00:28 -0500 Subject: [PATCH] LU-5396 libcfs: make some functions static Some functions and variables are only used in their C file, so reduce their scope. This reduces the code size, and fixes sparse warnings such as: warning: symbol 'proc_lnet_routes' was not declared. Should it be static? warning: symbol 'proc_lnet_routers' was not declared. Should it be static? Some prototypes were removed from C files and added to the proper header. Signed-off-by: Frank Zago Change-Id: I5bdf94633fb94e435d32691d521ad7c1234018aa Reviewed-on: http://review.whamcloud.com/12207 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs.h | 3 +++ libcfs/include/libcfs/libcfs_private.h | 7 +++++++ libcfs/libcfs/debug.c | 12 ++++++------ libcfs/libcfs/linux/linux-crypto-adler.c | 1 + libcfs/libcfs/linux/linux-crypto-crc32.c | 1 + libcfs/libcfs/linux/linux-curproc.c | 4 ++-- libcfs/libcfs/linux/linux-module.c | 2 -- libcfs/libcfs/linux/linux-proc.c | 5 ----- libcfs/libcfs/linux/linux-tcpip.c | 2 +- libcfs/libcfs/module.c | 15 ++------------- libcfs/libcfs/nidstrings.c | 21 +++++++++++---------- libcfs/libcfs/tracefile.c | 2 +- libcfs/libcfs/tracefile.h | 9 +++++++++ libcfs/libcfs/workitem.c | 2 +- lnet/include/lnet/nidstr.h | 1 + 15 files changed, 46 insertions(+), 41 deletions(-) diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index cff0fcc..33dc487 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -298,4 +298,7 @@ static inline void *__container_of(const void *ptr, unsigned long shift) #define _LIBCFS_H +int libcfs_arch_init(void); +void libcfs_arch_cleanup(void); + #endif /* _LIBCFS_H */ diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 6f7953c..63b5b92 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -636,4 +636,11 @@ enum { GNIIPLND = 14, }; +extern struct cfs_psdev_ops libcfs_psdev_ops; +extern struct miscdevice libcfs_dev; +extern struct cfs_wi_sched *cfs_sched_rehash; + +extern int insert_proc(void); +extern void remove_proc(void); + #endif diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 417a494..e0d8717 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -57,7 +57,7 @@ CFS_MODULE_PARM(libcfs_debug, "i", int, 0644, "Lustre kernel debug mask"); EXPORT_SYMBOL(libcfs_debug); -unsigned int libcfs_debug_mb = 0; +static unsigned int libcfs_debug_mb; CFS_MODULE_PARM(libcfs_debug_mb, "i", uint, 0644, "Total debug buffer size."); EXPORT_SYMBOL(libcfs_debug_mb); @@ -93,7 +93,7 @@ EXPORT_SYMBOL(libcfs_debug_binary); unsigned int libcfs_stack = 3 * THREAD_SIZE / 4; EXPORT_SYMBOL(libcfs_stack); -unsigned int portal_enter_debugger; +static unsigned int portal_enter_debugger; EXPORT_SYMBOL(portal_enter_debugger); unsigned int libcfs_catastrophe; @@ -115,7 +115,7 @@ static wait_queue_head_t debug_ctlwq; char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT; /* We need to pass a pointer here, but elsewhere this must be a const */ -char *libcfs_debug_file_path; +static char *libcfs_debug_file_path; CFS_MODULE_PARM(libcfs_debug_file_path, "s", charp, 0644, "Path for dumping debug logs, " "set 'NONE' to prevent log dumping"); @@ -124,7 +124,7 @@ int libcfs_panic_in_progress; /* libcfs_debug_token2mask() expects the returned * string in lower-case */ -const char *libcfs_debug_subsys2str(int subsys) +static const char *libcfs_debug_subsys2str(int subsys) { static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES; @@ -136,7 +136,7 @@ const char *libcfs_debug_subsys2str(int subsys) /* libcfs_debug_token2mask() expects the returned * string in lower-case */ -const char *libcfs_debug_dbg2str(int debug) +static const char *libcfs_debug_dbg2str(int debug) { static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES; @@ -251,7 +251,7 @@ void libcfs_debug_dumplog_internal(void *arg) POP_JOURNAL; } -int libcfs_debug_dumplog_thread(void *arg) +static int libcfs_debug_dumplog_thread(void *arg) { libcfs_debug_dumplog_internal(arg); wake_up(&debug_ctlwq); diff --git a/libcfs/libcfs/linux/linux-crypto-adler.c b/libcfs/libcfs/linux/linux-crypto-adler.c index 5eec002..dd2aafd 100644 --- a/libcfs/libcfs/linux/linux-crypto-adler.c +++ b/libcfs/libcfs/linux/linux-crypto-adler.c @@ -31,6 +31,7 @@ #include #include +#include #include diff --git a/libcfs/libcfs/linux/linux-crypto-crc32.c b/libcfs/libcfs/linux/linux-crypto-crc32.c index 83af630..3929950 100644 --- a/libcfs/libcfs/linux/linux-crypto-crc32.c +++ b/libcfs/libcfs/linux/linux-crypto-crc32.c @@ -31,6 +31,7 @@ #include #include +#include #include #define CHKSUM_BLOCK_SIZE 1 diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index cfe1641..f260225 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -82,7 +82,7 @@ int cfs_cap_raised(cfs_cap_t cap) return cap_raised(current_cap(), cfs_cap_unpack(cap)); } -void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) +static void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) { #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 *cap = cfs_cap_pack(kcap); @@ -96,7 +96,7 @@ void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) #endif } -void cfs_kernel_cap_unpack(kernel_cap_t *kcap, cfs_cap_t cap) +static void cfs_kernel_cap_unpack(kernel_cap_t *kcap, cfs_cap_t cap) { #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 *kcap = cfs_cap_unpack(cap); diff --git a/libcfs/libcfs/linux/linux-module.c b/libcfs/libcfs/linux/linux-module.c index 668e3c5..f21c6f67 100644 --- a/libcfs/libcfs/linux/linux-module.c +++ b/libcfs/libcfs/linux/linux-module.c @@ -100,8 +100,6 @@ failed: RETURN(err); } -extern struct cfs_psdev_ops libcfs_psdev_ops; - static int libcfs_psdev_open(struct inode * inode, struct file * file) { diff --git a/libcfs/libcfs/linux/linux-proc.c b/libcfs/libcfs/linux/linux-proc.c index bb9dc04..5adddd3 100644 --- a/libcfs/libcfs/linux/linux-proc.c +++ b/libcfs/libcfs/linux/linux-proc.c @@ -70,11 +70,6 @@ #ifdef CONFIG_SYSCTL static struct ctl_table_header *lnet_table_header = NULL; #endif -extern char lnet_upcall[1024]; -/** - * The path of debug log dump upcall script. - */ -extern char lnet_debug_log_upcall[1024]; int lprocfs_call_handler(void *data, int write, loff_t *ppos, void __user *buffer, size_t *lenp, diff --git a/libcfs/libcfs/linux/linux-tcpip.c b/libcfs/libcfs/linux/linux-tcpip.c index 9a12e8c..82a31d2 100644 --- a/libcfs/libcfs/linux/linux-tcpip.c +++ b/libcfs/libcfs/linux/linux-tcpip.c @@ -51,7 +51,7 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) } #endif -int +static int libcfs_sock_ioctl(int cmd, unsigned long arg) { mm_segment_t oldmm = get_fs(); diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index b35bade..29ca9d2 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -44,7 +44,7 @@ #include #include "tracefile.h" -void +static void kportal_memhog_free (struct libcfs_device_userstate *ldu) { struct page **level0p = &ldu->ldu_memhog_root_page; @@ -87,7 +87,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu) LASSERT(ldu->ldu_memhog_pages == 0); } -int +static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages, gfp_t flags) { @@ -309,21 +309,10 @@ struct cfs_psdev_ops libcfs_psdev_ops = { libcfs_ioctl }; -extern int insert_proc(void); -extern void remove_proc(void); MODULE_AUTHOR("Peter J. Braam "); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); -extern struct miscdevice libcfs_dev; -extern struct rw_semaphore cfs_tracefile_sem; -extern struct mutex cfs_trace_thread_mutex; -extern struct cfs_wi_sched *cfs_sched_rehash; - -extern void libcfs_init_nidstrings(void); -extern int libcfs_arch_init(void); -extern void libcfs_arch_cleanup(void); - static int init_libcfs_module(void) { int rc; diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index 10e8f8d..3442b86 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -278,16 +278,17 @@ static struct netstrfns libcfs_netstrfns[] = { {/* .nf_type */ -1}, }; -const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]); +static const int libcfs_nnetstrfns = + sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]); -int +static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr) { *addr = 0; return 1; } -void +static void libcfs_ip_addr2str(__u32 addr, char *str) { #if 0 /* never lookup */ @@ -313,7 +314,7 @@ libcfs_ip_addr2str(__u32 addr, char *str) * fine, if it doesn't, then the scan ended at the end of the string, which is * fine too :) */ -int +static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) { unsigned int a; @@ -360,19 +361,19 @@ libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) return 0; } -void +static void libcfs_decnum_addr2str(__u32 addr, char *str) { snprintf(str, LNET_NIDSTR_SIZE, "%u", addr); } -void +static void libcfs_hexnum_addr2str(__u32 addr, char *str) { snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr); } -int +static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr) { int n; @@ -392,7 +393,7 @@ libcfs_num_str2addr(const char *str, int nob, __u32 *addr) return 0; } -struct netstrfns * +static struct netstrfns * libcfs_lnd2netstrfns(int lnd) { int i; @@ -405,7 +406,7 @@ libcfs_lnd2netstrfns(int lnd) return NULL; } -struct netstrfns * +static struct netstrfns * libcfs_namenum2netstrfns(const char *name) { struct netstrfns *nf; @@ -420,7 +421,7 @@ libcfs_namenum2netstrfns(const char *name) return NULL; } -struct netstrfns * +static struct netstrfns * libcfs_name2netstrfns(const char *name) { int i; diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index c544e43..2114063 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -55,7 +55,7 @@ static struct tracefiled_ctl trace_tctl; struct mutex cfs_trace_thread_mutex; static int thread_running = 0; -atomic_t cfs_tage_allocated = ATOMIC_INIT(0); +static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); static void put_pages_on_tcd_daemon_list(struct page_collection *pc, struct cfs_trace_cpu_data *tcd); diff --git a/libcfs/libcfs/tracefile.h b/libcfs/libcfs/tracefile.h index 1291c58..0238bae 100644 --- a/libcfs/libcfs/tracefile.h +++ b/libcfs/libcfs/tracefile.h @@ -52,6 +52,12 @@ typedef enum { extern char cfs_tracefile[TRACEFILE_NAME_SIZE]; extern long long cfs_tracefile_size; +extern char lnet_upcall[1024]; +/** + * The path of debug log dump upcall script. + */ +extern char lnet_debug_log_upcall[1024]; + extern void libcfs_run_debug_log_upcall(char *file); int cfs_tracefile_init_arch(void); @@ -91,6 +97,9 @@ extern void libcfs_unregister_panic_notifier(void); extern int libcfs_panic_in_progress; extern int cfs_trace_max_debug_mb(void); +extern struct mutex cfs_trace_thread_mutex; +extern struct rw_semaphore cfs_tracefile_sem; + #define TCD_MAX_PAGES (5 << (20 - PAGE_CACHE_SHIFT)) #define TCD_STOCK_PAGES (TCD_MAX_PAGES) #define CFS_TRACEFILE_SIZE (500 << 20) diff --git a/libcfs/libcfs/workitem.c b/libcfs/libcfs/workitem.c index 722b25d..0e56a3f 100644 --- a/libcfs/libcfs/workitem.c +++ b/libcfs/libcfs/workitem.c @@ -77,7 +77,7 @@ typedef struct cfs_wi_sched { char ws_name[CFS_WS_NAME_LEN]; } cfs_wi_sched_t; -struct cfs_workitem_data { +static struct cfs_workitem_data { /** serialize */ spinlock_t wi_glock; /** list of all schedulers */ diff --git a/lnet/include/lnet/nidstr.h b/lnet/include/lnet/nidstr.h index d2ab743..1f8be10 100644 --- a/lnet/include/lnet/nidstr.h +++ b/lnet/include/lnet/nidstr.h @@ -25,5 +25,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *list); bool cfs_nidrange_is_contiguous(struct list_head *nidlist); void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid, char *max_nid, int nidstr_length); +void libcfs_init_nidstrings(void); #endif /* _LNET_NIDSTRINGS_H */ -- 1.8.3.1