mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/4] drivers core: Remove strcat uses around sysfs_emit and neaten
Date: Tue, 08 Sep 2020 01:40:19 -0700	[thread overview]
Message-ID: <97e79472f42c8d4fd04acfbde62d014e4ca33917.camel@perches.com> (raw)
In-Reply-To: <20200908083249.GB704757@kroah.com>

On Tue, 2020-09-08 at 10:32 +0200, Greg Kroah-Hartman wrote:
> On Mon, Sep 07, 2020 at 10:58:06AM -0700, Joe Perches wrote:
> > strcat is no longer necessary for sysfs_emit and sysfs_emit_at uses.
> > 
> > Convert the strcat uses to sysfs_emit calls and neaten other block
> > uses of direct returns to use an intermediate const char *.
[]
> This function is now longer, with an assignment that is not needed
> (type=NULL), so why make this "cleanup"?

It's smaller object code.

[]
> > Again, not a type, it's a state.  And you did not merge all sysfs_emit()
> calls into one here, so it's messier now, don't you think?

You can't because the default type uses an argument and not
a fixed string.  I don't think it's messier, no.

> >  int memory_notify(unsigned long val, void *v)
> > @@ -307,17 +305,16 @@ static ssize_t phys_device_show(struct device *dev,
> >  }
> >  
> >  #ifdef CONFIG_MEMORY_HOTREMOVE
> > -static void print_allowed_zone(char *buf, int nid, unsigned long start_pfn,
> > -		unsigned long nr_pages, int online_type,
> > -		struct zone *default_zone)
> > +static int print_allowed_zone(char *buf, int len, int nid,
> > +			      unsigned long start_pfn, unsigned long nr_pages,
> > +			      int online_type, struct zone *default_zone)
> 
> Unrelated change :(

No it's not, it's outputting to buf so it
needs len to output to appropriate spot to
be able to use sysfs_emit_at.

> >  {
> >  	struct zone *zone;
> >  
> >  	zone = zone_for_pfn_range(online_type, nid, start_pfn, nr_pages);
> > -	if (zone != default_zone) {
> > -		strcat(buf, " ");
> > -		strcat(buf, zone->name);
> > -	}
> > +	if (zone == default_zone)
> > +		return 0;
> > +	return sysfs_emit_at(buf, len, " %s", zone->name);

here.

> []

> This is better.

All of it is better. <smile>

> > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
[]
> > @@ -255,9 +255,9 @@ static ssize_t pm_qos_latency_tolerance_us_show(struct device *dev,
> >  	s32 value = dev_pm_qos_get_user_latency_tolerance(dev);
> >  
> >  	if (value < 0)
> > -		return sysfs_emit(buf, "auto\n");
> > +		return sysfs_emit(buf, "%s\n", "auto");
> >  	if (value == PM_QOS_LATENCY_ANY)
> > -		return sysfs_emit(buf, "any\n");
> > +		return sysfs_emit(buf, "%s\n", "any");
> >  
> >  	return sysfs_emit(buf, "%d\n", value);
> >  }
> 
> Unrelated change :(

Again, no it's not unrelated, it's consistent.



  reply	other threads:[~2020-09-08  8:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 17:58 [PATCH 0/4] drivers core: Use sysfs_emit functions Joe Perches
2020-09-07 17:58 ` [PATCH 1/4] drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions Joe Perches
     [not found]   ` <202009080519.SXudMmrU%lkp@intel.com>
2020-09-07 22:58     ` Joe Perches
2020-09-08  8:27   ` Greg Kroah-Hartman
2020-09-08  8:33     ` Joe Perches
2020-09-07 17:58 ` [PATCH 2/4] drivers core: Remove strcat uses around sysfs_emit and neaten Joe Perches
2020-09-08  1:54   ` kernel test robot
2020-09-08  8:32   ` Greg Kroah-Hartman
2020-09-08  8:40     ` Joe Perches [this message]
2020-09-07 17:58 ` [PATCH 3/4] drivers core: Reindent a couple uses around sysfs_emit Joe Perches
2020-09-07 17:58 ` [PATCH 4/4] drivers core: Miscellaneous changes for sysfs_emit Joe Perches
2020-09-07 22:59   ` kernel test robot
2020-09-07 19:58 ` [PATCH 5/4] drivers core: Convert class uses of sprintf to sysfs_emit Joe Perches

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=97e79472f42c8d4fd04acfbde62d014e4ca33917.camel@perches.com \
    --to=joe@perches.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.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®