]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove the strlcpy compat code and just #define it to snprintf(3).
authorRoy Marples <roy@marples.name>
Tue, 21 Mar 2017 20:16:47 +0000 (20:16 +0000)
committerRoy Marples <roy@marples.name>
Tue, 21 Mar 2017 20:16:47 +0000 (20:16 +0000)
This is the same and reduces code size.

compat/strlcpy.c [deleted file]
compat/strlcpy.h [deleted file]
configure

diff --git a/compat/strlcpy.c b/compat/strlcpy.c
deleted file mode 100644 (file)
index 47776a0..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
- * All rights reserved
-
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-
-#include "strlcpy.h"
-
-size_t
-strlcpy(char *dst, const char *src, size_t size)
-{
-       const char *s = src;
-       size_t n = size;
-
-       if (n && --n)
-               do {
-                       if (!(*dst++ = *src++))
-                               break;
-               } while (--n);
-
-       if (!n) {
-               if (size)
-                       *dst = '\0';
-               while (*src++);
-       }
-
-
-       return (size_t)(src - s - 1);
-}
diff --git a/compat/strlcpy.h b/compat/strlcpy.h
deleted file mode 100644 (file)
index 951390a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
- * All rights reserved
-
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef STRLCPY_H
-#define STRLCPY_H
-
-#include <sys/types.h>
-
-size_t strlcpy(char *, const char *, size_t);
-#endif
index 3cf0000887090dfc86df88b3dacba1267f82294b..53984182a27dc6cc5298b9c72e0ff40a0d795a6c 100755 (executable)
--- a/configure
+++ b/configure
@@ -773,8 +773,8 @@ EOF
        rm -f _strlcpy.c _strlcpy
 fi
 if [ "$STRLCPY" = no ]; then
-       echo "COMPAT_SRCS+=     compat/strlcpy.c" >>$CONFIG_MK
-       echo "#include          \"compat/strlcpy.h\"" >>$CONFIG_H
+       echo "#define strlcpy(dst, src, size)" \
+               " (size_t)snprintf((dst), (size), \"%s\", (src))" >>$CONFIG_H
 fi
 
 if [ -z "$PIDFILE_LOCK" ]; then