From 067dfd8d2701572ebe7246726c14a6e72a78cb33 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Fri, 23 Jun 2023 20:31:30 +0000 Subject: [PATCH] LU-8191 libcfs: convert functions to static, removed function Static analysis shows that a number of functions could be made static. This patch declares several functions in libcfs static. Remove cfs_expr_list_values_free in string.c, since it is not used. A header was missing in param.c, causing a number of functions to be missing declarations. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: Ia580881efa806bde49d532e5b2d8f5097f2294e0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51428 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/libcfs/tracefile.c | 6 +++--- libcfs/libcfs/util/nidstrings.c | 4 ++-- libcfs/libcfs/util/param.c | 1 + libcfs/libcfs/util/string.c | 9 --------- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index e45cf82..acb8389 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -77,7 +77,7 @@ static DECLARE_RWSEM(cfs_tracefile_sem); * with other interrupt locks that might be happening. See LU-1311 * for details. */ -int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking) +static int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking) __acquires(&tcd->tcd_lock) { __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_CNT); @@ -92,7 +92,7 @@ int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking) return 1; } -void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) +static void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) __releases(&tcd->tcd_lock) { __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_CNT); @@ -117,7 +117,7 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++) -enum cfs_trace_buf_type cfs_trace_buf_idx_get(void) +static enum cfs_trace_buf_type cfs_trace_buf_idx_get(void) { if (in_irq()) return CFS_TCD_TYPE_IRQ; diff --git a/libcfs/libcfs/util/nidstrings.c b/libcfs/libcfs/util/nidstrings.c index e9fab1c..c9e31a4 100644 --- a/libcfs/libcfs/util/nidstrings.c +++ b/libcfs/libcfs/util/nidstrings.c @@ -1202,7 +1202,7 @@ libcfs_net_str_len(const char *str) return 0; } -int +static int parse_net_range(char *str, __u32 len, struct list_head *net_num, __u32 *net_type) { @@ -1262,7 +1262,7 @@ parse_net_range(char *str, __u32 len, struct list_head *net_num, net_num); } -int +static int parse_address(struct cfs_lstr *src, const __u32 net_type, struct list_head *addr) { diff --git a/libcfs/libcfs/util/param.c b/libcfs/libcfs/util/param.c index 18fe84d..a33cd52 100644 --- a/libcfs/libcfs/util/param.c +++ b/libcfs/libcfs/util/param.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/libcfs/libcfs/util/string.c b/libcfs/libcfs/util/string.c index f957db6..205f3c3 100644 --- a/libcfs/libcfs/util/string.c +++ b/libcfs/libcfs/util/string.c @@ -334,15 +334,6 @@ cfs_expr_list_values(struct cfs_expr_list *expr_list, int max, __u32 **valpp) return count; } -void -cfs_expr_list_values_free(__u32 *values, int num) -{ - /* This array is allocated by LIBCFS_ALLOC(), so it shouldn't be freed - * by OBD_FREE() if it's called by module other than libcfs & LNet, - * otherwise we will see fake memory leak */ - free(values); -} - /** * Frees cfs_range_expr structures of \a expr_list. * -- 1.8.3.1