[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a3hQKASNVp0VsFYteGh6Mav3=iNZT5n2eWzFieH0hpXjQ@mail.gmail.com>
Date: Mon, 22 Mar 2021 19:24:51 +0100
From: Arnd Bergmann <arnd@...nel.org>
To: Richard Guy Briggs <rgb@...hat.com>
Cc: Paul Moore <paul@...l-moore.com>, Eric Paris <eparis@...hat.com>,
Jules Irenge <jbi.octave@...il.com>, linux-audit@...hat.com,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] audit: avoid -Wempty-body warning
On Mon, Mar 22, 2021 at 6:58 PM Richard Guy Briggs <rgb@...hat.com> wrote:
>
> On 2021-03-22 17:28, Arnd Bergmann wrote:
> > On Mon, Mar 22, 2021 at 3:33 PM Richard Guy Briggs <rgb@...hat.com> wrote:
> > > > Change the macros to use the usual "do { } while (0)" instead, and change a
> > > > few more that were (void)0, for consistency.
> > >
> > > So what about audit_put_watch() and audit_get_watch() which are set to
> > > {}? (And all of include/linux/audit.h that uses the latter...) Does
> > > this only matter if they are the only action called in an if or loop?
> >
> > I missed those, thanks for pointing it out. I sent a v2 patch now.
>
> Ok, cool, that looks more consistent. Can you answer my question about
> include/linux/audit.h and exactly what conditions require
> "do { } while (0)" over "{ }"?
This is the usual way of constructing a C expression that can be used
e.g. in
if (x)
foo();
else
bar();
If foo() is defined as '{}', this causes a syntax error.
Arnd
Powered by blists - more mailing lists