Re: [PATCH] devcoredump: avoid -Wempty-body warnings

From: Arnd Bergmann
Date: Mon Mar 22 2021 - 07:23:02 EST


On Mon, Mar 22, 2021 at 11:29 AM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, Mar 22, 2021 at 11:19:53AM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@xxxxxxxx>
> > + * These should normally not fail, but there is no problem
> > + * continuing without the links, so just warn instead of
> > + * failing.
> > + */
> > + WARN_ON_ONCE(sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
> > + "failing_device"));
> >
> > - if (sysfs_create_link(&dev->kobj, &devcd->devcd_dev.kobj,
> > - "devcoredump"))
> > - /* nothing - symlink will be missing */;
> > + WARN_ON_ONCE(sysfs_create_link(&dev->kobj, &devcd->devcd_dev.kobj,
> > + "devcoredump"));
>
> We do not want to reboot machines that have panic-on-warn set,

Fair enough.

> so if this really needs a trace dump, please do that instead...

I don't think the backtrace is needed here, if it ever happens it's either
going to be -ENOMEM or completely reproducible. I can instead
do the cast to (void) that Linus suggested, or a simple if(...) dev_warn()
or dev_warn_once() to have some indication of the failure.

Arnd