5364de644a
The strncpy function is error prone for doing "safe" string copies, so we generally try to use "snprintf" instead in the code. The function "strlcpy" is a better alternative, since it better conveys the intention of the programmer, and doesn't suffer from the non-null terminating behaviour of it's n'ed brethern. The downside of this function is that it is not available by default on linux, though standard in the BSD's. It is available on most distros by installing "libbsd" package. This patch therefore provides the following in rte_string_fns.h to ensure that strlcpy is available there: * for BSD, include string.h as normal * if RTE_USE_LIBBSD is set, include <bsd/string.h> * if not set, fallback to snprintf for strlcpy Using make build system, the RTE_USE_LIBBSD is a hard-coded value to "n", but when using meson, it's automatically set based on what is available on the platform. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org> |
||
---|---|---|
.. | ||
arm | ||
x86 | ||
common_armv8a_linuxapp | ||
common_base | ||
common_bsdapp | ||
common_linuxapp | ||
defconfig_arm64-armv8a-linuxapp-clang | ||
defconfig_arm64-armv8a-linuxapp-gcc | ||
defconfig_arm64-dpaa2-linuxapp-gcc | ||
defconfig_arm64-dpaa-linuxapp-gcc | ||
defconfig_arm64-thunderx-linuxapp-gcc | ||
defconfig_arm64-xgene1-linuxapp-gcc | ||
defconfig_arm-armv7a-linuxapp-gcc | ||
defconfig_i686-native-linuxapp-gcc | ||
defconfig_i686-native-linuxapp-icc | ||
defconfig_ppc_64-power8-linuxapp-gcc | ||
defconfig_x86_64-native-bsdapp-clang | ||
defconfig_x86_64-native-bsdapp-gcc | ||
defconfig_x86_64-native-linuxapp-clang | ||
defconfig_x86_64-native-linuxapp-gcc | ||
defconfig_x86_64-native-linuxapp-icc | ||
defconfig_x86_x32-native-linuxapp-gcc | ||
meson.build | ||
rte_config.h |