diff --git a/Android.mk b/Android.mk index b9ef5c645..0718ff96f 100644 --- a/Android.mk +++ b/Android.mk @@ -228,7 +228,6 @@ LOCAL_SRC_FILES := \ src/core/utils/heap.cpp \ src/core/utils/jam_detector.cpp \ src/core/utils/missing_strlcpy.c \ - src/core/utils/missing_strlcat.c \ src/core/utils/missing_strnlen.c \ src/core/utils/parse_cmdline.cpp \ src/core/utils/slaac_address.cpp \ diff --git a/BUILD.gn b/BUILD.gn index 9f58b97a8..94b47db40 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -159,7 +159,6 @@ static_library("lib-ot-core") { "src/core/utils/child_supervision.cpp", "src/core/utils/heap.cpp", "src/core/utils/jam_detector.cpp", - "src/core/utils/missing_strlcat.c", "src/core/utils/missing_strlcpy.c", "src/core/utils/missing_strnlen.c", "src/core/utils/parse_cmdline.cpp", diff --git a/configure.ac b/configure.ac index d9a8c19e2..2e9e6a9d8 100644 --- a/configure.ac +++ b/configure.ac @@ -173,7 +173,6 @@ then # Here we guess conservative values for tests that require link checks # to test for these features. This will prevent these checks from # being performed later in the configuration process. - ac_cv_func_strlcat=${ac_cv_func_strlcat-no} ac_cv_func_strlcpy=${ac_cv_func_strlcpy-no} ac_cv_func_strnlen=${ac_cv_func_strnlen-no} else @@ -952,7 +951,6 @@ AC_CHECK_HEADERS([string.h]) # Missing Functions # AC_CHECK_FUNC([strlcpy], [AC_DEFINE([HAVE_STRLCPY], [1], [Define if strlcpy exists.])]) -AC_CHECK_FUNC([strlcat], [AC_DEFINE([HAVE_STRLCAT], [1], [Define if strlcat exists.])]) AC_CHECK_FUNC([strnlen], [AC_DEFINE([HAVE_STRNLEN], [1], [Define if strnlen exists.])]) # diff --git a/etc/cmake/checks.cmake b/etc/cmake/checks.cmake index baaf41b83..1fdea9aaa 100644 --- a/etc/cmake/checks.cmake +++ b/etc/cmake/checks.cmake @@ -28,7 +28,6 @@ include(CheckFunctionExists) -check_function_exists("strlcat" HAVE_STRLCAT) check_function_exists("strlcpy" HAVE_STRLCPY) check_function_exists("strnlen" HAVE_STRNLEN) diff --git a/etc/cmake/openthread-config-generic.h.in b/etc/cmake/openthread-config-generic.h.in index 95c8b5a51..352ffd0fb 100644 --- a/etc/cmake/openthread-config-generic.h.in +++ b/etc/cmake/openthread-config-generic.h.in @@ -26,9 +26,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* Define if strlcat exists. */ -#cmakedefine01 HAVE_STRLCAT - /* Define if strlcpy exists. */ #cmakedefine01 HAVE_STRLCPY diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 99d2e62ea..d294895bf 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -178,7 +178,6 @@ set(COMMON_SOURCES utils/child_supervision.cpp utils/heap.cpp utils/jam_detector.cpp - utils/missing_strlcat.c utils/missing_strlcpy.c utils/missing_strnlen.c utils/parse_cmdline.cpp diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 8bca8e319..0c89b4584 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -235,7 +235,6 @@ SOURCES_COMMON = \ utils/child_supervision.cpp \ utils/heap.cpp \ utils/jam_detector.cpp \ - utils/missing_strlcat.c \ utils/missing_strlcpy.c \ utils/missing_strnlen.c \ utils/parse_cmdline.cpp \ @@ -269,7 +268,6 @@ libopenthread_radio_a_SOURCES = \ radio/radio_callbacks.cpp \ radio/radio_platform.cpp \ thread/link_quality.cpp \ - utils/missing_strlcat.c \ utils/missing_strlcpy.c \ utils/missing_strnlen.c \ utils/parse_cmdline.cpp \ diff --git a/src/core/utils/missing_strlcat.c b/src/core/utils/missing_strlcat.c deleted file mode 100644 index 3e38192d7..000000000 --- a/src/core/utils/missing_strlcat.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, The OpenThread Authors. - * 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. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 "utils/wrap_string.h" - -size_t missing_strlcat(char *dst, const char *src, size_t dstsize) -{ - size_t len = strlen(dst); - - if (len < dstsize - 1) - { - return (len + strlcpy(dst + len, src, dstsize - len)); - } - - return len + strlen(src); -} diff --git a/src/core/utils/wrap_string.h b/src/core/utils/wrap_string.h index f2f0e10d9..c3e349868 100644 --- a/src/core/utils/wrap_string.h +++ b/src/core/utils/wrap_string.h @@ -51,8 +51,6 @@ /* See: https://www.freebsd.org/cgi/man.cgi?query=strlcpy */ WRAP_EXTERN_C size_t missing_strlcpy(char *dst, const char *src, size_t dstsize); -/* See: https://www.freebsd.org/cgi/man.cgi?query=strlcat */ -WRAP_EXTERN_C size_t missing_strlcat(char *dst, const char *src, size_t dstsize); /* See: https://www.freebsd.org/cgi/man.cgi?query=strnlen */ WRAP_EXTERN_C size_t missing_strnlen(const char *s, size_t maxlen); @@ -66,10 +64,6 @@ WRAP_EXTERN_C size_t missing_strnlen(const char *s, size_t maxlen); #define HAVE_STRLCPY 0 #endif -#ifndef HAVE_STRLCAT -#define HAVE_STRLCAT 0 -#endif - #if (!HAVE_STRNLEN) #define strnlen(S, N) missing_strnlen(S, N) #endif @@ -78,8 +72,4 @@ WRAP_EXTERN_C size_t missing_strnlen(const char *s, size_t maxlen); #define strlcpy(D, S, N) missing_strlcpy(D, S, N) #endif -#if (!HAVE_STRLCAT) -#define strlcat(D, S, N) missing_strlcat(D, S, N) -#endif - #endif // WRAP_STRING_H diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index e80b92a15..2b85a5fef 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -122,7 +122,6 @@ check_PROGRAMS += \ test-priority-queue \ test-pskc \ test-string \ - test-strlcat \ test-strlcpy \ test-strnlen \ test-timer \ @@ -223,9 +222,6 @@ test_pskc_SOURCES = $(COMMON_SOURCES) test_pskc.cpp test_string_LDADD = $(COMMON_LDADD) test_string_SOURCES = $(COMMON_SOURCES) test_string.cpp -test_strlcat_LDADD = $(COMMON_LDADD) -test_strlcat_SOURCES = test_strlcat.c - test_strlcpy_LDADD = $(COMMON_LDADD) test_strlcpy_SOURCES = test_strlcpy.c @@ -267,7 +263,6 @@ PRETTY_FILES = \ $(test_spinel_decoder_SOURCES) \ $(test_spinel_encoder_SOURCES) \ $(test_string_SOURCES) \ - $(test_strlcat_SOURCES) \ $(test_strlcpy_SOURCES) \ $(test_strnlen_SOURCES) \ $(test_timer_SOURCES) \ diff --git a/tests/unit/test_strlcat.c b/tests/unit/test_strlcat.c deleted file mode 100644 index e6bf86331..000000000 --- a/tests/unit/test_strlcat.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016-2017, The OpenThread Authors. - * 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. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 - -#include -#include -#include "utils/wrap_string.h" - -int main(int argc, char **argv) -{ - char string_a[8] = "foo"; - char string_b[8] = "barbar"; - size_t ret = 0; - int errors = 0; - - (void)argc; - (void)argv; - - ret = missing_strlcat(string_a, string_b, sizeof(string_a)); - - if (0 != strcmp(string_a, "foobarb")) - { - printf("strcmp failed\n"); - errors++; - } - - if (ret != 9) - { - printf("strlcat return value is wrong (%d)\n", (int)ret); - errors++; - } - - if (errors != 0) - { - printf("FAIL\n"); - return EXIT_FAILURE; - } - - printf("OK\n"); - return EXIT_SUCCESS; -}