mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Baole Ni <baolex.ni@intel.com>,
	cmetcalf@mellanox.com, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org,
	viresh.kumar@linaro.org, chuansheng.liu@intel.com
Subject: Re: [PATCH 0029/1285] Replace numeric parameter like 0444 with macro
Date: Tue, 2 Aug 2016 10:35:37 -0400	[thread overview]
Message-ID: <20160802143537.GT15995@brightrain.aerifal.cx> (raw)
In-Reply-To: <20160802121617.GA23006@kroah.com>

On Tue, Aug 02, 2016 at 02:16:17PM +0200, Greg KH wrote:
> On Tue, Aug 02, 2016 at 06:35:37PM +0800, Baole Ni wrote:
> > I find that the developers often just specified the numeric value
> > when calling a macro which is defined with a parameter for access permission.
> > As we know, these numeric value for access permission have had the corresponding macro,
> > and that using macro can improve the robustness and readability of the code,
> > thus, I suggest replacing the numeric parameter with the macro.
> > 
> > Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> > Signed-off-by: Baole Ni <baolex.ni@intel.com>
> > ---
> >  arch/tile/kernel/sysfs.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/tile/kernel/sysfs.c b/arch/tile/kernel/sysfs.c
> > index 825867c..cef3937 100644
> > --- a/arch/tile/kernel/sysfs.c
> > +++ b/arch/tile/kernel/sysfs.c
> > @@ -38,7 +38,7 @@ static ssize_t chip_width_show(struct device *dev,
> >  {
> >  	return sprintf(page, "%u\n", smp_width);
> >  }
> > -static DEVICE_ATTR(chip_width, 0444, chip_width_show, NULL);
> > +static DEVICE_ATTR(chip_width, S_IRUSR | S_IRGRP | S_IROTH, chip_width_show, NULL);
> 
> You do know about S_IRUGO, right?  Why not use that?
> 
> Same goes for your other replacements, use the correct #define, not a
> mix of values | together.
> 
> And you are sending hundreds of patches with the same identical subject
> line, that's not ok, you need to make it unique for every patch.
> Usually that is done with the subsystem and driver name, see examples of
> this in the kernel changelogs.
> 
> Please fix up and try again, in a much smaller series, before trying to
> do this across the whole kernel tree.
> 
> good luck!

While I won't object to the parts I'm maintainer for if there's a
general consensus this is an improvement, I don't think it's an
improvement, even with S_IRUGO. It's a significant decrease in
readability. Everybody who works on this code knows immediately and
intuitively what 0444 means. I have to actually stop and think about
what S_IRUGO means.

>From my perspective, these macros were a mistake from a time when
standardization efforts wrongly thought of file permission mode values
as "not a public interface". POSIX since corrected that (in the 2008
edition, from what I can tell); the specific values everybody expects
are mandated.

Rich

  reply	other threads:[~2016-08-02 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 10:35 Baole Ni
2016-08-02 12:16 ` Greg KH
2016-08-02 14:35   ` Rich Felker [this message]
2016-08-02 16:27   ` Linus Torvalds

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=20160802143537.GT15995@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=baolex.ni@intel.com \
    --cc=chuansheng.liu@intel.com \
    --cc=cmetcalf@mellanox.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=viresh.kumar@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®