drivers: staging: lustre: lustre: lov: lov_pool: Fixed a warning
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
@@ -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
Quoted 5 lines · Rakhi Sharma
Fixed a checkpatch warning.
WARNING: structfile_operationsshould normally be constSigned-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: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
Quoted 28 lines · Sudip Mukherjee
Quoted 5 lines · Rakhi Sharma
Fixed a checkpatch warning.
WARNING: structfile_operationsshould normally be constSigned-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:547:16:
note: expected ‘structfile_operations*’ but argument is of type ‘const structfile_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
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 ‘structfile_operations*’ but argument is of type ‘const structfile_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.
Quoted 31 lines · RAKHI SHARMA
Quoted 28 lines · Sudip Mukherjee
Quoted 5 lines · Rakhi Sharma
Fixed a checkpatch warning.
WARNING: structfile_operationsshould normally be constSigned-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:547:16:
note: expected ‘structfile_operations*’ but argument is of type ‘const structfile_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
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: structfile_operationsshould 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
Signed-off-by Rakhi Sharma <[email protected]>--- 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@@ -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.