public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Alexandra Winter <wintera@linux.ibm.com>,
	Jules Irenge <jbi.octave@gmail.com>,
	borntraeger@linux.ibm.com
Cc: svens@linux.ibm.com, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	agordeev@linux.ibm.com
Subject: Re: [PATCH 3/7] s390/qeth: Convert snprintf() to scnprintf()
Date: Wed, 28 Sep 2022 16:04:07 -0700	[thread overview]
Message-ID: <46a600465f08edbda7d413f6dd0b1b1edd57cfa4.camel@perches.com> (raw)
In-Reply-To: <cfcc8d22-8efd-8b0b-d24f-cb734f9ef927@linux.ibm.com>

On Wed, 2022-09-28 at 10:24 +0200, Alexandra Winter wrote:
> On 27.09.22 16:27, Joe Perches wrote:
> > On Mon, 2022-09-26 at 19:42 +0100, Jules Irenge wrote:
> > > Coccinnelle reports a warning
> > > Warning: Use scnprintf or sprintf
> > > Adding to that, there has been a slow migration from snprintf to scnprintf.
> > > This LWN article explains the rationale for this change
> > > https: //lwn.net/Articles/69419/
> > > Ie. snprintf() returns what *would* be the resulting length,
> > > while scnprintf() returns the actual length.
> > []
> > > diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
> > []
> > > @@ -500,9 +500,9 @@ static ssize_t qeth_hw_trap_show(struct device *dev,
> > >  	struct qeth_card *card = dev_get_drvdata(dev);
> > >  
> > >  	if (card->info.hwtrap)
> > > -		return snprintf(buf, 5, "arm\n");
> > > +		return scnprintf(buf, 5, "arm\n");
> > >  	else
> > > -		return snprintf(buf, 8, "disarm\n");
> > > +		return scnprintf(buf, 8, "disarm\n");
> > >  }
> > 
> > Use sysfs_emit instead.
> > 
> 
> Thank you Joe, that sounds like the best way to handle this. 
> I propose that I take this onto my ToDo list and test it in the s390 environment.
> I will add 
> Reported-by: Jules Irenge <jbi.octave@gmail.com>
> Suggested-by: Joe Perches <joe@perches.com>
> 

Thanks.

btw: I was careless when I wrote one section of the proposed patch.

In this patch block,

@@ -467,28 +478,31 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev,

The last line

+	return sysfs_emit_at(buf, len, "\n");

is not correct

It needs to be changed to:

	len += sysfs_emit_at(buf, len, "\n");

	return len;


      reply	other threads:[~2022-09-28 23:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 18:42 [PATCH 3/7] s390/qeth: Convert snprintf() to scnprintf() Jules Irenge
2022-09-27  0:33 ` Jakub Kicinski
2022-09-27 13:31   ` Alexandra Winter
2022-09-27 14:27 ` Joe Perches
2022-09-28  8:24   ` Alexandra Winter
2022-09-28 23:04     ` Joe Perches [this message]

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=46a600465f08edbda7d413f6dd0b1b1edd57cfa4.camel@perches.com \
    --to=joe@perches.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=jbi.octave@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=wintera@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox