Skip to contentSkip to conversation

Staging : lustre: Struct file_operations should be const

PATCH Superseded Shraddha Barke 3 participants 4 messages Aug 2, 2015 – Aug 3, 2015 Staging

lore
Share & tools
lore
#0 lore raw

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

This patch fixes the following checkpatch.pl warning:

WARNING: struct file_operations should normally be const

---
 drivers/staging/lustre/lustre/llite/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/file.c +1 -1
index dcd0c6d..369a722 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,
Signature · 1 line
2.1.0
#1 lore raw
Quoted 3 lines · Shraddha Barke

This patch fixes the following checkpatch.pl warning:

WARNING: struct file_operations should normally be const

This is not the good way to write the message. The information it conveys is "checkpatch generated this warning, so I have made some change (unspecified) that make checkpatch not complain".

A better approach would be to say:

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.

This way the reader knows what was done, and what issues were taken into account when making the change. At the same time, you still credit checkpatch for helping you find the problem

julia

Quoted 23 lines
---
 drivers/staging/lustre/lustre/llite/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/file.c +1 -1
index dcd0c6d..369a722 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,
Signature · 1 line
2.1.0
#2 lore raw

PATCH v2 1/1 Revert "Staging : lustre: Struct file_operations should be const"

In reply to 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.

---
Changes in v2:
- Make the commit message more clearer.

 drivers/staging/lustre/lustre/llite/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/file.c +1 -1
index 369a722..dcd0c6d 100644
@@ -3116,7 +3116,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 }
 
 /* -o localflock - only provides locally consistent flock locks */
-const struct file_operations ll_file_operations = {
+struct file_operations ll_file_operations = {
 	.read_iter = ll_file_read_iter,
 	.write_iter = ll_file_write_iter,
 	.unlocked_ioctl = ll_file_ioctl,
Signature · 1 line
2.1.0
#3 lore raw

Re: [PATCH v2] Revert "Staging : lustre: Struct file_operations should be const"

On Sun, Aug 02, 2015 at 11:04:22PM +0530, Shraddha Barke wrote:

Your subject says 'Revert "Staging : lustre: Struct file_operations should be const"'. This patch reverts which commit?

Quoted 18 lines

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.

---
Changes in v2:
- Make the commit message more clearer.

 drivers/staging/lustre/lustre/llite/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/file.c +0 -0
index 369a722..dcd0c6d 100644

drivers/staging/lustre/lustre/llite/file.c int ll_inode_permission(struct inode *inode, int mask) · line 3119

Quoted 5 lines
drivers/staging/lustre/lustre/llite/file.c +1 -1
@@ -3116,7 +3116,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 }
 
 /* -o localflock - only provides locally consistent flock locks */
-const struct file_operations ll_file_operations = {
+struct file_operations ll_file_operations = {

Your commit message says "Declare the file_operations structure ll_file_operations as const" but your patch is removing the const.

regards
sudip