Whamcloud - gitweb
LU-5396 libcfs: make some functions static 07/12207/7
authorFrank Zago <fzago@cray.com>
Sun, 7 Sep 2014 18:00:28 +0000 (13:00 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Dec 2014 08:11:06 +0000 (08:11 +0000)
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 <fzago@cray.com>
Change-Id: I5bdf94633fb94e435d32691d521ad7c1234018aa
Reviewed-on: http://review.whamcloud.com/12207
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
15 files changed:
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_private.h
libcfs/libcfs/debug.c
libcfs/libcfs/linux/linux-crypto-adler.c
libcfs/libcfs/linux/linux-crypto-crc32.c
libcfs/libcfs/linux/linux-curproc.c
libcfs/libcfs/linux/linux-module.c
libcfs/libcfs/linux/linux-proc.c
libcfs/libcfs/linux/linux-tcpip.c
libcfs/libcfs/module.c
libcfs/libcfs/nidstrings.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h
libcfs/libcfs/workitem.c
lnet/include/lnet/nidstr.h

index cff0fcc..33dc487 100644 (file)
@@ -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 */
index 6f7953c..63b5b92 100644 (file)
@@ -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
index 417a494..e0d8717 100644 (file)
@@ -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);
index 5eec002..dd2aafd 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/module.h>
 #include <linux/zutil.h>
+#include <libcfs/linux/linux-crypto.h>
 #include <crypto/internal/hash.h>
 
 
index 83af630..3929950 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/module.h>
 #include <linux/crc32.h>
+#include <libcfs/linux/linux-crypto.h>
 #include <crypto/internal/hash.h>
 
 #define CHKSUM_BLOCK_SIZE      1
index cfe1641..f260225 100644 (file)
@@ -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);
index 668e3c5..f21c6f6 100644 (file)
@@ -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)
 {
index bb9dc04..5adddd3 100644 (file)
 #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,
index 9a12e8c..82a31d2 100644 (file)
@@ -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();
index b35bade..29ca9d2 100644 (file)
@@ -44,7 +44,7 @@
 #include <lnet/nidstr.h>
 #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 <braam@clusterfs.com>");
 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;
index 10e8f8d..3442b86 100644 (file)
@@ -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;
index c544e43..2114063 100644 (file)
@@ -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);
index 1291c58..0238bae 100644 (file)
@@ -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)
index 722b25d..0e56a3f 100644 (file)
@@ -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 */
index d2ab743..1f8be10 100644 (file)
@@ -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 */