Skip to contentSkip to conversation

filelock: ignore 'lock' argument to for_each_file_lock()

PATCH In review Arnd Bergmann 3 participants 3 messages Feb 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 filelock: ignore 'lock' argument to for_each_file_lock()

From: Arnd Bergmann <[email protected]>

When CONFIG_FILE_LOCKING is disabled, ceph causes a warning about a variable that is only used insode of the for_each_file_lock() loop:

fs/ceph/locks.c: In function 'ceph_count_locks':
fs/ceph/locks.c:380:27: error: unused variable 'lock' [-Werror=unused-variable]
380 | struct file_lock *lock;

Rather than working around this in ceph, change the macro definition to still contain a reference to the variable in order to shut up the warning.

Fixes 75cabec0111b ("filelock: add some new helper functions")
---
 include/linux/filelock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/filelock.h +1 -1
index aabd4bdf7eba..69290173280a 100644
@@ -283,7 +283,7 @@ static inline void locks_wake_up(struct file_lock *fl)
 {
 }
 
-#define for_each_file_lock(_fl, _head)	while(false)
+#define for_each_file_lock(_fl, _head)	while((void)_fl, false)
 
 static inline void
 locks_free_lock_context(struct inode *inode)
Signature · 1 line
2.39.2
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_FILE_LOCKING is disabled, ceph causes a warning about a variable that is only used insode of the for_each_file_lock() loop:

fs/ceph/locks.c: In function 'ceph_count_locks':
fs/ceph/locks.c:380:27: error: unused variable 'lock' [-Werror=unused-variable]
380 | struct file_lock *lock;

Quoted 7 lines

Rather than working around this in ceph, change the macro definition to still contain a reference to the variable in order to shut up the warning.

Fixes 75cabec0111b ("filelock: add some new helper functions")

---

Yup, seems good to me.

#2 lore raw
In reply to Arnd Bergmann
Quoted 25 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_FILE_LOCKING is disabled, ceph causes a warning about a variable that is only used insode of the for_each_file_lock() loop:

fs/ceph/locks.c: In function 'ceph_count_locks':
fs/ceph/locks.c:380:27: error: unused variable 'lock' [-Werror=unused-variable]
380 | struct file_lock *lock;

Rather than working around this in ceph, change the macro definition to still contain a reference to the variable in order to shut up the warning.

Fixes 75cabec0111b ("filelock: add some new helper functions")
---
 include/linux/filelock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/filelock.h +0 -0
index aabd4bdf7eba..69290173280a 100644

include/linux/filelock.h static inline void locks_wake_up(struct file_lock *fl) · line 289

Quoted 8 lines
include/linux/filelock.h +1 -1
@@ -283,7 +283,7 @@ static inline void locks_wake_up(struct file_lock *fl)
 {
 }
 
-#define for_each_file_lock(_fl, _head)	while(false)
+#define for_each_file_lock(_fl, _head)	while((void)_fl, false)
 
 static inline void
 locks_free_lock_context(struct inode *inode)

I had sent a patch early last week for this, but then dropped the ball on following up. The simpler fix is to just unconditionally define for_each_file_lock(). It's a macro, so we can just move the "real" definition outside of the #ifdef.

I'll spin up a patch later today and resend it.

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>