Declare functions as static
cover Declare functions as static
These patches declare the functions and structures which are not used anywhere else as static.
Shraddha Barke (5):
Staging: lustre: obdclass: cl_io: Declare as static
Staging: lustre: obdclass: cl_lock: Declare as static
Staging: lustre: obdclass: obd_config: Declare as static
Staging: lustre: obdclass: genops: Declare as static
Staging: lustre: obdclass: class_obd: Declare as static
drivers/staging/lustre/lustre/include/cl_object.h | 5 ---- .../staging/lustre/lustre/include/lustre_param.h | 1 - drivers/staging/lustre/lustre/include/obd_class.h | 7 ------ drivers/staging/lustre/lustre/obdclass/cl_io.c | 28 ++++++++++------------ drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 ++++---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++--- .../staging/lustre/lustre/obdclass/llog_internal.h | 1 - .../staging/lustre/lustre/obdclass/obd_config.c | 27 +++++++++------------ 9 files changed, 30 insertions(+), 57 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/5 Staging: lustre: obdclass: cl_io: Declare as static
Declare cl_page_list_assume, cl_io_cancel, cl_io_rw_advance, cl_page_list_del, cl_page_list_discard, cl_page_list_fini as static since they are used only in this particular file. Also remove them from corresponding header files
--- drivers/staging/lustre/lustre/include/cl_object.h | 5 ---- drivers/staging/lustre/lustre/obdclass/cl_io.c | 28 ++++++++++------------- 2 files changed, 12 insertions(+), 21 deletions(-)
drivers/staging/lustre/lustre/include/cl_object.h +0 -5
@@ -3125,13 +3125,8 @@ void cl_page_list_move (struct cl_page_list *dst, struct cl_page_list *src, struct cl_page *page);void cl_page_list_splice (struct cl_page_list *list,struct cl_page_list *head); -void cl_page_list_del (const struct lu_env *env, -struct cl_page_list *plist,struct cl_page *page);void cl_page_list_disown (const struct lu_env *env,struct cl_io *io,struct cl_page_list *plist); -void cl_page_list_discard (const struct lu_env *env, -struct cl_io *io,struct cl_page_list *plist); -void cl_page_list_fini (const struct lu_env *env,struct cl_page_list *plist);void cl_2queue_init (struct cl_2queue *queue);void cl_2queue_add (struct cl_2queue *queue,struct cl_page *page);
drivers/staging/lustre/lustre/obdclass/cl_io.c +12 -16
@@ -570,7 +570,8 @@ EXPORT_SYMBOL(cl_io_iter_fini);/** * Records that read or write io progressed \a nob bytes forward. */ -void cl_io_rw_advance (const struct lu_env *env,struct cl_io *io,size_t nob) +static void cl_io_rw_advance (const struct lu_env *env,struct cl_io *io, +size_t nob) {const struct cl_io_slice *scan;
@@ -589,7 +590,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob) nob); } } -EXPORT_SYMBOL (cl_io_rw_advance);/** * Adds a lock to a lockset.
@@ -936,8 +936,8 @@ EXPORT_SYMBOL(cl_io_submit_sync);/** * Cancel an IO which has been submitted by cl_io_submit_rw. */ -int cl_io_cancel (const struct lu_env *env,struct cl_io *io, -struct cl_page_list *queue) +static int cl_io_cancel (const struct lu_env *env,struct cl_io *io, +struct cl_page_list *queue) {struct cl_page *page;int result =0 ;
@@ -952,7 +952,6 @@ int cl_io_cancel(const struct lu_env *env, struct cl_io *io, }return result; } -EXPORT_SYMBOL (cl_io_cancel);/** * Main io loop.
@@ -1076,8 +1075,8 @@ EXPORT_SYMBOL(cl_page_list_add);/** * Removes a page from a page list. */ -void cl_page_list_del (const struct lu_env *env, -struct cl_page_list *plist,struct cl_page *page) +static void cl_page_list_del (const struct lu_env *env, +struct cl_page_list *plist,struct cl_page *page) {LASSERT (plist->pl_nr >0 );LINVRNT (plist->pl_owner == current);
@@ -1090,7 +1089,6 @@ void cl_page_list_del(const struct lu_env *env,lu_ref_del_at (&page->cp_reference, &page->cp_queue_ref,"queue" , plist);cl_page_put (env, page); } -EXPORT_SYMBOL (cl_page_list_del);/** * Moves a page from one page list to another.
@@ -1167,7 +1165,8 @@ EXPORT_SYMBOL(cl_page_list_disown);/** * Releases pages from queue. */ -void cl_page_list_fini (const struct lu_env *env,struct cl_page_list *plist) +static void cl_page_list_fini (const struct lu_env *env, +struct cl_page_list *plist) {struct cl_page *page;struct cl_page *temp;
@@ -1178,13 +1177,12 @@ void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist)cl_page_list_del (env, plist, page);LASSERT (plist->pl_nr ==0 ); } -EXPORT_SYMBOL (cl_page_list_fini);/** * Assumes all pages in a queue. */ -void cl_page_list_assume (const struct lu_env *env, -struct cl_io *io,struct cl_page_list *plist) +static void cl_page_list_assume (const struct lu_env *env, +struct cl_io *io,struct cl_page_list *plist) {struct cl_page *page;
@@ -1193,13 +1191,12 @@ void cl_page_list_assume(const struct lu_env *env,cl_page_list_for_each (page, plist)cl_page_assume (env, io, page); } -EXPORT_SYMBOL (cl_page_list_assume);/** * Discards all pages in a queue. */ -void cl_page_list_discard (const struct lu_env *env,struct cl_io *io, -struct cl_page_list *plist) +static void cl_page_list_discard (const struct lu_env *env,struct cl_io *io, +struct cl_page_list *plist) {struct cl_page *page;
@@ -1207,7 +1204,6 @@ void cl_page_list_discard(const struct lu_env *env, struct cl_io *io,cl_page_list_for_each (page, plist)cl_page_discard (env, io, page); } -EXPORT_SYMBOL (cl_page_list_discard);/** * Initialize dual page queue.
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 1/5] Staging: lustre: obdclass: cl_io: Declare as static
Quoted 7 lines · On Friday 02 October 2015 23:19:10 Shraddha Barke wrote:
Declare
cl_page_list_assume,cl_io_cancel,cl_io_rw_advance,cl_page_list_del,cl_page_list_discard,cl_page_list_finias static since they are used only in this particular file. Also remove them from corresponding header filesSigned-off-by Shraddha Barke <[email protected]>
PATCH 2/5 Staging: lustre: obdclass: cl_lock: Declare as static
In reply to Shraddha BarkeDeclare cl_lock_intransit and cl_lock_extransit as static since they are used only in this particular file.
--- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/obdclass/cl_lock.c +4 -6
@@ -403,8 +403,8 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,* \post state: CLS_INTRANSIT * \see CLS_INTRANSIT */ -enum cl_lock_state cl_lock_intransit (const struct lu_env *env, -struct cl_lock *lock) +static enum cl_lock_state cl_lock_intransit (const struct lu_env *env, +struct cl_lock *lock) {enum cl_lock_state state = lock->cll_state;
@@ -418,13 +418,12 @@ enum cl_lock_state cl_lock_intransit(const struct lu_env *env,cl_lock_hold_add (env, lock,"intransit" , current);return state; } -EXPORT_SYMBOL (cl_lock_intransit);/** * Exit the intransit state and restore the lock state to the original state */ -void cl_lock_extransit (const struct lu_env *env,struct cl_lock *lock, -enum cl_lock_state state) +static void cl_lock_extransit (const struct lu_env *env,struct cl_lock *lock, +enum cl_lock_state state) {LASSERT (cl_lock_is_mutexed (lock));LASSERT (lock->cll_state ==CLS_INTRANSIT );
@@ -435,7 +434,6 @@ void cl_lock_extransit(const struct lu_env *env, struct cl_lock *lock,cl_lock_state_set (env, lock, state);cl_lock_unhold (env, lock,"intransit" , current); } -EXPORT_SYMBOL (cl_lock_extransit);/** * Checking whether the lock is intransit state
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 2/5] Staging: lustre: obdclass: cl_lock: Declare as static
Quoted 8 lines · On Friday 02 October 2015 23:19:11 Shraddha Barke wrote:
Declare
cl_lock_intransitandcl_lock_extransitas static since they are used only in this particular file.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
I still see declarations for these functions in cl_object.h, you should remove them at the same time.
I would have expected to see a compile-time error as a result of your patch, because you have an extern declaration and a static definition for the same symbol.
Can you find out what happened?
Arnd
Re: [Outreachy kernel] [PATCH 2/5] Staging: lustre: obdclass: cl_lock: Declare as static
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Friday 02 October 2015 23:19:11 Shraddha Barke wrote:
Declare
cl_lock_intransitandcl_lock_extransitas static since they are used only in this particular file.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Quoted 6 lines
I still see declarations for these functions in
cl_object.h, you should remove them at the same time.I would have expected to see a compile-time error as a result of your patch, because you have an extern declaration and a static definition for the same symbol.
Yes that would normally happen. But the declarations for these were removed in another patch 4 days ago.
https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing&id=a83a765d14df24c8fa0fc500d24b0334638ee828
Quoted 5 lines
Can you find out what happened?
Arnd
Arnd Bergmann
Reviewed-byRe: [Outreachy kernel] [PATCH 2/5] Staging: lustre: obdclass: cl_lock: Declare as static
Quoted 15 lines · On Saturday 03 October 2015 02:21:10 Shraddha Barke wrote:
Quoted 13 lines · Arnd Bergmann
Quoted 8 lines · On Friday 02 October 2015 23:19:11 Shraddha Barke wrote:
Declare
cl_lock_intransitandcl_lock_extransitas static since they are used only in this particular file.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)I still see declarations for these functions in
cl_object.h, you should remove them at the same time.
Quoted 7 lines
Quoted 3 lines
I would have expected to see a compile-time error as a result of your patch, because you have an extern declaration and a static definition for the same symbol.
Yes that would normally happen. But the declarations for these were removed in another patch 4 days ago.
https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing&id=a83a765d14df24c8fa0fc500d24b0334638ee828
Ah, got it. I guess it was actually me who removed the lines, I just forgot about it, and I would have thought that I put them back.
My initial dead code removal patch converted these two into static functions already, but then I realized just how much work it was to do them all at once, and I decided to revert that conversion for the time being and only do the code removal then.
for your patch:
PATCH 3/5 Staging: lustre: obdclass: obd_config: Declare as static
In reply to Shraddha BarkeDeclare class_add_conn, class_add_profile, class_cleanup, class_config_parse_rec, class_del_conn, class_detach, class_match_param, class_attach, class_setup as static since they are used only in this particular file. Also remove the corresponding declarations from header files.
--- .../staging/lustre/lustre/include/lustre_param.h | 1 - drivers/staging/lustre/lustre/include/obd_class.h | 5 ---- .../staging/lustre/lustre/obdclass/llog_internal.h | 1 - .../staging/lustre/lustre/obdclass/obd_config.c | 27 +++++++++------------- 4 files changed, 11 insertions(+), 23 deletions(-)
drivers/staging/lustre/lustre/include/lustre_param.h +0 -1
@@ -56,7 +56,6 @@ struct cfg_interop_param {/* obd_config.c */ int class_find_param (char *buf,char *key,char **valp); -int class_match_param (char *buf,char *key,char **valp);int class_parse_nid (char *buf,lnet_nid_t *nid,char **endh);int class_parse_nid_quiet (char *buf,lnet_nid_t *nid,char **endh);/* obd_mount.c */
drivers/staging/lustre/lustre/include/obd_class.h +0 -5
@@ -109,10 +109,6 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,int class_process_config (struct lustre_cfg *lcfg);int class_process_proc_param (char *prefix,struct lprocfs_vars *lvars,struct lustre_cfg *lcfg,void *data); -int class_attach (struct lustre_cfg *lcfg); -int class_setup (struct obd_device *obd,struct lustre_cfg *lcfg); -int class_cleanup (struct obd_device *obd,struct lustre_cfg *lcfg); -int class_detach (struct obd_device *obd,struct lustre_cfg *lcfg);struct obd_device *class_incref (struct obd_device *obd,const char *scope,const void *source); void class_decref(struct obd_device *obd,
@@ -121,7 +117,6 @@ void dump_exports(struct obd_device *obd, int locks);int class_config_llog_handler (const struct lu_env *env,struct llog_handle *handle,struct llog_rec_hdr *rec,void *data); -int class_add_conn (struct obd_device *obd,struct lustre_cfg *lcfg);int class_add_uuid (const char *uuid,__u64 nid);/*obdecho*/
drivers/staging/lustre/lustre/obdclass/llog_internal.h +0 -1
@@ -71,7 +71,6 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle,int class_config_dump_handler (const struct lu_env *env,struct llog_handle *handle,struct llog_rec_hdr *rec,void *data); -int class_config_parse_rec (struct llog_rec_hdr *rec,char *buf,int size);int llog_process_or_fork (const struct lu_env *env,struct llog_handle *loghandle,llog_cb_t cb,void *data,void *catdata,bool fork);
drivers/staging/lustre/lustre/obdclass/obd_config.c +11 -16
@@ -72,7 +72,7 @@ EXPORT_SYMBOL(class_find_param);/* returns 0 if this is the first key in the buffer, else 1. valp points to first char after key. */ -int class_match_param (char *buf,char *key,char **valp) +static int class_match_param (char *buf,char *key,char **valp) {if (!buf)return 1 ;
@@ -85,7 +85,6 @@ int class_match_param(char *buf, char *key, char **valp)return 0 ; } -EXPORT_SYMBOL (class_match_param);static int parse_nid (char *buf,void *value,int quiet) {
@@ -175,7 +174,7 @@ EXPORT_SYMBOL(class_parse_nid_quiet);* Create a new obd device and set the type, name and uuid. If successful, * the new device can be accessed by either name or uuid. */ -int class_attach (struct lustre_cfg *lcfg) +static int class_attach (struct lustre_cfg *lcfg) {struct obd_device *obd =NULL ;char *typename, *name, *uuid;
@@ -278,12 +277,11 @@ int class_attach(struct lustre_cfg *lcfg) }return rc; } -EXPORT_SYMBOL (class_attach);/** Create hashes, self-export, and call type-specific setup. * Setup is effectively the "start this obd" call. */ -int class_setup (struct obd_device *obd,struct lustre_cfg *lcfg) +static int class_setup (struct obd_device *obd,struct lustre_cfg *lcfg) {int err =0 ;struct obd_export *exp;
@@ -373,12 +371,11 @@ err_hash:CERROR ("setup %s failed (%d)\n" , obd->obd_name, err);return err; } -EXPORT_SYMBOL (class_setup);/** We have finished using this obd and are ready to destroy it. * There can be no more references to this obd. */ -int class_detach (struct obd_device *obd,struct lustre_cfg *lcfg) +static int class_detach (struct obd_device *obd,struct lustre_cfg *lcfg) {if (obd->obd_set_up) {CERROR ("OBD device %d still set up\n" , obd->obd_minor);
@@ -400,13 +397,12 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)class_decref (obd,"attach" , obd);return 0 ; } -EXPORT_SYMBOL (class_detach);/** Start shutting down the obd. There may be in-progress ops when * this is called. We tell them to start shutting down with a call * to class_disconnect_exports(). */ -int class_cleanup (struct obd_device *obd,struct lustre_cfg *lcfg) +static int class_cleanup (struct obd_device *obd,struct lustre_cfg *lcfg) {int err =0 ;char *flag;
@@ -479,7 +475,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)return 0 ; } -EXPORT_SYMBOL (class_cleanup);struct obd_device *class_incref (struct obd_device *obd,const char *scope,const void *source)
@@ -543,7 +538,7 @@ EXPORT_SYMBOL(class_decref);/** Add a failover nid location. * Client obd types contact server obd types using this nid list. */ -int class_add_conn (struct obd_device *obd,struct lustre_cfg *lcfg) +static int class_add_conn (struct obd_device *obd,struct lustre_cfg *lcfg) {struct obd_import *imp;struct obd_uuid uuid;
@@ -574,11 +569,10 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg)return rc; } -EXPORT_SYMBOL (class_add_conn);/** Remove a failover nid location. */ -int class_del_conn (struct obd_device *obd,struct lustre_cfg *lcfg) +static int class_del_conn (struct obd_device *obd,struct lustre_cfg *lcfg) {struct obd_import *imp;struct obd_uuid uuid;
@@ -626,8 +620,8 @@ EXPORT_SYMBOL(class_get_profile);* This defines the mdc and osc names to use for a client. * This also is used to define the lov to be used by a mdt. */ -int class_add_profile (int proflen,char *prof,int osclen,char *osc, -int mdclen,char *mdc) +static int class_add_profile (int proflen,char *prof,int osclen,char *osc, +int mdclen,char *mdc) {struct lustre_profile *lprof;int err =0 ;
@@ -1303,7 +1297,8 @@ EXPORT_SYMBOL(class_config_parse_llog);* This is separated from class_config_dump_handler() to use * for ioctl needs as well */ -int class_config_parse_rec (struct llog_rec_hdr *rec,char *buf,int size) +static int class_config_parse_rec (struct llog_rec_hdr *rec,char *buf, +int size) {struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec +1 );char *ptr = buf;
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 3/5] Staging: lustre: obdclass: obd_config: Declare as static
Quoted 8 lines · On Friday 02 October 2015 23:19:12 Shraddha Barke wrote:
Declare
class_add_conn,class_add_profile,class_cleanup,class_config_parse_rec,class_del_conn,class_detach,class_match_param,class_attach,class_setupas static since they are used only in this particular file. Also remove the corresponding declarations from header files.Signed-off-by Shraddha Barke <[email protected]>
PATCH 4/5 Staging: lustre: obdclass: genops: Declare as static
In reply to Shraddha BarkeDeclare class_get_type and class_search_type as static since they are used only in this particular file. Also remove the declaration from header files.
--- drivers/staging/lustre/lustre/include/obd_class.h | 2 -- drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +0 -2
@@ -256,8 +256,6 @@ void class_import_put(struct obd_import *);struct obd_import *class_new_import (struct obd_device *obd);void class_destroy_import (struct obd_import *exp); -struct obd_type *class_search_type (const char *name); -struct obd_type *class_get_type (const char *name);void class_put_type (struct obd_type *type);int class_connect (struct lustre_handle *conn,struct obd_device *obd,struct obd_uuid *cluuid);
drivers/staging/lustre/lustre/obdclass/genops.c +2 -4
@@ -90,7 +90,7 @@ static void obd_device_free(struct obd_device *obd)OBD_SLAB_FREE_PTR (obd, obd_device_cachep); } -struct obd_type *class_search_type (const char *name) +static struct obd_type *class_search_type (const char *name) {struct list_head *tmp;struct obd_type *type;
@@ -106,9 +106,8 @@ struct obd_type *class_search_type(const char *name)spin_unlock (&obd_types_lock);return NULL ; } -EXPORT_SYMBOL (class_search_type); -struct obd_type *class_get_type (const char *name) +static struct obd_type *class_get_type (const char *name) {struct obd_type *type =class_search_type (name);
@@ -140,7 +139,6 @@ struct obd_type *class_get_type(const char *name) }return type; } -EXPORT_SYMBOL (class_get_type);void class_put_type (struct obd_type *type) {
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 4/5] Staging: lustre: obdclass: genops: Declare as static
drivers/staging/lustre/lustre/include/obd_class.h void class_import_put(struct obd_import *); · line 261
Quoted 11 lines · On Friday 02 October 2015 23:19:13 Shraddha Barke wrote:
drivers/staging/lustre/lustre/include/obd_class.h +0
-2@@ -256,8 +256,6 @@ void class_import_put(struct obd_import *);struct obd_import *class_new_import (struct obd_device *obd);void class_destroy_import (struct obd_import *exp); -struct obd_type *class_search_type (const char *name); -struct obd_type *class_get_type (const char *name);void class_put_type (struct obd_type *type);int class_connect (struct lustre_handle *conn,struct obd_device *obd,struct obd_uuid *cluuid);
I've dug a little deeper and found that class_put_type() falls into the same category once you realize that 'ldt_obd_type' is always NULL.
It would make sense to do another patch to remove that member (also look at surrounding members of the same struct to see if more may be unused) and the caller of class_put_type().
Arnd
PATCH 5/5 Staging: lustre: obdclass: class_obd: Declare as static
In reply to Shraddha BarkeDeclare class_resolve_dev_name as static it is not used anywhere apart from this particular file.Also remove the declaration from header file
--- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/class_obd.c +1 -1
@@ -133,7 +133,7 @@ static inline void obd_conn2data(struct obd_ioctl_data *data, data->ioc_cookie = conn->cookie; } -int class_resolve_dev_name (__u32 len,const char *name) +static int class_resolve_dev_name (__u32 len,const char *name) {int rc;int dev;
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 5/5] Staging: lustre: obdclass: class_obd: Declare as static
Quoted 6 lines · On Friday 02 October 2015 23:19:14 Shraddha Barke wrote:
Declare
class_resolve_dev_nameas static it is not used anywhere apart from this particular file.Also remove the declaration from header fileSigned-off-by Shraddha Barke <[email protected]>