driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sandro Volery <sandro@volery.com>
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	aaro.koskinen@iki.fi, davem@davemloft.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: octeon: Avoid several usecases of strcpy
Date: Wed, 11 Sep 2019 12:16:59 +0300	[thread overview]
Message-ID: <20190911091659.GI15977@kadam> (raw)
In-Reply-To: <39D8B984-479C-42D5-8431-9FF7BD3A96D6@volery.com>

On Wed, Sep 11, 2019 at 11:04:38AM +0200, Sandro Volery wrote:
> 
> 
> > On 11 Sep 2019, at 10:52, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > 
> > On Wed, Sep 11, 2019 at 08:23:59AM +0200, Sandro Volery wrote:
> >> strcpy was used multiple times in strcpy to write into dev->name.
> >> I replaced them with strscpy.
> >> 
> >> Signed-off-by: Sandro Volery <sandro@volery.com>
> >> ---
> >> drivers/staging/octeon/ethernet.c | 16 ++++++++--------
> >> 1 file changed, 8 insertions(+), 8 deletions(-)
> >> 
> >> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
> >> index 8889494adf1f..cf8e9a23ebf9 100644
> >> --- a/drivers/staging/octeon/ethernet.c
> >> +++ b/drivers/staging/octeon/ethernet.c
> >> @@ -784,7 +784,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
> >>            priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
> >>            priv->port = CVMX_PIP_NUM_INPUT_PORTS;
> >>            priv->queue = -1;
> >> -            strcpy(dev->name, "pow%d");
> >> +            strscpy(dev->name, "pow%d", sizeof(dev->name));
> > 
> > Is there a program which is generating a warning for this code?  We know
> > that "pow%d" is 6 characters and static analysis tools can understand
> > this code fine so we know it's safe.
> 
> Well I was confused too but checkpatch complained about 
> it so I figured I'd clean it up quick

Ah.  It's a new checkpatch warning.  I don't care in that case.  I'm
fine with replacing all of these in that case.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2019-09-11  9:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11  6:23 [PATCH] Staging: octeon: Avoid several usecases of strcpy Sandro Volery
2019-09-11  8:49 ` Dan Carpenter
2019-09-11  9:04   ` Sandro Volery
2019-09-11  9:16     ` Dan Carpenter [this message]
2019-09-11  9:21       ` Sandro Volery
2019-09-11 10:05         ` Dan Carpenter
2019-09-11 10:58       ` Rasmus Villemoes

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=20190911091659.GI15977@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandro@volery.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;
as well as URLs for NNTP newsgroup(s).