Skip to contentSkip to conversation

Staging : lustre: Struct file_operations should be const

PATCH In review Shraddha Barke 2 participants 2 messages Aug 3, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging : lustre: Struct file_operations should be const

Declare the file_operations structure ll_file_operations as const, as done elsewhere in the kernel, as there are no modifications to its fields.

Problem found using checkpatch:

WARNING: struct file_operations should normally be const

---
 drivers/staging/lustre/lustre/llite/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +3 -3
index dcd0c6d..2c467bf 100644
@@ -3116,7 +3116,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 }
 
 /* -o localflock - only provides locally consistent flock locks */
-struct file_operations ll_file_operations = {
+const struct file_operations ll_file_operations = {
 	.read_iter = ll_file_read_iter,
 	.write_iter = ll_file_write_iter,
 	.unlocked_ioctl = ll_file_ioctl,
@@ -3129,7 +3129,7 @@ struct file_operations ll_file_operations = {
 	.flush	  = ll_flush
 };
 
-struct file_operations ll_file_operations_flock = {
+const struct file_operations ll_file_operations_flock = {
 	.read_iter    = ll_file_read_iter,
 	.write_iter   = ll_file_write_iter,
 	.unlocked_ioctl = ll_file_ioctl,
@@ -3145,7 +3145,7 @@ struct file_operations ll_file_operations_flock = {
 };
 
 /* These are for -o noflock - to return ENOSYS on flock calls */
-struct file_operations ll_file_operations_noflock = {
+const struct file_operations ll_file_operations_noflock = {
 	.read_iter    = ll_file_read_iter,
 	.write_iter   = ll_file_write_iter,
 	.unlocked_ioctl = ll_file_ioctl,
Signature · 1 line
2.1.0
#1 lore raw
Quoted 9 lines · Shraddha Barke

Declare the file_operations structure ll_file_operations as const, as done elsewhere in the kernel, as there are no modifications to its fields.

Problem found using checkpatch:

WARNING: struct file_operations should normally be const

---

You have not even build tested your patch before sending. :(

drivers/staging/lustre/lustre/llite/file.c:3119:30: error: conflicting type qualifiers for ‘ll_file_operations’

 const struct file_operations ll_file_operations = {
                              ^
In file included from drivers/staging/lustre/lustre/llite/file.c:48:0:
drivers/staging/lustre/lustre/llite/llite_internal.h:710:31: note: previous declaration of ‘ll_file_operations’ was here
 extern struct file_operations ll_file_operations;
                               ^
drivers/staging/lustre/lustre/llite/file.c:3132:30: error: conflicting type qualifiers for ‘ll_file_operations_flock’
 const struct file_operations ll_file_operations_flock = {
                              ^
In file included from drivers/staging/lustre/lustre/llite/file.c:48:0:
drivers/staging/lustre/lustre/llite/llite_internal.h:711:31: note: previous declaration of ‘ll_file_operations_flock’ was here
 extern struct file_operations ll_file_operations_flock;
                               ^
drivers/staging/lustre/lustre/llite/file.c:3148:30: error: conflicting type qualifiers for ‘ll_file_operations_noflock’
 const struct file_operations ll_file_operations_noflock = {
                              ^
In file included from drivers/staging/lustre/lustre/llite/file.c:48:0:
drivers/staging/lustre/lustre/llite/llite_internal.h:712:31: note: previous declaration of ‘ll_file_operations_noflock’ was here
 extern struct file_operations ll_file_operations_noflock;
                               ^

make[3]: *** [drivers/staging/lustre/lustre/llite/file.o] Error 1 make[2]: *** [drivers/staging/lustre/lustre/llite] Error 2 make[1]: *** [drivers/staging/lustre/lustre] Error 2
make: *** [_module_drivers/staging/lustre] Error 2

regards
sudip