]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: stzncpy: restrict pointer parameters
authorJim Meyering <meyering@redhat.com>
Sat, 21 Jul 2012 10:08:31 +0000 (12:08 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 21 Jul 2012 10:08:31 +0000 (12:08 +0200)
* src/system.h (stzncpy): Add "restrict" attribute to each pointer
parameter and note in the comment that the buffers must not overlap.

src/system.h

index 6907603e6fd64808fbcec1fd505376c41c86aec5..06cc803b1a2fdf99d0c8ae478aeb058000d82176 100644 (file)
@@ -628,10 +628,11 @@ The following directory is part of the cycle:\n  %s\n"), \
 
 /* Like stpncpy, but do ensure that the result is NUL-terminated,
    and do not NUL-pad out to LEN.  I.e., when strnlen (src, len) == len,
-   this function writes a NUL byte into dest[len].  Thus, the destination
-   buffer must be at least LEN+1 bytes long.  */
+   this function writes a NUL byte into dest[len].  Thus, the length
+   of the destination buffer must be at least LEN + 1.
+   The DEST and SRC buffers must not overlap.  */
 static inline char *
-stzncpy (char *dest, char const *src, size_t len)
+stzncpy (char *restrict dest, char const *restrict src, size_t len)
 {
   char const *src_end = src + len;
   while (src < src_end && *src)