mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] lib: string.c:  Added a funktion function strzcpy
@ 2014-10-05 13:06 Rickard Strandqvist
  2014-10-05 13:06 ` Rickard Strandqvist
  0 siblings, 1 reply; 6+ messages in thread
From: Rickard Strandqvist @ 2014-10-05 13:06 UTC (permalink / raw)
  To: Rickard Strandqvist, Grant Likely
  Cc: Andrew Morton, Andi Kleen, Dan Carpenter, linux-kernel

I've added a strzcpy to make it easier to not do wrong
when you use the function strncpy.

Often one needs the zero padding, but must still have a
guaranteed zero character terminat.
Then you end up writing code like this:
  strncpy(to, src, sizeof(to));
  to[sizeof(to) - 1] = '\0';

This is solved with strzcpy.

Rickard Strandqvist (1):
  lib: string.c:  Added a funktion function strzcpy

 include/linux/string.h |    1 +
 lib/string.c           |   31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

-- 
1.7.10.4


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

end of thread, other threads:[~2014-10-16 21:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-05 13:06 [PATCH v2] lib: string.c: Added a funktion function strzcpy Rickard Strandqvist
2014-10-05 13:06 ` Rickard Strandqvist
2014-10-15 22:15   ` Andrew Morton
2014-10-16 21:09     ` Rickard Strandqvist
2014-10-16 21:17       ` Andrew Morton
2014-10-16 21:28         ` Rickard Strandqvist

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

all inboxes | Powered by JetHome®