Skip to contentSkip to conversation

drivers: staging: lustre: lustre: lov: lov_pool: Fixed a warning

PATCH In review Rakhi Sharma 3 participants 6 messages Feb 9, 2016 – Feb 10, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: staging: lustre: lustre: lov: lov_pool: Fixed a warning

Fixed a checkpatch warning.
WARNING: struct file_operations should normally be const

---
 drivers/staging/lustre/lustre/lov/lov_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/lov/lov_pool.c +1 -1
index b43ce6c..bba37bf 100644
@@ -288,7 +288,7 @@ static int pool_proc_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static struct file_operations pool_proc_operations = {
+static const struct file_operations pool_proc_operations = {
 	.open	   = pool_proc_open,
 	.read	   = seq_read,
 	.llseek	 = seq_lseek,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Rakhi Sharma

Fixed a checkpatch warning.
WARNING: struct file_operations should normally be const

---

It now adds new build warning:

../drivers/staging/lustre/lustre/lov/lov_pool.c: In function ‘lov_pool_new’:
../drivers/staging/lustre/lustre/lov/lov_pool.c:438:7: warning: passing argument 4 of ‘ldebugfs_add_simple’ discards ‘const’ qualifier from pointer target type [enabled by default]

       &pool_proc_operations);
       ^
In file included from ../drivers/staging/lustre/lustre/lov/../include/linux/../obd_support.h:43:0,
                 from ../drivers/staging/lustre/lustre/lov/../include/linux/obd.h:44,
                 from ../drivers/staging/lustre/lustre/lov/../include/obd.h:40,
                 from ../drivers/staging/lustre/lustre/lov/lov_pool.c:49:

../drivers/staging/lustre/lustre/lov/../include/linux/../lprocfs_status.h:547:16: note: expected ‘struct file_operations *’ but argument is of type ‘const struct file_operations *’
struct dentry *ldebugfs_add_simple(struct dentry *root,

regards
sudip

#2 lore raw
Quoted 28 lines · Sudip Mukherjee
Quoted 5 lines · Rakhi Sharma

Fixed a checkpatch warning.
WARNING: struct file_operations should normally be const

---

It now adds new build warning:

../drivers/staging/lustre/lustre/lov/lov_pool.c: In function ‘lov_pool_new’:
../drivers/staging/lustre/lustre/lov/lov_pool.c:438:7: warning: passing argument 4 of ‘ldebugfs_add_simple’ discards ‘const’ qualifier from pointer target type [enabled by default]

       &pool_proc_operations);
       ^

In file included from ../drivers/staging/lustre/lustre/lov/../include/linux/../obd_support.h:43:0,
from
../drivers/staging/lustre/lustre/lov/../include/linux/obd.h:44,
from
../drivers/staging/lustre/lustre/lov/../include/obd.h:40,
from ../drivers/staging/lustre/lustre/lov/lov_pool.c:49:
../drivers/staging/lustre/lustre/lov/../include/linux/../lprocfs_status.h:547:16:
note: expected ‘struct file_operations *’ but argument is of type ‘const struct file_operations *’
struct dentry *ldebugfs_add_simple(struct dentry *root,

Quoted 2 lines

regards

hi Sudip,
Will you please help me to understand why this warning produce? Is the const I have put there is wrong? but as I think it is ok there.may be I am wrong this side, please let me know how this is going on? thanks
Rakhi

Quoted 3 lines

sudip

#3 lore raw
Quoted 33 lines · RAKHI SHARMA

On Wed, Feb 10, 2016 at 11:44 AM, Sudip Mukherjee
<[email protected]> wrote:

      On Wed, Feb 10, 2016 at 05:28:46AM +0530, Rakhi Sharma wrote:
      > Fixed a checkpatch warning.
      > WARNING: struct file_operations should normally be const
      >
      > Signed-off-by: Rakhi Sharma <[email protected]>
      > ---

      It now adds new build warning:

      ../drivers/staging/lustre/lustre/lov/lov_pool.c: In function
      ‘lov_pool_new’:
      ../drivers/staging/lustre/lustre/lov/lov_pool.c:438:7: warning:
      passing argument 4 of ‘ldebugfs_add_simple’ discards ‘const’
      qualifier from pointer target type [enabled by default]
             &pool_proc_operations);
             ^
      In file included from../drivers/staging/lustre/lustre/lov/../include/linux/../obd_support.h:43:0
      ,
                       from
      ../drivers/staging/lustre/lustre/lov/../include/linux/obd.h:44,
                       from
      ../drivers/staging/lustre/lustre/lov/../include/obd.h:40,
                       from
      ../drivers/staging/lustre/lustre/lov/lov_pool.c:49:

../drivers/staging/lustre/lustre/lov/../include/linux/../lprocfs_status.h:5
47:16: note: expected ‘struct file_operations *’ but argument is of type ‘const struct file_operations *’
 struct dentry *ldebugfs_add_simple(struct dentry *root,

Quoted 6 lines

regards

hi Sudip,
Will you please help me to understand why this warning produce? Is the const I have put there is wrong? but as I think it is ok there.may be I am wrong this side, please let me know how this is going on?

In general, a structure is something that gets passed around in the code. If you put the annotation const on it, then all of the variables that point to it, eg functon parameters, local variables etc, also have to be annotated with const. Otherwise, the compiler is not certain that there can be no modification to the structure.

If you get a warning like this one, then you should look at the code that it mentions and see if it can be annotated with const too. And so on. Normally a file operations structure should not be modified, so it should work out in the end. But everythng has to be consistent.

julia

Quoted 16 lines

thanks
Rakhi
sudip

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAMnyiXsk1P19XHUCx11%3Ds %2BRtwXSDL-fMxAJdkSaaqdrD6hFSyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
In reply to RAKHI SHARMA
Quoted 31 lines · RAKHI SHARMA
Quoted 28 lines · Sudip Mukherjee
Quoted 5 lines · Rakhi Sharma

Fixed a checkpatch warning.
WARNING: struct file_operations should normally be const

---

It now adds new build warning:

../drivers/staging/lustre/lustre/lov/lov_pool.c: In function ‘lov_pool_new’:
../drivers/staging/lustre/lustre/lov/lov_pool.c:438:7: warning: passing argument 4 of ‘ldebugfs_add_simple’ discards ‘const’ qualifier from pointer target type [enabled by default]

       &pool_proc_operations);
       ^

In file included from ../drivers/staging/lustre/lustre/lov/../include/linux/../obd_support.h:43:0,
from
../drivers/staging/lustre/lustre/lov/../include/linux/obd.h:44,
from
../drivers/staging/lustre/lustre/lov/../include/obd.h:40,
from ../drivers/staging/lustre/lustre/lov/lov_pool.c:49:
../drivers/staging/lustre/lustre/lov/../include/linux/../lprocfs_status.h:547:16:
note: expected ‘struct file_operations *’ but argument is of type ‘const struct file_operations *’
struct dentry *ldebugfs_add_simple(struct dentry *root,

Quoted 6 lines
Quoted 2 lines

regards

hi Sudip,
Will you please help me to understand why this warning produce? Is the const I have put there is wrong? but as I think it is ok there.may be I am wrong this side, please let me know how this is going on?

you should have also made it as const in the argument of ldebugfs_add_simple() in drivers/staging/lustre/lustre/include/lprocfs_status.h.

regards
sudip

#5 lore raw
In reply to Rakhi Sharma

Again, the description of the file in the subject line should be shortened and the comment needs to be more clear about what is done.

Quoted 2 lines · Rakhi Sharma

Fixed a checkpatch warning.
WARNING: struct file_operations should normally be const

The commit message should also say more clearly what you did. What change did you make to cause the warning to go away. In this case, it would also make sense to say where the structure is used, and to argue why a const value is acceptable at those places.

julia

Quoted 28 lines
---
 drivers/staging/lustre/lustre/lov/lov_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/lov/lov_pool.c +1 -1
index b43ce6c..bba37bf 100644
@@ -288,7 +288,7 @@ static int pool_proc_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static struct file_operations pool_proc_operations = {
+static const struct file_operations pool_proc_operations = {
 	.open	   = pool_proc_open,
 	.read	   = seq_read,
 	.llseek	 = seq_lseek,
Signature · 8 lines
1.9.1

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1455062326-20870-1-git-send-email-rakhish1994%40gmail.com.
For more options, visit https://groups.google.com/d/optout.