Linux commit v4.2-rc1-2-g30035e45753b
string: provide strscpy()
The strscpy() API is intended to be used instead of strlcpy(),
and instead of most uses of strncpy().
Unfortunatley strscpy is not always available.
Test for strscpy and fallback to strlcpy when strscpy is
not available.
Test-Parameters: trivial
Fixes:
b77a6d86936 ("LU-14665 lnet: simplify lnet_ni_add_interface")
HPE-bug-id: LUS-9546
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I43038e4a6260dafb57195ec3417ce009f5a3fad4
Reviewed-on: https://review.whamcloud.com/45175
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
AC_SUBST(GNILND)
]) # LN_CONFIG_GNILND
AC_SUBST(GNILND)
]) # LN_CONFIG_GNILND
+# LN_CONFIG_STRSCPY_EXISTS
+#
+# If strscpy exists, prefer it over strlcpy
+#
+AC_DEFUN([LN_CONFIG_STRSCPY_EXISTS], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([kernel strscpy is available],
+strscpy_exists, [
+ #include <linux/string.h>
+],[
+ strscpy((char *)NULL, (const char *)NULL, 0);
+],[
+ AC_DEFINE(HAVE_STRSCPY, 1,
+ [kernel strscpy is available])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_CONFIG_STRSCPY_EXISTS
+
# LN_CONFIG_SOCK_CREATE_KERN
#
# 4.x sock_create_kern() added a first parameter as 'struct net *'
# LN_CONFIG_SOCK_CREATE_KERN
#
# 4.x sock_create_kern() added a first parameter as 'struct net *'
LN_CONFIG_BACKOFF
LN_CONFIG_O2IB
LN_CONFIG_GNILND
LN_CONFIG_BACKOFF
LN_CONFIG_O2IB
LN_CONFIG_GNILND
+LN_CONFIG_STRSCPY_EXISTS
# 3.10
LN_EXPORT_KMAP_TO_PAGE
# 3.15
# 3.10
LN_EXPORT_KMAP_TO_PAGE
# 3.15
#define SPACESTR " \t\v\r\n"
#define DELIMITERS ":()[]"
#define SPACESTR " \t\v\r\n"
#define DELIMITERS ":()[]"
+#ifndef HAVE_STRSCPY
+#define strscpy(s1, s2, sz) strlcpy((s1), (s2), (sz))
+#endif
+
static void
lnet_syntax(const char *name, const char *str, int offset, int width)
{
static void
lnet_syntax(const char *name, const char *str, int offset, int width)
{