Declare functions and structures as static
cover Declare functions and structures as static
These patches declare the functions and structures which are not used anywhere else as static.
Shraddha Barke (6):
Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_merge as static
Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_free as static
Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_expand as static
Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Staging: lustre: ptlrpc: Declare sptlrpc_req_replace_dead_ctx as
static
Staging: lustre: ptlrpc: Declare sptlrpc_parse_rule as static
drivers/staging/lustre/lustre/include/lustre_sec.h | 11 ---------- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 25 +++++++++------------- 3 files changed, 11 insertions(+), 28 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_merge as static
Declare sptlrpc_rule_set_merge as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 2 -- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -2
@@ -332,8 +332,6 @@ static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)void sptlrpc_rule_set_free (struct sptlrpc_rule_set *set);int sptlrpc_rule_set_expand (struct sptlrpc_rule_set *set); -int sptlrpc_rule_set_merge (struct sptlrpc_rule_set *set, -struct sptlrpc_rule *rule); int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, enum lustre_sec_part from, enum lustre_sec_part to,
drivers/staging/lustre/lustre/ptlrpc/sec_config.c +2 -3
@@ -306,8 +306,8 @@ static inline int rule_match_net(struct sptlrpc_rule *r1,* merge @rule into @rset. * the @rset slots might be expanded. */ -int sptlrpc_rule_set_merge (struct sptlrpc_rule_set *rset, -struct sptlrpc_rule *rule) +static int sptlrpc_rule_set_merge (struct sptlrpc_rule_set *rset, +struct sptlrpc_rule *rule) {struct sptlrpc_rule *p = rset->srs_rules;int spec_dir, spec_net;
@@ -391,7 +391,6 @@ int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,return 0 ; } -EXPORT_SYMBOL (sptlrpc_rule_set_merge);/** * given from/to/nid, determine a matching flavor in ruleset.
Signature · 1 line
2.1.4
PATCH 2/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_free as static
In reply to Shraddha BarkeDeclare sptlrpc_rule_set_free as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 1 - drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -1
@@ -330,7 +330,6 @@ static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)memset (set,0 ,sizeof (*set)); } -void sptlrpc_rule_set_free (struct sptlrpc_rule_set *set);int sptlrpc_rule_set_expand (struct sptlrpc_rule_set *set); int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, enum lustre_sec_part from,
drivers/staging/lustre/lustre/ptlrpc/sec_config.c +1 -2
@@ -236,7 +236,7 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) }EXPORT_SYMBOL (sptlrpc_parse_rule); -void sptlrpc_rule_set_free (struct sptlrpc_rule_set *rset) +static void sptlrpc_rule_set_free (struct sptlrpc_rule_set *rset) {LASSERT (rset->srs_nslot || (rset->srs_nrule ==0 && rset->srs_rules ==NULL ));
@@ -246,7 +246,6 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)sptlrpc_rule_set_init (rset); } } -EXPORT_SYMBOL (sptlrpc_rule_set_free);/* * return 0 if the rule set could accommodate one more rule.
Signature · 1 line
2.1.4
PATCH 3/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_expand as static
In reply to Shraddha BarkeDeclare sptlrpc_rule_set_expand as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 1 - drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -1
@@ -330,7 +330,6 @@ static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)memset (set,0 ,sizeof (*set)); } -int sptlrpc_rule_set_expand (struct sptlrpc_rule_set *set); int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, enum lustre_sec_part from, enum lustre_sec_part to,
drivers/staging/lustre/lustre/ptlrpc/sec_config.c +1 -2
@@ -250,7 +250,7 @@ static void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)/* * return 0 if the rule set could accommodate one more rule. */ -int sptlrpc_rule_set_expand (struct sptlrpc_rule_set *rset) +static int sptlrpc_rule_set_expand (struct sptlrpc_rule_set *rset) {struct sptlrpc_rule *rules;int nslot;
@@ -279,7 +279,6 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) rset->srs_nslot = nslot;return 0 ; } -EXPORT_SYMBOL (sptlrpc_rule_set_expand);static inline int rule_spec_dir (struct sptlrpc_rule *rule) {
Signature · 1 line
2.1.4
PATCH 4/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
In reply to Shraddha BarkeDeclare sptlrpc_rule_set_choose as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 5 ----- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 11 +++++------ 2 files changed, 5 insertions(+), 11 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -5
@@ -330,11 +330,6 @@ static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)memset (set,0 ,sizeof (*set)); } -int sptlrpc_rule_set_choose (struct sptlrpc_rule_set *rset, -enum lustre_sec_part from, -enum lustre_sec_part to, -lnet_nid_t nid, -struct sptlrpc_flavor *sf);void sptlrpc_rule_set_dump (struct sptlrpc_rule_set *set);int sptlrpc_process_config (struct lustre_cfg *lcfg);
drivers/staging/lustre/lustre/ptlrpc/sec_config.c +5 -6
@@ -394,11 +394,11 @@ static int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,* given from/to/nid, determine a matching flavor in ruleset. * return 1 if a match found, otherwise return 0. */ -int sptlrpc_rule_set_choose (struct sptlrpc_rule_set *rset, -enum lustre_sec_part from, -enum lustre_sec_part to, -lnet_nid_t nid, -struct sptlrpc_flavor *sf) +static int sptlrpc_rule_set_choose (struct sptlrpc_rule_set *rset, +enum lustre_sec_part from, +enum lustre_sec_part to, +lnet_nid_t nid, +struct sptlrpc_flavor *sf) {struct sptlrpc_rule *r;int n;
@@ -425,7 +425,6 @@ int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,return 0 ; } -EXPORT_SYMBOL (sptlrpc_rule_set_choose);void sptlrpc_rule_set_dump (struct sptlrpc_rule_set *rset) {
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Quoted 6 lines · Shraddha Barke
Declare
sptlrpc_rule_set_chooseas static since it is accessed from this particular file only. Also remove it's declaration from header fileSigned-off-by Shraddha Barke <[email protected]>---
This patch will not apply because of some other changes done by:d97cc6442a44 ("staging/lustre/ptlrpc: secure wrapping code cleanup")
regards
sudip
Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Quoted 9 lines · Sudip Mukherjee
Quoted 6 lines · Shraddha Barke
Declare
sptlrpc_rule_set_chooseas static since it is accessed from this particular file only. Also remove it's declaration from header fileSigned-off-by Shraddha Barke <[email protected]>---
This patch will not apply because of some other changes done by:
d97cc6442a44("staging/lustre/ptlrpc: secure wrapping code cleanup")
I'm confused as to how it applied to my staging-testing :( Should I send a v2 dropping this one?
Thanks,
Shraddha
Quoted 4 lines
regards
sudip
Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Quoted 9 lines · Shraddha Barke
Quoted 5 lines · Sudip Mukherjee
Quoted 4 lines · Shraddha Barke
Declare
sptlrpc_rule_set_chooseas static since it is accessed from this particular file only. Also remove it's declaration from header file
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Shraddha Barke <[email protected]>---
This patch will not apply because of some other changes done by:
d97cc6442a44("staging/lustre/ptlrpc: secure wrapping code cleanup")I'm confused as to how it applied to my staging-testing :( Should I send a v2 dropping this one?
Try to see if you have this commit in the tree. Try to rebase. It is not applying because sptlrpc_rule_set_dump() is not there in the file anymore.
regards
sudip
Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Quoted 15 lines · Sudip Mukherjee
Quoted 14 lines · Shraddha Barke
Quoted 9 lines · Sudip Mukherjee
Quoted 6 lines · Shraddha Barke
Declare
sptlrpc_rule_set_chooseas static since it is accessed from this particular file only. Also remove it's declaration from header fileSigned-off-by Shraddha Barke <[email protected]>---
This patch will not apply because of some other changes done by:
d97cc6442a44("staging/lustre/ptlrpc: secure wrapping code cleanup")
Quoted 6 lines
Quoted 2 lines
I'm confused as to how it applied to my staging-testing :( Should I send a v2 dropping this one?
Try to see if you have this commit in the tree. Try to rebase. It is not applying because
sptlrpc_rule_set_dump()is not there in the file anymore.
Okay, should I send a version 2 for this series?
Quoted 4 lines
regards
sudip
Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static
Quoted 19 lines · Shraddha Barke
Quoted 15 lines · Sudip Mukherjee
Quoted 14 lines · Shraddha Barke
Quoted 9 lines · Sudip Mukherjee
Quoted 6 lines · Shraddha Barke
Declare
sptlrpc_rule_set_chooseas static since it is accessed from this particular file only. Also remove it's declaration from header fileSigned-off-by Shraddha Barke <[email protected]>---
This patch will not apply because of some other changes done by:
d97cc6442a44("staging/lustre/ptlrpc: secure wrapping code cleanup")
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I'm confused as to how it applied to my staging-testing :( Should I send a v2 dropping this one?
Try to see if you have this commit in the tree. Try to rebase. It is not applying because
sptlrpc_rule_set_dump()is not there in the file anymore.Okay, should I send a version 2 for this series?
Yes, please.
regards
sudip
PATCH 5/6 Staging: lustre: ptlrpc: Declare sptlrpc_req_replace_dead_ctx as static
In reply to Shraddha BarkeDeclare sptlrpc_req_replace_dead_ctx as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 1 - drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -1
@@ -1035,7 +1035,6 @@ void sptlrpc_import_flush_all_ctx(struct obd_import *imp);int sptlrpc_req_get_ctx (struct ptlrpc_request *req);void sptlrpc_req_put_ctx (struct ptlrpc_request *req,int sync);int sptlrpc_req_refresh_ctx (struct ptlrpc_request *req,long timeout); -int sptlrpc_req_replace_dead_ctx (struct ptlrpc_request *req);void sptlrpc_req_set_flavor (struct ptlrpc_request *req,int opcode);int sptlrpc_parse_rule (char *param,struct sptlrpc_rule *rule);
drivers/staging/lustre/lustre/ptlrpc/sec.c +1 -2
@@ -509,7 +509,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,* \note a request must have a context, to keep other parts of code happy. * In any case of failure during the switching, we must restore the old one. */ -int sptlrpc_req_replace_dead_ctx (struct ptlrpc_request *req) +static int sptlrpc_req_replace_dead_ctx (struct ptlrpc_request *req) {struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx;struct ptlrpc_cli_ctx *newctx;
@@ -562,7 +562,6 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)sptlrpc_cli_ctx_put (oldctx,1 );return 0 ; } -EXPORT_SYMBOL (sptlrpc_req_replace_dead_ctx);static int ctx_check_refresh (struct ptlrpc_cli_ctx *ctx)
Signature · 1 line
2.1.4
PATCH 6/6 Staging: lustre: ptlrpc: Declare sptlrpc_parse_rule as static
In reply to Shraddha BarkeDeclare sptlrpc_parse_rule as static since it is accessed from this particular file only. Also remove it's declaration from header file
--- drivers/staging/lustre/lustre/include/lustre_sec.h | 1 - drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/include/lustre_sec.h +0 -1
@@ -1037,7 +1037,6 @@ void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync);int sptlrpc_req_refresh_ctx (struct ptlrpc_request *req,long timeout);void sptlrpc_req_set_flavor (struct ptlrpc_request *req,int opcode); -int sptlrpc_parse_rule (char *param,struct sptlrpc_rule *rule);/* gc */ void sptlrpc_gc_add_sec (struct ptlrpc_sec *sec);
drivers/staging/lustre/lustre/ptlrpc/sec_config.c +1 -2
@@ -180,7 +180,7 @@ static void sptlrpc_rule_init(struct sptlrpc_rule *rule)/* * format: network[.direction]=flavor */ -int sptlrpc_parse_rule (char *param,struct sptlrpc_rule *rule) +static int sptlrpc_parse_rule (char *param,struct sptlrpc_rule *rule) {char *flavor, *dir;int rc;
@@ -234,7 +234,6 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule)return 0 ; } -EXPORT_SYMBOL (sptlrpc_parse_rule);static void sptlrpc_rule_set_free (struct sptlrpc_rule_set *rset) {
Signature · 1 line
2.1.4
Quoted 4 lines · On Thursday 01 October 2015 22:59:35 Shraddha Barke wrote:
These patches declare the functions and structures which are not used anywhere else as static.
Quoted 10 lines
Shraddha Barke (6):
Staging: lustre: ptlrpc: Declaresptlrpc_rule_set_mergeas static
Staging: lustre: ptlrpc: Declaresptlrpc_rule_set_freeas static
Staging: lustre: ptlrpc: Declaresptlrpc_rule_set_expandas static
Staging: lustre: ptlrpc: Declaresptlrpc_rule_set_chooseas static
Staging: lustre: ptlrpc: Declaresptlrpc_req_replace_dead_ctxas
static
Staging: lustre: ptlrpc: Declaresptlrpc_parse_ruleas static
Individually, each of these looks good and can be applied
Now that you get the principle right, I think it would be better to continue with similar patches that do multiple functions at once and look at the bigger picture. In case of this series, it would be worth noting that there are two more sptlrpc_rule_set_* functions, and neither of them should be global. The sptlrpc_rule_set_init() one is slightly different because it's static inline but can simply be moved into the file that holds the other functions.
Try to find patterns like this and then handle all symbols that fall into a similar category as a combined patch.
Arnd