Skip to contentSkip to conversation

staging: lustre: libcfs: fix sparse warnings about static declaration

PATCH In review Jia He 3 participants 9 messages Dec 16, 2014 – Jan 16, 2015 Staging

lore
Share & tools
lore

Jia He

author
#0 lore raw

PATCH 1/1 staging: lustre: libcfs: fix sparse warnings about static declaration

make sparse happy since these two fuchtion are only used in module.c. tested by successful compilation.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -4
index 2c4fc74..b9ee37c 100644
@@ -42,8 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
@@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 	LASSERT (ldu->ldu_memhog_pages == 0);
 }
 
-int
-kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
 		     gfp_t flags)
 {
 	struct page **level0p;
Signature · 1 line
1.9.1
#1 lore raw

Ping.
Thanks for any comments

Quoted 35 lines · On Tue, 16 Dec 2014 22:39:38 +0800 from [email protected] wrote:

make sparse happy since these two fuchtion are only used in module.c. tested by successful compilation.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -4
index 2c4fc74..b9ee37c 100644
@@ -42,8 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
@@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 	LASSERT (ldu->ldu_memhog_pages == 0);
 }
 
-int
-kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
 		     gfp_t flags)
 {
 	struct page **level0p;
#2 lore raw
In reply to Jia He

Hi all
Ping again, any comments are welcome

Justin

Quoted 35 lines · On Tue, 16 Dec 2014 22:39:38 +0800 from [email protected] wrote:

make sparse happy since these two fuchtion are only used in module.c. tested by successful compilation.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -4
index 2c4fc74..b9ee37c 100644
@@ -42,8 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
@@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 	LASSERT (ldu->ldu_memhog_pages == 0);
 }
 
-int
-kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
 		     gfp_t flags)
 {
 	struct page **level0p;
#3 lore raw
In reply to Jia He

Jia He,

Quoted 3 lines · Jia He

make sparse happy since these two fuchtion are only used in module.c. tested by successful compilation.

spelling: s/fuchtion/function/

Not sure if "make sparse happy" is the best way to describe what you are doing. You are fixing sparse warnings.

[...]

drivers/staging/lustre/lustre/libcfs/module.c line 45

Quoted 3 lines
drivers/staging/lustre/lustre/libcfs/module.c +1 -2
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free (struct libcfs_device_userstate *ldu)

You might as well fix the checkpatch warning created by this line too.

[...]

These functions aren't used outside of this file so making them static looks correct.

Signature · 1 line
- Jeremiah Mahler
author
#4 lore raw

PATCH 1/2 staging: lustre: libcfs: fix sparse warnings about static declaration

These functions aren't used outside of this file so making them static to suppress the sparse warnings about static declaration.

Cc Jeremiah Mahler <[email protected]>
Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -4
index 2c4fc74..b9ee37c 100644
@@ -42,8 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
@@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 	LASSERT (ldu->ldu_memhog_pages == 0);
 }
 
-int
-kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
 		     gfp_t flags)
 {
 	struct page **level0p;
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH 2/2 staging: lustre: libcfs: fix space between function and open parenthesis

This fixes the space warning checked by check_patch.pl

Cc Jeremiah Mahler <[email protected]>
Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
index b9ee37c..1af6a37 100644
@@ -42,7 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH 2/2] staging: lustre: libcfs: fix space between function and open parenthesis

Jia He,

Quoted 1 line · Jia He

This fixes the space warning checked by check_patch.pl

                                              ^^^
                                          checkpatch.pl
Quoted 1 line

[...]

drivers/staging/lustre/lustre/libcfs/module.c line 46

Quoted 3 lines
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
-static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {

[...]

I would have included this change in with the previous patch since it is that patch that has the checkpatch warning.

Signature · 1 line
- Jeremiah Mahler
author
#7 lore raw

PATCH 1/1 staging: lustre: libcfs: fix sparse warnings about static declaration

In reply to Jeremiah Mahler

These functions kportal_memhog_{alloc,free} aren't used outside of
this file, so making them static to suppress the sparse warnings about static declaration.
Besides, this also fixes the space warning checked by checkpatch.pl

Cc Jeremiah Mahler <[email protected]>
Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -4
index 2c4fc74..1af6a37 100644
@@ -42,8 +42,7 @@
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
-void
-kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {
 	struct page **level0p = &ldu->ldu_memhog_root_page;
 	struct page **level1p;
@@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 	LASSERT (ldu->ldu_memhog_pages == 0);
 }
 
-int
-kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
 		     gfp_t flags)
 {
 	struct page **level0p;
Signature · 1 line
1.9.1
#8 lore raw

Jia He,

Your patch is looking better :-)
A few nits though.

Quoted 1 line · Jia He

These functions kportal_memhog_{alloc,free} aren't used outside of

^^^^^ Don't indent paragraphs, just use a line between paragraphs.

Quoted 4 lines

this file, so making them static to suppress the sparse warnings about static declaration.

Besides, this also fixes the space warning checked by checkpatch.pl

"Besides" doesn't sound right here. I would just say something like "Also fix the space warning ..."

In your subject line it is helpful to add a version number so people can tell that this is a new revision. For example: [PATCH v2]. git format-patch can add this automatically with the '-v' option.

[...]

Signature · 1 line
- Jeremiah Mahler