public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: kernel-janitors@vger.kernel.org
Subject: [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
Date: Mon, 06 Feb 2012 21:10:27 +0000	[thread overview]
Message-ID: <4F3041C3.70607@wanadoo.fr> (raw)

Hi,

I don't know if it worses a patch, but function 'nla_strlcpy' in file 
'\lib\nlattr.c' could be improved a bit.
There is no need to memset(0) the whole buffer. Only the end of it has 
to be cleared.

Usually, 'dstsize' is small (most of the time IFNAMSIZ = 16 bytes), so 
the gain should be real small, if noticeable.

I'm not sure of who to cc: the mail. I've just added Alexey Kuznetsov 
which is one of the author of the modified file and still in the 
MAINTAINERS list.


Hope this helps,
Best regards.

Signed-off-by: Christophe Jaillet<christophe.jaillet@wanadoo.fr>

--- a/lib/nlattr.c    2012-02-06 21:40:04.421875000 +0100
+++ b/lib/nlattr.c    2012-02-06 21:50:43.093750000 +0100
@@ -248,8 +248,8 @@
      if (dstsize > 0) {
          size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;

-        memset(dst, 0, dstsize);
          memcpy(dst, src, len);
+        memset(dst + len, 0, dstsize - len);
      }

      return srclen;



             reply	other threads:[~2012-02-06 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 21:10 Christophe JAILLET [this message]
2012-02-07  6:54 ` [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c' Dan Carpenter

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=4F3041C3.70607@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@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