cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Julia Lawall <Julia.Lawall@inria.fr>
Cc: cocci <cocci@systeme.lip6.fr>
Subject: [Cocci] cocci: missed strlcpy->strscpy conversion?
Date: Thu, 31 Dec 2020 12:13:30 -0800	[thread overview]
Message-ID: <cc5722eb472a0a94f3418f6081b10f3c4a7e156d.camel@perches.com> (raw)
In-Reply-To: <58a84d03b714f71d231f9cac04af09a6b97c6f04.camel@perches.com>

On Thu, 2020-12-31 at 11:04 -0800, Joe Perches wrote:
> strlcpy is deprecated.  see: Documentation/process/deprecated.rst
> 
> Change the calls that do not use the strlcpy return value to the
> preferred strscpy.
> 
> Done with cocci script:
> 
> @@
> expression e1, e2, e3;
> @@
> 
> -	strlcpy(
> +	strscpy(
> 	e1, e2, e3);
> 
> This cocci script leaves the instances where the return value is
> used unchanged.

Hey Julia.

After using the cocci script above on a test treewide conversion,
there were a few instances with no return use that were not converted.

Any idea why these were not converted?
I don't see a pattern.

The .h files may be because those are the only uses in .h files in the kernel
but drivers/block/rnbd/rnbd-clt.c I don't understand at all.

drivers/block/rnbd/rnbd-clt.c:  strlcpy(sess->sessname, sessname, sizeof(sess->sessname));
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(dst, "PNP:", dst_size);
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h:      strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);

$ git grep -3 strlcpy drivers/block/rnbd/rnbd-clt.c drivers/input/serio/i8042-x86ia64io.h drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
drivers/block/rnbd/rnbd-clt.c-  sess = kzalloc_node(sizeof(*sess), GFP_KERNEL, NUMA_NO_NODE);
drivers/block/rnbd/rnbd-clt.c-  if (!sess)
drivers/block/rnbd/rnbd-clt.c-          return ERR_PTR(-ENOMEM);
drivers/block/rnbd/rnbd-clt.c:  strlcpy(sess->sessname, sessname, sizeof(sess->sessname));
drivers/block/rnbd/rnbd-clt.c-  atomic_set(&sess->busy, 0);
drivers/block/rnbd/rnbd-clt.c-  mutex_init(&sess->lock);
drivers/block/rnbd/rnbd-clt.c-  INIT_LIST_HEAD(&sess->devs_list);
--
drivers/input/serio/i8042-x86ia64io.h-
drivers/input/serio/i8042-x86ia64io.h-static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
drivers/input/serio/i8042-x86ia64io.h-{
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(dst, "PNP:", dst_size);
drivers/input/serio/i8042-x86ia64io.h-
drivers/input/serio/i8042-x86ia64io.h-  while (id) {
drivers/input/serio/i8042-x86ia64io.h-          strlcat(dst, " ", dst_size);
--
drivers/input/serio/i8042-x86ia64io.h-  if (pnp_irq_valid(dev,0))
drivers/input/serio/i8042-x86ia64io.h-          i8042_pnp_kbd_irq = pnp_irq(dev, 0);
drivers/input/serio/i8042-x86ia64io.h-
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
drivers/input/serio/i8042-x86ia64io.h-  if (strlen(pnp_dev_name(dev))) {
drivers/input/serio/i8042-x86ia64io.h-          strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
drivers/input/serio/i8042-x86ia64io.h-          strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
--
drivers/input/serio/i8042-x86ia64io.h-  if (pnp_irq_valid(dev, 0))
drivers/input/serio/i8042-x86ia64io.h-          i8042_pnp_aux_irq = pnp_irq(dev, 0);
drivers/input/serio/i8042-x86ia64io.h-
drivers/input/serio/i8042-x86ia64io.h:  strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
drivers/input/serio/i8042-x86ia64io.h-  if (strlen(pnp_dev_name(dev))) {
drivers/input/serio/i8042-x86ia64io.h-          strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
drivers/input/serio/i8042-x86ia64io.h-          strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
--
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-static inline void bnx2x_vf_fill_fw_str(struct bnx2x *bp, char *buf,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-                                      size_t buf_len)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-{
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h:      strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-}
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h-static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

       reply	other threads:[~2020-12-31 22:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <58a84d03b714f71d231f9cac04af09a6b97c6f04.camel@perches.com>
2020-12-31 20:13 ` Joe Perches [this message]
2020-12-31 20:27   ` [Cocci] cocci: missed strlcpy->strscpy conversion? Julia Lawall
2020-12-31 20:41     ` Joe Perches
2020-12-31 20:49       ` Julia Lawall
2020-12-31 21:21       ` Julia Lawall
2020-12-31 21:23         ` 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=cc5722eb472a0a94f3418f6081b10f3c4a7e156d.camel@perches.com \
    --to=joe@perches.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=cocci@systeme.lip6.fr \
    /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).