All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Max Kellermann <max.kellermann@ionos.com>
Cc: Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] drivers/hwmon: add local variable for newly allocated attribute_group**
Date: Mon, 9 Oct 2023 12:36:38 -0700	[thread overview]
Message-ID: <61bd7bfd-5054-4578-bcb5-0b855706b6d7@roeck-us.net> (raw)
In-Reply-To: <CAKPOu+8Uk4GNpZ3DfWhNWXR1bQ60LxcaK9nKs+kRKuq3BOJtmA@mail.gmail.com>

On Mon, Oct 09, 2023 at 07:28:03PM +0200, Max Kellermann wrote:
> On Mon, Oct 9, 2023 at 7:19 PM Guenter Roeck <linux@roeck-us.net> wrote:
> > I have no idea what this is about, and I don't see how that would
> > improve anything, but ...
> 
> Later, we can make lots of global variables "const", which puts them
> in ".rodata" (write-protected at runtime). This is some
> micro-hardening.
> 
> > CHECK: multiple assignments should be avoided
> > #101: FILE: drivers/hwmon/hwmon.c:794:
> > +               hwdev->groups = new_groups = kcalloc(ngroups, sizeof(*new_groups), GFP_KERNEL);
> 
> What program emitted this warning? checkpatch.pl had no error. I'll
> change it in all patches.

I doubt that you ran checkpatch --strict. That check has existed in checkpatch
at least since 2007.

Also, process/coding-style.rst says:

    Don't put multiple assignments on a single line either.  Kernel coding style
    is super simple.  Avoid tricky expressions.

As far as I know that guildeline has not changed.

Now, you might argue something like "who cares about checkpatch --strict",
but in Documentation/hwmon/submitting-patches.rst we specifically say

* Please run your patch through 'checkpatch --strict'. There should be no
  errors, no warnings, and few if any check messages. If there are any
  messages, please be prepared to explain.

So, please explain why this message and with it the coding style violation
should be ignored.

> 
> > either case, this change is not acceptable.
> 
> Because of the multi-assignment, or is there something else?

I don't really see the benefit of this code, and I am not sure if the
explanation about compiler optimization is really valid. It makes me
want to run some test compliations to see if the claim is really true,
and I really don't have time for that.

Also, as Greg points out, this is not in a hot code path but executed
exactly once for each hwmon device, so making such a change with a reason
like that just invites lots of follow-up patches with similar reasons,
and then the submitters of those can point to this patch and argue
"but you accepted that one". You say "micro-hardening" above, but for
me it is time consuming micro-optimization.

Guenter

  reply	other threads:[~2023-10-09 19:36 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 16:57 [PATCH 1/7] drivers/rtc/sysfs: move code to count_attribute_groups() Max Kellermann
2023-10-09 16:57 ` [PATCH 2/7] drivers/hwmon: add local variable for newly allocated attribute_group** Max Kellermann
2023-10-09 17:19   ` Guenter Roeck
2023-10-09 17:28     ` Max Kellermann
2023-10-09 19:36       ` Guenter Roeck [this message]
2023-10-09 17:27   ` Greg KH
2023-10-09 17:34     ` Max Kellermann
2023-10-09 16:57 ` [PATCH 3/7] drivers/extcon: " Max Kellermann
2023-10-09 17:28   ` Greg KH
2023-10-09 16:57 ` [PATCH 4/7] drivers/counter: " Max Kellermann
2023-10-09 17:28   ` Greg KH
2023-10-09 16:57 ` [PATCH 5/7] drivers/tty/serial_core: " Max Kellermann
2023-10-09 17:28   ` Greg Kroah-Hartman
2023-10-09 16:57 ` [PATCH 6/7] fs/sysfs/group: make attribute_group pointers const Max Kellermann
2023-10-09 17:24   ` Guenter Roeck
2023-10-09 20:05     ` Max Kellermann
2023-10-10  5:59       ` Greg Kroah-Hartman
2023-10-10  6:48       ` Joe Perches
2023-10-10  6:57         ` Greg Kroah-Hartman
2023-10-10  7:38         ` Max Kellermann
2023-10-10  8:01           ` Joe Perches
2023-10-09 17:25   ` Greg Kroah-Hartman
2023-10-09 17:30     ` Max Kellermann
2023-10-09 17:31     ` Greg Kroah-Hartman
2023-10-09 20:20     ` Max Kellermann
2023-10-10  5:38   ` kernel test robot
2023-10-09 16:57 ` [PATCH 7/7] block, drivers: make lots of attribute_group globals const Max Kellermann
2023-10-09 17:30   ` Greg Kroah-Hartman
2023-10-09 17:40     ` Max Kellermann
2023-10-09 17:24 ` [PATCH 1/7] drivers/rtc/sysfs: move code to count_attribute_groups() Greg KH
2023-10-09 18:01   ` Max Kellermann
2023-10-10  8:15 ` Alexandre Belloni
2023-10-10  8:24   ` Max Kellermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61bd7bfd-5054-4578-bcb5-0b855706b6d7@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max.kellermann@ionos.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.