public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
@ 2012-02-06 21:10 Christophe JAILLET
  2012-02-07  6:54 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2012-02-06 21:10 UTC (permalink / raw)
  To: kernel-janitors

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;



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-07  6:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-06 21:10 [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c' Christophe JAILLET
2012-02-07  6:54 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox