Skip to contentSkip to conversation

locks: remove trailing semicolon in macro definition

PATCH In review [email protected] 5 participants 6 messages Nov 27, 2020 – Nov 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locks: remove trailing semicolon in macro definition

From: Tom Rix <[email protected]>

The macro use will already have a semicolon.

---
 fs/fcntl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fcntl.c +1 -1
index 05b36b28f2e8..96a65758c498 100644
@@ -526,7 +526,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 	(dst)->l_whence = (src)->l_whence;	\
 	(dst)->l_start = (src)->l_start;	\
 	(dst)->l_len = (src)->l_len;		\
-	(dst)->l_pid = (src)->l_pid;
+	(dst)->l_pid = (src)->l_pid
 
 static int get_compat_flock(struct flock *kfl, const struct compat_flock __user *ufl)
 {
Signature · 1 line
2.18.4
#1 lore raw

fs/fcntl.c SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · line 529

Quoted 7 lines · On Fri, Nov 27, 2020 at 11:07:07AM -0800, [email protected] wrote:

+++ b/fs/fcntl.c

fs/fcntl.c +1 -1
@@ -526,7 +526,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 	(dst)->l_whence = (src)->l_whence;	\
 	(dst)->l_start = (src)->l_start;	\
 	(dst)->l_len = (src)->l_len;		\
-	(dst)->l_pid = (src)->l_pid;
+	(dst)->l_pid = (src)->l_pid

This should be wrapped in a do { } while (0).

Look, this warning is clearly great at finding smelly code, but the fixes being generated to shut up the warning are low quality.

author
#2 lore raw
Quoted 10 lines · Matthew Wilcox

fs/fcntl.c SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · line 529

Quoted 7 lines · On Fri, Nov 27, 2020 at 11:07:07AM -0800, [email protected] wrote:

+++ b/fs/fcntl.c

fs/fcntl.c +1 -1
@@ -526,7 +526,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 	(dst)->l_whence = (src)->l_whence;	\
 	(dst)->l_start = (src)->l_start;	\
 	(dst)->l_len = (src)->l_len;		\
-	(dst)->l_pid = (src)->l_pid;
+	(dst)->l_pid = (src)->l_pid

This should be wrapped in a do { } while (0).

Quoted 3 lines

Look, this warning is clearly great at finding smelly code, but the fixes being generated to shut up the warning are low quality.

Multiline macros not following the do {} while (0) pattern are likely a larger problem.

I'll take a look.

Thanks,

Tom

#3 lore raw
Quoted 12 lines · Tom Rix
Quoted 10 lines · Matthew Wilcox

fs/fcntl.c SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · line 529

Quoted 7 lines · On Fri, Nov 27, 2020 at 11:07:07AM -0800, [email protected] wrote:

+++ b/fs/fcntl.c

fs/fcntl.c +1 -1
@@ -526,7 +526,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 	(dst)->l_whence = (src)->l_whence;	\
 	(dst)->l_start = (src)->l_start;	\
 	(dst)->l_len = (src)->l_len;		\
-	(dst)->l_pid = (src)->l_pid;
+	(dst)->l_pid = (src)->l_pid

This should be wrapped in a do { } while (0).

Quoted 6 lines
Quoted 3 lines

Look, this warning is clearly great at finding smelly code, but the fixes being generated to shut up the warning are low quality.

Multiline macros not following the do {} while (0) pattern are likely a larger problem.

I'll take a look.

Could it become a static inline function instead?
or that might expand its scope too much?

Signature · 1 line
~Randy
#4 lore raw
Quoted 17 lines · Randy Dunlap
Quoted 16 lines · Tom Rix
Quoted 15 lines · Matthew Wilcox

fs/fcntl.c SYSCALL_DEFINE3(fcntl64, unsigned int, fd, · line 530

Quoted 8 lines · On Fri, Nov 27, 2020 at 11:07:07AM -0800, [email protected] wrote:

+++ b/fs/fcntl.c

fs/fcntl.c +1 -1
@@ -526,7 +526,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd,
 unsigned int, cmd,
 	(dst)->l_whence = (src)->l_whence;	\
 	(dst)->l_start = (src)->l_start;	\
 	(dst)->l_len = (src)->l_len;		\
-	(dst)->l_pid = (src)->l_pid;
+	(dst)->l_pid = (src)->l_pid

This should be wrapped in a do { } while (0).

Look, this warning is clearly great at finding smelly code, but the
fixes being generated to shut up the warning are low quality.

Quoted 7 lines
Quoted 4 lines

Multiline macros not following the do {} while (0) pattern are likely a larger problem.

I'll take a look.

Could it become a static inline function instead?
or that might expand its scope too much?

I think nowadays we should always use static inlines for argument checking unless we're capturing debug information like __FILE__ or __LINE__ or something that a static inline can't. Even in the latter case the pattern should probably be single line #define that captures the information and passes it to a static inline.

There was a time when we had problems with compiler expansion of static inlines, so we shouldn't go back and churn the code base to change it because there's thousands of these and possibly some old compiler used for an obscure architecture that still needs the define.

James

#5 lore raw
Quoted 3 lines · James Bottomley

I think nowadays we should always use static inlines for argument checking unless we're capturing debug information like __FILE__ or __LINE__ or something that a static inline can't.

IMO: __LINE__ should never be used.

__func__ is the only thing that can't be captured correctly as the inline gets its own name.

__builtin_return_address(1) would generally work well enough for the inlines.

Quoted 4 lines

There was a time when we had problems with compiler expansion of static inlines, so we shouldn't go back and churn the code base to change it because there's thousands of these and possibly some old compiler used for an obscure architecture that still needs the define.

That's not a very compelling argument to me.

Those old compilers and obscure architectures should continue to use the old versions of the code.