Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ohaugan@codeaurora.org (Olav Haugan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] coresight: Replace sprintf with scnprintf
Date: Mon, 24 Apr 2017 15:26:35 -0700	[thread overview]
Message-ID: <20170424222635.ghj6ur64hgv6yiyj@codeaurora.org> (raw)
In-Reply-To: <20170408154223.GA22401@kroah.com>

On 17-04-08 17:42:23, Greg KH wrote:
> On Mon, Mar 27, 2017 at 11:09:31AM -0600, Mathieu Poirier wrote:
> > From: Olav Haugan <ohaugan@codeaurora.org>
> > 
> > Replace all occurrences of sprintf with scnprintf in coresight driver for
> > consistency. scnprintf is also a safer alternative to sprintf.
> 
> But it's totally pointless here :(
> 

The driver is using a mix of sprintf and scnprintf. This patch is
making the usage consistent across the driver. (There is actually more scnprintf
usage than sprintf usage.) Consistency is good. What is the harm?

> > 
> > Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > ---
> >  drivers/hwtracing/coresight/coresight-etb10.c      |  2 +-
> >  drivers/hwtracing/coresight/coresight-etm-perf.c   |  2 +-
> >  .../hwtracing/coresight/coresight-etm3x-sysfs.c    | 66 +++++++++++-----------
> >  drivers/hwtracing/coresight/coresight-funnel.c     |  4 +-
> >  drivers/hwtracing/coresight/coresight-stm.c        |  2 +-
> >  drivers/hwtracing/coresight/coresight-tmc.c        |  2 +-
> >  6 files changed, 39 insertions(+), 39 deletions(-)
> > 
> > diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> > index d7325c6534ad..491f4da61c11 100644
> > --- a/drivers/hwtracing/coresight/coresight-etb10.c
> > +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> > @@ -588,7 +588,7 @@ static ssize_t trigger_cntr_show(struct device *dev,
> >  	struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);
> >  	unsigned long val = drvdata->trigger_cntr;
> >  
> > -	return sprintf(buf, "%#lx\n", val);
> > +	return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
> 
> There is no need for this in sysfs show callbacks.  You _know_ this is a
> PAGE_SIZE buffer, and that you can not overflow it with a simple number.
> 
> So don't change these types of functions for no reason please.
> 
> Same for most of this patch.
> 
> thanks,
> 
> greg k-h
> 

-- 
.Olav

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2017-04-24 22:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 17:09 [PATCH 0/3] coresight: next v4.11-rc4 Mathieu Poirier
2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
2017-04-08 15:42   ` Greg KH
2017-04-24 22:26     ` Olav Haugan [this message]
2017-03-27 17:09 ` [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node Mathieu Poirier
2017-04-08 15:43   ` Greg KH
2017-03-27 17:09 ` [PATCH 3/3] coresight: Fixes coresight DT parse to get correct output port ID Mathieu Poirier

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=20170424222635.ghj6ur64hgv6yiyj@codeaurora.org \
    --to=ohaugan@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.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