public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jules Irenge <jbi.octave@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: abbotti@mev.co.uk, hsweeten@visionengravers.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] comedi: Convert snprintf() to scnprintf()
Date: Wed, 28 Sep 2022 14:27:42 +0100	[thread overview]
Message-ID: <YzRLzkltH1nwroNc@octinomon> (raw)
In-Reply-To: <YzKS/3z2cQsFFfxD@kroah.com>

On Tue, Sep 27, 2022 at 08:06:55AM +0200, Greg KH wrote:
> On Mon, Sep 26, 2022 at 07:37:37PM +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.
> > 
> > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > ---
> >  drivers/comedi/comedi_fops.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
> > index 55a0cae04b8d..e8a0142d5894 100644
> > --- a/drivers/comedi/comedi_fops.c
> > +++ b/drivers/comedi/comedi_fops.c
> > @@ -396,7 +396,7 @@ static ssize_t max_read_buffer_kb_show(struct device *csdev,
> >  	mutex_unlock(&dev->mutex);
> >  
> >  	comedi_dev_put(dev);
> > -	return snprintf(buf, PAGE_SIZE, "%u\n", size);
> > +	return scnprintf(buf, PAGE_SIZE, "%u\n", size);
> 
> Ick, no, you should use sysfs_emit() if you really want to change these
> functions to "do the right thing".
> 
> thanks,
> 
> greg k-h

Thanks for feedback. 

I just sent a different version.

I will appreciate any more feedback.

Thanks,

Jules

  reply	other threads:[~2022-09-28 13:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 18:37 [PATCH 1/7] comedi: Convert snprintf() to scnprintf() Jules Irenge
2022-09-27  6:06 ` Greg KH
2022-09-28 13:27   ` Jules Irenge [this message]
2022-09-28 15:45   ` Ian Abbott
2022-09-28 18:51     ` Jules Irenge

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=YzRLzkltH1nwroNc@octinomon \
    --to=jbi.octave@gmail.com \
    --cc=abbotti@mev.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.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