lkml.org 
[lkml]   [2020]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] locks: remove trailing semicolon in macro definition
From
Date
On Sun, 2020-11-29 at 09:52 -0800, Randy Dunlap wrote:
> On 11/29/20 9:47 AM, Tom Rix wrote:
> > On 11/27/20 11:53 AM, Matthew Wilcox wrote:
> > > On Fri, Nov 27, 2020 at 11:07:07AM -0800, trix@redhat.com wrote:
> > > > +++ b/fs/fcntl.c
> > > > @@ -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.
> > >
> > 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


\
 
 \ /
  Last update: 2020-11-29 19:18    [W:0.042 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site