lkml.org 
[lkml]   [2003]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Resend [PATCH] Make KOBJ_NAME_LEN match BUS_ID_SIZE
On Sat, May 24, 2003 at 08:52:53PM -0700, Linus Torvalds wrote:
>
> How about just adding a sane
>
> int copy_string(char *dest, const char *src, int len)
> {
> int size;
>
> if (!len)
> return 0;
> size = strlen(src);
> if (size >= len)
> size = len-1;
> memcpy(dest, src, size);
> dest[size] = '\0';
> return size;
> }

The return value here isn't particularly useful. The OpenBSD
strlcpy/strlcat variant tell you how big the result should have been
so that you can realloc if need be.

--
Matt Mackall : http://www.selenic.com : of or relating to the moon
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:0.050 / U:2.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site