Skip to contentSkip to conversation

Declare functions and structures as static

PATCH Superseded Shraddha Barke 3 participants 13 messages Oct 1, 2015 – Oct 2, 2015 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index d36752e..dc7d4d0 100644
@@ -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
index e7f2f33..6721541 100644
@@ -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
#2 lore raw

PATCH 2/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_free as static

In reply to Shraddha Barke

Declare 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
index dc7d4d0..00a67cf 100644
@@ -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
index 6721541..394429f 100644
@@ -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
#3 lore raw

PATCH 3/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_expand as static

In reply to Shraddha Barke

Declare 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
index 00a67cf..47c4c64 100644
@@ -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
index 394429f..fac9532 100644
@@ -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
#4 lore raw

PATCH 4/6 Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static

In reply to Shraddha Barke

Declare 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
index 47c4c64..ed0eb4d 100644
@@ -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
index fac9532..6de9aa6 100644
@@ -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
#10 lore raw

PATCH 5/6 Staging: lustre: ptlrpc: Declare sptlrpc_req_replace_dead_ctx as static

In reply to Shraddha Barke

Declare 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
index ed0eb4d..5433fce 100644
@@ -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
index 70aa271..e967389 100644
@@ -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
#11 lore raw

PATCH 6/6 Staging: lustre: ptlrpc: Declare sptlrpc_parse_rule as static

In reply to Shraddha Barke

Declare 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
index 5433fce..0dd5687 100644
@@ -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
index 6de9aa6..0b96f62 100644
@@ -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
Reviewed-by on the v1 series
#12 lore raw
In reply to Shraddha Barke
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: 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

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

#5 lore raw

Re: [Outreachy kernel] [PATCH 4/6] Staging: lustre: ptlrpc: Declare sptlrpc_rule_set_choose as static

In reply to Shraddha Barke
Quoted 6 lines · Shraddha Barke

Declare sptlrpc_rule_set_choose as static since it is accessed from this particular file only. Also remove it's declaration from header file

---

This patch will not apply because of some other changes done by:
d97cc6442a44 ("staging/lustre/ptlrpc: secure wrapping code cleanup")

regards
sudip

#6 lore raw

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_choose as static since it is accessed from this particular file only. Also remove it's declaration from header file

---

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

#7 lore raw

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_choose as 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

---

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

#8 lore raw

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_choose as static since it is accessed from this particular file only. Also remove it's declaration from header file

---

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

#9 lore raw

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_choose as static since it is accessed from this particular file only. Also remove it's declaration from header file

---

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