[PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

--- 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;


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux