diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/strlcpy.c | |
parent | *: add indent control files (diff) | |
download | frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/strlcpy.c')
-rw-r--r-- | lib/strlcpy.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/strlcpy.c b/lib/strlcpy.c index 112c8180b..b7681754a 100644 --- a/lib/strlcpy.c +++ b/lib/strlcpy.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with the GNU C Library; if not, see - * <http://www.gnu.org/licenses/>. + * <http://www.gnu.org/licenses/>. */ /* adapted for Quagga from glibc patch submission originally from @@ -27,31 +27,27 @@ #ifndef HAVE_STRLCPY #undef strlcpy -size_t -strlcpy (char *__restrict dest, const char *__restrict src, size_t size); +size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t size); -size_t -strlcpy (char *__restrict dest, const char *__restrict src, size_t size) +size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t size) { - size_t src_length = strlen (src); + size_t src_length = strlen(src); - if (__builtin_expect (src_length >= size, 0)) - { - if (size > 0) - { - /* Copy the leading portion of the string. The last - character is subsequently overwritten with the NUL - terminator, but the destination size is usually a - multiple of a small power of two, so writing it twice - should be more efficient than copying an odd number of - bytes. */ - memcpy (dest, src, size); - dest[size - 1] = '\0'; - } - } - else - /* Copy the string and its terminating NUL character. */ - memcpy (dest, src, src_length + 1); - return src_length; + if (__builtin_expect(src_length >= size, 0)) { + if (size > 0) { + /* Copy the leading portion of the string. The last + character is subsequently overwritten with the NUL + terminator, but the destination size is usually a + multiple of a small power of two, so writing it twice + should be more efficient than copying an odd number + of + bytes. */ + memcpy(dest, src, size); + dest[size - 1] = '\0'; + } + } else + /* Copy the string and its terminating NUL character. */ + memcpy(dest, src, src_length + 1); + return src_length; } #endif /* HAVE_STRLCPY */ |