From 8340b98dea45b5355d291064aa8673ddd1515173 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Mon, 11 May 2009 16:01:14 -0700 Subject: [PATCH] Rename strlcpy to ovs_strlcpy. If strlpy is not defined on the build system, we build our own and added it to the OpenVSwitch library. Unfortunately, programs that link against the library may do the same thing, and there will be a name conflict. This renames our implementation to prevent these linking errors. --- lib/dpif.c | 2 +- lib/util.c | 2 +- lib/util.h | 4 +--- lib/vlog.c | 2 +- m4/libopenvswitch.m4 | 3 +-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index de49e832..35b03d9b 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -196,7 +196,7 @@ dpif_get_name(struct dpif *dpif, char *name, size_t name_size) error = dpif_port_query_by_number(dpif, ODPP_LOCAL, &port); if (!error) { - strlcpy(name, port.devname, name_size); + ovs_strlcpy(name, port.devname, name_size); } return error; } diff --git a/lib/util.c b/lib/util.c index 0c9d87bc..7ad8ba4e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -143,7 +143,7 @@ xasprintf(const char *format, ...) } void -strlcpy(char *dst, const char *src, size_t size) +ovs_strlcpy(char *dst, const char *src, size_t size) { if (size > 0) { size_t n = strlen(src); diff --git a/lib/util.h b/lib/util.h index ec657927..dcb15a4b 100644 --- a/lib/util.h +++ b/lib/util.h @@ -108,9 +108,7 @@ char *xasprintf(const char *format, ...) PRINTF_FORMAT(1, 2) MALLOC_LIKE; char *xvasprintf(const char *format, va_list) PRINTF_FORMAT(1, 0) MALLOC_LIKE; void *x2nrealloc(void *p, size_t *n, size_t s); -#ifndef HAVE_STRLCPY -void strlcpy(char *dst, const char *src, size_t size); -#endif +void ovs_strlcpy(char *dst, const char *src, size_t size); void ovs_fatal(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3) NO_RETURN; diff --git a/lib/vlog.c b/lib/vlog.c index 8c7e38c1..d4db5062 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -504,7 +504,7 @@ fetch_braces(const char *p, const char *def, char *out, size_t out_size) out[n_copy] = '\0'; p += n + 2; } else { - strlcpy(out, def, out_size); + ovs_strlcpy(out, def, out_size); } return p; } diff --git a/m4/libopenvswitch.m4 b/m4/libopenvswitch.m4 index 2a603f4a..51d7560b 100644 --- a/m4/libopenvswitch.m4 +++ b/m4/libopenvswitch.m4 @@ -189,6 +189,5 @@ AC_DEFUN([OVS_CHECK_LIBOPENVSWITCH], AC_REQUIRE([OVS_CHECK_RUNDIR]) AC_REQUIRE([OVS_CHECK_LOGDIR]) AC_REQUIRE([OVS_CHECK_MALLOC_HOOKS]) - AC_REQUIRE([OVS_CHECK_VALGRIND]) - AC_CHECK_FUNCS([strlcpy])]) + AC_REQUIRE([OVS_CHECK_VALGRIND])]) -- 2.30.2