aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-01-22 01:56:46 +0100
committerBrian Behlendorf <[email protected]>2022-03-15 15:13:48 -0700
commitd465fc584425c618f8baa13a31b70ffabe053484 (patch)
treed5c120208b294829231adc7d7efbb28fdee3adcd
parent861166b02701dfc8f63a105bd32758e806c84fd7 (diff)
Forbid b{copy,zero,cmp}(). Don't include <strings.h> for <string.h>
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12996
-rw-r--r--cmd/zed/agents/fmd_api.c2
-rw-r--r--cmd/zed/agents/fmd_serd.c2
-rw-r--r--cmd/zed/agents/zfs_diagnosis.c1
-rw-r--r--cmd/zfs/zfs_iter.c1
-rw-r--r--cmd/zfs/zfs_main.c2
-rw-r--r--cmd/zfs/zfs_project.c2
-rw-r--r--cmd/zinject/translate.c3
-rw-r--r--cmd/zinject/zinject.c3
-rw-r--r--cmd/zpool/zpool_iter.c2
-rw-r--r--cmd/zpool/zpool_util.c2
-rw-r--r--cmd/zstream/zstream.c2
-rw-r--r--cmd/zstream/zstream_dump.c2
-rw-r--r--cmd/zstream/zstream_redup.c2
-rw-r--r--cmd/zstream/zstream_token.c2
-rw-r--r--config/Rules.am3
-rw-r--r--include/os/freebsd/spl/sys/Makefile.am1
-rw-r--r--include/os/freebsd/spl/sys/strings.h1
-rw-r--r--include/os/linux/spl/sys/Makefile.am2
-rw-r--r--include/os/linux/spl/sys/string.h1
-rw-r--r--include/os/linux/spl/sys/strings.h30
-rw-r--r--include/sys/xvattr.h2
-rw-r--r--include/sys/zfs_context.h3
-rw-r--r--lib/libefi/rdwr_efi.c1
-rw-r--r--lib/libnvpair/libnvpair_json.c2
-rw-r--r--lib/libshare/libshare.c2
-rw-r--r--lib/libshare/os/freebsd/smb.c1
-rw-r--r--lib/libshare/os/linux/nfs.c1
-rw-r--r--lib/libshare/os/linux/smb.c1
-rw-r--r--lib/libspl/include/sys/Makefile.am2
-rw-r--r--lib/libspl/include/sys/string.h1
-rw-r--r--lib/libspl/include/sys/strings.h33
-rw-r--r--lib/libzfs/libzfs_iter.c2
-rw-r--r--lib/libzfs/libzfs_mount.c2
-rw-r--r--lib/libzfs/libzfs_sendrecv.c2
-rw-r--r--lib/libzfs/os/linux/libzfs_mount_os.c2
-rw-r--r--lib/libzfs/os/linux/libzfs_pool_os.c2
-rw-r--r--module/icp/algs/edonr/edonr.c2
-rw-r--r--module/icp/algs/skein/skein_impl.h2
-rw-r--r--module/nvpair/nvpair.c4
-rw-r--r--module/os/freebsd/spl/acl_common.c1
-rw-r--r--module/os/freebsd/zfs/crypto_os.c2
-rw-r--r--module/os/linux/spl/spl-generic.c2
-rw-r--r--module/os/linux/zfs/zfs_uio.c2
-rw-r--r--module/unicode/u8_textprep.c2
-rw-r--r--module/zcommon/zfs_deleg.c2
-rw-r--r--module/zcommon/zfs_fletcher_aarch64_neon.c2
-rw-r--r--module/zcommon/zfs_fletcher_avx512.c2
-rw-r--r--module/zcommon/zfs_fletcher_intel.c2
-rw-r--r--module/zcommon/zfs_fletcher_sse.c2
-rw-r--r--module/zcommon/zfs_fletcher_superscalar.c2
-rw-r--r--module/zcommon/zfs_fletcher_superscalar4.c2
-rw-r--r--module/zfs/gzip.c1
-rw-r--r--tests/zfs-tests/cmd/file_common.h2
-rw-r--r--tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c11
-rw-r--r--tests/zfs-tests/cmd/mkbusy/mkbusy.c2
-rw-r--r--tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c7
-rw-r--r--tests/zfs-tests/cmd/rename_dir/rename_dir.c15
-rw-r--r--tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c1
-rw-r--r--tests/zfs-tests/tests/functional/checksum/skein_test.c2
-rw-r--r--tests/zfs-tests/tests/functional/ctime/ctime.c1
-rw-r--r--tests/zfs-tests/tests/functional/hkdf/hkdf_test.c6
61 files changed, 63 insertions, 141 deletions
diff --git a/cmd/zed/agents/fmd_api.c b/cmd/zed/agents/fmd_api.c
index 24d6d357e..d97f67b4f 100644
--- a/cmd/zed/agents/fmd_api.c
+++ b/cmd/zed/agents/fmd_api.c
@@ -38,7 +38,7 @@
#include <sys/fm/protocol.h>
#include <uuid/uuid.h>
#include <signal.h>
-#include <strings.h>
+#include <string.h>
#include <time.h>
#include "fmd_api.h"
diff --git a/cmd/zed/agents/fmd_serd.c b/cmd/zed/agents/fmd_serd.c
index 497dffe7f..94736ce42 100644
--- a/cmd/zed/agents/fmd_serd.c
+++ b/cmd/zed/agents/fmd_serd.c
@@ -29,7 +29,7 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <sys/list.h>
#include <sys/time.h>
diff --git a/cmd/zed/agents/zfs_diagnosis.c b/cmd/zed/agents/zfs_diagnosis.c
index 3e45a957f..4fe9ee2bc 100644
--- a/cmd/zed/agents/zfs_diagnosis.c
+++ b/cmd/zed/agents/zfs_diagnosis.c
@@ -27,7 +27,6 @@
#include <stddef.h>
#include <string.h>
-#include <strings.h>
#include <libuutil.h>
#include <libzfs.h>
#include <sys/types.h>
diff --git a/cmd/zfs/zfs_iter.c b/cmd/zfs/zfs_iter.c
index 8b6a49a79..d44bc2ad7 100644
--- a/cmd/zfs/zfs_iter.c
+++ b/cmd/zfs/zfs_iter.c
@@ -32,7 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <libzfs.h>
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 36df2e8f4..938fd2edd 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -46,7 +46,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <zone.h>
diff --git a/cmd/zfs/zfs_project.c b/cmd/zfs/zfs_project.c
index 341cc005d..757d04358 100644
--- a/cmd/zfs/zfs_project.c
+++ b/cmd/zfs/zfs_project.c
@@ -27,7 +27,7 @@
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
diff --git a/cmd/zinject/translate.c b/cmd/zinject/translate.c
index 4939c0b85..2b5f1fcd9 100644
--- a/cmd/zinject/translate.c
+++ b/cmd/zinject/translate.c
@@ -31,7 +31,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <sys/file.h>
#include <sys/mntent.h>
#include <sys/mnttab.h>
@@ -186,6 +186,7 @@ initialize_range(err_type_t type, int level, char *range,
switch (type) {
default:
break;
+
case TYPE_DATA:
break;
diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c
index 10d5dbe90..74c54baeb 100644
--- a/cmd/zinject/zinject.c
+++ b/cmd/zinject/zinject.c
@@ -144,6 +144,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <strings.h>
#include <unistd.h>
@@ -159,7 +160,7 @@
libzfs_handle_t *g_zfs;
int zfs_fd;
-static const char *errtable[TYPE_INVAL] = {
+static const char *const errtable[TYPE_INVAL] = {
"data",
"dnode",
"mos",
diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c
index 65e53f8e0..ec3f768e3 100644
--- a/cmd/zpool/zpool_iter.c
+++ b/cmd/zpool/zpool_iter.c
@@ -32,7 +32,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <thread_pool.h>
#include <libzfs.h>
diff --git a/cmd/zpool/zpool_util.c b/cmd/zpool/zpool_util.c
index 1c64c83d8..91dbb8ec4 100644
--- a/cmd/zpool/zpool_util.c
+++ b/cmd/zpool/zpool_util.c
@@ -28,7 +28,7 @@
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <ctype.h>
#include "zpool_util.h"
diff --git a/cmd/zstream/zstream.c b/cmd/zstream/zstream.c
index 523ae0689..a228f45fa 100644
--- a/cmd/zstream/zstream.c
+++ b/cmd/zstream/zstream.c
@@ -23,7 +23,7 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include <stddef.h>
diff --git a/cmd/zstream/zstream_dump.c b/cmd/zstream/zstream_dump.c
index 04a4986b4..977256cae 100644
--- a/cmd/zstream/zstream_dump.c
+++ b/cmd/zstream/zstream_dump.c
@@ -34,7 +34,7 @@
#include <libnvpair.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <stddef.h>
diff --git a/cmd/zstream/zstream_redup.c b/cmd/zstream/zstream_redup.c
index 36431dc1e..20aff17ae 100644
--- a/cmd/zstream/zstream_redup.c
+++ b/cmd/zstream/zstream_redup.c
@@ -27,7 +27,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <umem.h>
#include <unistd.h>
#include <sys/debug.h>
diff --git a/cmd/zstream/zstream_token.c b/cmd/zstream/zstream_token.c
index 36a76a4bb..bedb6893c 100644
--- a/cmd/zstream/zstream_token.c
+++ b/cmd/zstream/zstream_token.c
@@ -34,7 +34,7 @@
#include <libnvpair.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <stddef.h>
diff --git a/config/Rules.am b/config/Rules.am
index cbef12e21..154073848 100644
--- a/config/Rules.am
+++ b/config/Rules.am
@@ -58,6 +58,9 @@ AM_CPPFLAGS += -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Us
AM_CPPFLAGS += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))"
AM_CPPFLAGS += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))"
AM_CPPFLAGS += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))"
+AM_CPPFLAGS += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)"
+AM_CPPFLAGS += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)"
+AM_CPPFLAGS += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)"
if ASAN_ENABLED
AM_CPPFLAGS += -DZFS_ASAN_ENABLED
diff --git a/include/os/freebsd/spl/sys/Makefile.am b/include/os/freebsd/spl/sys/Makefile.am
index 232aaf569..816f73354 100644
--- a/include/os/freebsd/spl/sys/Makefile.am
+++ b/include/os/freebsd/spl/sys/Makefile.am
@@ -48,7 +48,6 @@ KERNEL_H = \
simd.h \
spl_condvar.h \
string.h \
- strings.h \
sunddi.h \
sysmacros.h \
systeminfo.h \
diff --git a/include/os/freebsd/spl/sys/strings.h b/include/os/freebsd/spl/sys/strings.h
deleted file mode 100644
index 651685d30..000000000
--- a/include/os/freebsd/spl/sys/strings.h
+++ /dev/null
@@ -1 +0,0 @@
-/* do not delete */
diff --git a/include/os/linux/spl/sys/Makefile.am b/include/os/linux/spl/sys/Makefile.am
index 48c27f970..0dc9b90c1 100644
--- a/include/os/linux/spl/sys/Makefile.am
+++ b/include/os/linux/spl/sys/Makefile.am
@@ -33,7 +33,7 @@ KERNEL_H = \
signal.h \
simd.h \
stat.h \
- strings.h \
+ string.h \
sunddi.h \
sysmacros.h \
systeminfo.h \
diff --git a/include/os/linux/spl/sys/string.h b/include/os/linux/spl/sys/string.h
new file mode 100644
index 000000000..38134dcf4
--- /dev/null
+++ b/include/os/linux/spl/sys/string.h
@@ -0,0 +1 @@
+#include <linux/string.h>
diff --git a/include/os/linux/spl/sys/strings.h b/include/os/linux/spl/sys/strings.h
deleted file mode 100644
index 48e417d14..000000000
--- a/include/os/linux/spl/sys/strings.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2018 Lawrence Livermore National Security, LLC.
- * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- * UCRL-CODE-235197
- *
- * This file is part of the SPL, Solaris Porting Layer.
- *
- * The SPL is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * The SPL is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with the SPL. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SPL_SYS_STRINGS_H
-#define _SPL_SYS_STRINGS_H
-
-#include <linux/string.h>
-
-#define bzero(ptr, size) memset(ptr, 0, size)
-#define bcopy(src, dest, size) memmove(dest, src, size)
-#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size))
-
-#endif /* _SPL_SYS_STRINGS_H */
diff --git a/include/sys/xvattr.h b/include/sys/xvattr.h
index fc9bd6ae5..277c46940 100644
--- a/include/sys/xvattr.h
+++ b/include/sys/xvattr.h
@@ -40,7 +40,7 @@
#define _SYS_XVATTR_H
#include <sys/vnode.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h
index 9d99388be..61a6365f5 100644
--- a/include/sys/zfs_context.h
+++ b/include/sys/zfs_context.h
@@ -55,7 +55,7 @@ extern "C" {
#include <sys/disp.h>
#include <sys/debug.h>
#include <sys/random.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <sys/byteorder.h>
#include <sys/list.h>
#include <sys/time.h>
@@ -91,7 +91,6 @@ extern "C" {
#include <unistd.h>
#include <errno.h>
#include <string.h>
-#include <strings.h>
#include <pthread.h>
#include <setjmp.h>
#include <assert.h>
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c
index e32c45131..950c9562f 100644
--- a/lib/libefi/rdwr_efi.c
+++ b/lib/libefi/rdwr_efi.c
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <strings.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include <zlib.h>
diff --git a/lib/libnvpair/libnvpair_json.c b/lib/libnvpair/libnvpair_json.c
index b27f7e4f6..19acea8f5 100644
--- a/lib/libnvpair/libnvpair_json.c
+++ b/lib/libnvpair/libnvpair_json.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <wchar.h>
#include <sys/debug.h>
diff --git a/lib/libshare/libshare.c b/lib/libshare/libshare.c
index a228645fb..7bc31d7a6 100644
--- a/lib/libshare/libshare.c
+++ b/lib/libshare/libshare.c
@@ -27,8 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
-#include <strings.h>
#include <libintl.h>
#include <sys/file.h>
#include <sys/types.h>
diff --git a/lib/libshare/os/freebsd/smb.c b/lib/libshare/os/freebsd/smb.c
index a25990d3b..445784b75 100644
--- a/lib/libshare/os/freebsd/smb.c
+++ b/lib/libshare/os/freebsd/smb.c
@@ -27,7 +27,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c
index 002c5e24c..5acfa3fb8 100644
--- a/lib/libshare/os/linux/nfs.c
+++ b/lib/libshare/os/linux/nfs.c
@@ -29,7 +29,6 @@
#include <dirent.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
diff --git a/lib/libshare/os/linux/smb.c b/lib/libshare/os/linux/smb.c
index 312ffb97d..bcb9b4270 100644
--- a/lib/libshare/os/linux/smb.c
+++ b/lib/libshare/os/linux/smb.c
@@ -50,7 +50,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
diff --git a/lib/libspl/include/sys/Makefile.am b/lib/libspl/include/sys/Makefile.am
index 6816a0125..8305a5180 100644
--- a/lib/libspl/include/sys/Makefile.am
+++ b/lib/libspl/include/sys/Makefile.am
@@ -29,7 +29,7 @@ libspl_HEADERS = \
simd.h \
stack.h \
stdtypes.h \
- strings.h \
+ string.h \
stropts.h \
sunddi.h \
systeminfo.h \
diff --git a/lib/libspl/include/sys/string.h b/lib/libspl/include/sys/string.h
new file mode 100644
index 000000000..3b2f59002
--- /dev/null
+++ b/lib/libspl/include/sys/string.h
@@ -0,0 +1 @@
+#include <string.h>
diff --git a/lib/libspl/include/sys/strings.h b/lib/libspl/include/sys/strings.h
deleted file mode 100644
index c142047dc..000000000
--- a/lib/libspl/include/sys/strings.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _LIBSPL_SYS_STRINGS_H
-#define _LIBSPL_SYS_STRINGS_H
-
-#include <string.h>
-#include <strings.h>
-
-#endif
diff --git a/lib/libzfs/libzfs_iter.c b/lib/libzfs/libzfs_iter.c
index 3c537be79..132454886 100644
--- a/lib/libzfs/libzfs_iter.c
+++ b/lib/libzfs/libzfs_iter.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <stddef.h>
#include <libintl.h>
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index 62c46be95..794fd2f29 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -74,7 +74,7 @@
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <zone.h>
#include <sys/mntent.h>
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 2d866dfa7..4e805c575 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -38,7 +38,7 @@
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <stddef.h>
#include <fcntl.h>
diff --git a/lib/libzfs/os/linux/libzfs_mount_os.c b/lib/libzfs/os/linux/libzfs_mount_os.c
index 1b01caeb7..eab068d59 100644
--- a/lib/libzfs/os/linux/libzfs_mount_os.c
+++ b/lib/libzfs/os/linux/libzfs_mount_os.c
@@ -37,7 +37,7 @@
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <zone.h>
#include <sys/mntent.h>
diff --git a/lib/libzfs/os/linux/libzfs_pool_os.c b/lib/libzfs/os/linux/libzfs_pool_os.c
index 4484a57d3..147efbc0e 100644
--- a/lib/libzfs/os/linux/libzfs_pool_os.c
+++ b/lib/libzfs/os/linux/libzfs_pool_os.c
@@ -34,7 +34,7 @@
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include <zone.h>
diff --git a/module/icp/algs/edonr/edonr.c b/module/icp/algs/edonr/edonr.c
index dcf63fc18..6f3a43e26 100644
--- a/module/icp/algs/edonr/edonr.c
+++ b/module/icp/algs/edonr/edonr.c
@@ -35,7 +35,7 @@
* cryptographic use. Users of Edon-R must interface directly to this module.
*/
-#include <sys/strings.h>
+#include <sys/string.h>
#include <sys/edonr.h>
#include <sys/debug.h>
diff --git a/module/icp/algs/skein/skein_impl.h b/module/icp/algs/skein/skein_impl.h
index 1fa249e95..eff19ce83 100644
--- a/module/icp/algs/skein/skein_impl.h
+++ b/module/icp/algs/skein/skein_impl.h
@@ -25,7 +25,7 @@
#define _SKEIN_IMPL_H_
#include <sys/skein.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include "skein_impl.h"
#include "skein_port.h"
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c
index 53b4f7e5c..a5222dac7 100644
--- a/module/nvpair/nvpair.c
+++ b/module/nvpair/nvpair.c
@@ -40,7 +40,7 @@
#include <sys/nvpair_impl.h>
#include <sys/types.h>
#include <sys/param.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <rpc/xdr.h>
#include <sys/mod.h>
@@ -53,7 +53,7 @@
#include <stddef.h>
#endif
-#define skip_whitespace(p) while ((*(p) == ' ') || (*(p) == '\t')) p++
+#define skip_whitespace(p) while ((*(p) == ' ') || (*(p) == '\t')) (p)++
/*
* nvpair.c - Provides kernel & userland interfaces for manipulating
diff --git a/module/os/freebsd/spl/acl_common.c b/module/os/freebsd/spl/acl_common.c
index 718d0de8b..334a8b463 100644
--- a/module/os/freebsd/spl/acl_common.c
+++ b/module/os/freebsd/spl/acl_common.c
@@ -37,7 +37,6 @@
#include <errno.h>
#include <stdlib.h>
#include <stddef.h>
-#include <strings.h>
#include <unistd.h>
#include <assert.h>
#include <grp.h>
diff --git a/module/os/freebsd/zfs/crypto_os.c b/module/os/freebsd/zfs/crypto_os.c
index ddb95b0d8..c4d5f8761 100644
--- a/module/os/freebsd/zfs/crypto_os.c
+++ b/module/os/freebsd/zfs/crypto_os.c
@@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <opencrypto/cryptodev.h>
#include <opencrypto/xform.h>
-#else
-#include <strings.h>
#endif
#include <sys/zio_crypt.h>
diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c
index bf83d2fc2..cc9a973fe 100644
--- a/module/os/linux/spl/spl-generic.c
+++ b/module/os/linux/spl/spl-generic.c
@@ -42,7 +42,7 @@
#include <linux/ctype.h>
#include <sys/disp.h>
#include <sys/random.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <linux/kmod.h>
#include <linux/mod_compat.h>
#include <sys/cred.h>
diff --git a/module/os/linux/zfs/zfs_uio.c b/module/os/linux/zfs/zfs_uio.c
index 1b315c270..ce47b3e60 100644
--- a/module/os/linux/zfs/zfs_uio.c
+++ b/module/os/linux/zfs/zfs_uio.c
@@ -44,7 +44,7 @@
#include <sys/types.h>
#include <sys/uio_impl.h>
#include <sys/sysmacros.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <linux/kmap_compat.h>
#include <linux/uaccess.h>
diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c
index 863f69f7b..b6b07b245 100644
--- a/module/unicode/u8_textprep.c
+++ b/module/unicode/u8_textprep.c
@@ -36,7 +36,7 @@
*/
#include <sys/types.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <sys/debug.h>
diff --git a/module/zcommon/zfs_deleg.c b/module/zcommon/zfs_deleg.c
index 8a4a6ca86..acd2feca3 100644
--- a/module/zcommon/zfs_deleg.c
+++ b/module/zcommon/zfs_deleg.c
@@ -36,7 +36,7 @@
#include <libnvpair.h>
#include <ctype.h>
#endif
-#include <sys/strings.h>
+#include <sys/string.h>
#include <sys/dsl_deleg.h>
#include "zfs_prop.h"
#include "zfs_deleg.h"
diff --git a/module/zcommon/zfs_fletcher_aarch64_neon.c b/module/zcommon/zfs_fletcher_aarch64_neon.c
index 319c5332d..3e14875d6 100644
--- a/module/zcommon/zfs_fletcher_aarch64_neon.c
+++ b/module/zcommon/zfs_fletcher_aarch64_neon.c
@@ -45,7 +45,7 @@
#include <sys/simd.h>
#include <sys/spa_checksum.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <zfs_fletcher.h>
ZFS_NO_SANITIZE_UNDEFINED
diff --git a/module/zcommon/zfs_fletcher_avx512.c b/module/zcommon/zfs_fletcher_avx512.c
index 9166834f5..713806d28 100644
--- a/module/zcommon/zfs_fletcher_avx512.c
+++ b/module/zcommon/zfs_fletcher_avx512.c
@@ -27,7 +27,7 @@
#include <sys/byteorder.h>
#include <sys/frame.h>
#include <sys/spa_checksum.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <sys/simd.h>
#include <zfs_fletcher.h>
diff --git a/module/zcommon/zfs_fletcher_intel.c b/module/zcommon/zfs_fletcher_intel.c
index 15bfe3cc3..42b6309d3 100644
--- a/module/zcommon/zfs_fletcher_intel.c
+++ b/module/zcommon/zfs_fletcher_intel.c
@@ -43,8 +43,8 @@
#if defined(HAVE_AVX) && defined(HAVE_AVX2)
#include <sys/spa_checksum.h>
+#include <sys/string.h>
#include <sys/simd.h>
-#include <sys/strings.h>
#include <zfs_fletcher.h>
ZFS_NO_SANITIZE_UNDEFINED
diff --git a/module/zcommon/zfs_fletcher_sse.c b/module/zcommon/zfs_fletcher_sse.c
index 3ee679965..791bbd49f 100644
--- a/module/zcommon/zfs_fletcher_sse.c
+++ b/module/zcommon/zfs_fletcher_sse.c
@@ -45,8 +45,8 @@
#include <sys/simd.h>
#include <sys/spa_checksum.h>
+#include <sys/string.h>
#include <sys/byteorder.h>
-#include <sys/strings.h>
#include <zfs_fletcher.h>
ZFS_NO_SANITIZE_UNDEFINED
diff --git a/module/zcommon/zfs_fletcher_superscalar.c b/module/zcommon/zfs_fletcher_superscalar.c
index dec3c1750..ba3fb54cb 100644
--- a/module/zcommon/zfs_fletcher_superscalar.c
+++ b/module/zcommon/zfs_fletcher_superscalar.c
@@ -44,7 +44,7 @@
#include <sys/param.h>
#include <sys/byteorder.h>
#include <sys/spa_checksum.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <zfs_fletcher.h>
ZFS_NO_SANITIZE_UNDEFINED
diff --git a/module/zcommon/zfs_fletcher_superscalar4.c b/module/zcommon/zfs_fletcher_superscalar4.c
index 9e69dc30e..e3eda0295 100644
--- a/module/zcommon/zfs_fletcher_superscalar4.c
+++ b/module/zcommon/zfs_fletcher_superscalar4.c
@@ -44,7 +44,7 @@
#include <sys/param.h>
#include <sys/byteorder.h>
#include <sys/spa_checksum.h>
-#include <sys/strings.h>
+#include <sys/string.h>
#include <zfs_fletcher.h>
ZFS_NO_SANITIZE_UNDEFINED
diff --git a/module/zfs/gzip.c b/module/zfs/gzip.c
index f2a7b6d83..6282229c8 100644
--- a/module/zfs/gzip.c
+++ b/module/zfs/gzip.c
@@ -28,7 +28,6 @@
#include <sys/debug.h>
#include <sys/types.h>
-#include <sys/strings.h>
#include <sys/qat.h>
#include <sys/zio_compress.h>
diff --git a/tests/zfs-tests/cmd/file_common.h b/tests/zfs-tests/cmd/file_common.h
index 64b1777a9..f0c0e32b5 100644
--- a/tests/zfs-tests/cmd/file_common.h
+++ b/tests/zfs-tests/cmd/file_common.h
@@ -52,7 +52,7 @@ extern "C" {
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#define BLOCKSZ 8192
#define DATA 0xa5
diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
index fba18068c..bfa450be5 100644
--- a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
+++ b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <libzfs_core.h>
#include <libzutil.h>
@@ -33,19 +32,19 @@
* Test the nvpair inputs for the non-legacy zfs ioctl commands.
*/
-boolean_t unexpected_failures;
-int zfs_fd;
-const char *active_test;
+static boolean_t unexpected_failures;
+static int zfs_fd;
+static const char *active_test;
/*
* Tracks which zfs_ioc_t commands were tested
*/
-boolean_t ioc_tested[ZFS_IOC_LAST - ZFS_IOC_FIRST];
+static boolean_t ioc_tested[ZFS_IOC_LAST - ZFS_IOC_FIRST];
/*
* Legacy ioctls that are skipped (for now)
*/
-static unsigned ioc_skip[] = {
+static const zfs_ioc_t ioc_skip[] = {
ZFS_IOC_POOL_CREATE,
ZFS_IOC_POOL_DESTROY,
ZFS_IOC_POOL_IMPORT,
diff --git a/tests/zfs-tests/cmd/mkbusy/mkbusy.c b/tests/zfs-tests/cmd/mkbusy/mkbusy.c
index c32f1ecdc..835dc5a02 100644
--- a/tests/zfs-tests/cmd/mkbusy/mkbusy.c
+++ b/tests/zfs-tests/cmd/mkbusy/mkbusy.c
@@ -24,7 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
-#include <strings.h>
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
diff --git a/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c b/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c
index 3072ca979..4d2abfeb1 100644
--- a/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c
+++ b/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c
@@ -20,13 +20,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <libzfs_core.h>
#include <sys/nvpair.h>
-nvlist_t *nvl;
-const char *pool;
-boolean_t unexpected_failures;
+static nvlist_t *nvl;
+static const char *pool;
+static boolean_t unexpected_failures;
static boolean_t
nvlist_equal(nvlist_t *nvla, nvlist_t *nvlb)
diff --git a/tests/zfs-tests/cmd/rename_dir/rename_dir.c b/tests/zfs-tests/cmd/rename_dir/rename_dir.c
index 897ec7b84..3c3f45146 100644
--- a/tests/zfs-tests/cmd/rename_dir/rename_dir.c
+++ b/tests/zfs-tests/cmd/rename_dir/rename_dir.c
@@ -46,7 +46,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-#include <strings.h>
int
main(void)
@@ -58,6 +57,7 @@ main(void)
perror("fork");
exit(1);
break;
+
case 0:
while (i > 0) {
int c_count = 0;
@@ -65,11 +65,11 @@ main(void)
c_count++;
if (rename("1/2/3/c", "a/b/c") == 0)
c_count++;
- if (c_count) {
+ if (c_count)
(void) fprintf(stderr, "c_count: %d", c_count);
- }
}
- break;
+ _exit(0);
+
default:
while (i > 0) {
int p_count = 0;
@@ -77,12 +77,9 @@ main(void)
p_count++;
if (rename("a/b/c/d/e/1", "1") == 0)
p_count++;
- if (p_count) {
+ if (p_count)
(void) fprintf(stderr, "p_count: %d", p_count);
- }
}
- break;
+ return (0);
}
-
- return (0);
}
diff --git a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c
index f8b6e3e80..9aeabb08e 100644
--- a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c
+++ b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c
@@ -45,7 +45,6 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
-#include <strings.h>
static char *filebase;
diff --git a/tests/zfs-tests/tests/functional/checksum/skein_test.c b/tests/zfs-tests/tests/functional/checksum/skein_test.c
index aff9fec43..99b47b453 100644
--- a/tests/zfs-tests/tests/functional/checksum/skein_test.c
+++ b/tests/zfs-tests/tests/functional/checksum/skein_test.c
@@ -34,7 +34,7 @@
#include <sys/skein.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/stdtypes.h>
diff --git a/tests/zfs-tests/tests/functional/ctime/ctime.c b/tests/zfs-tests/tests/functional/ctime/ctime.c
index 41dcf6abc..cb2be72ee 100644
--- a/tests/zfs-tests/tests/functional/ctime/ctime.c
+++ b/tests/zfs-tests/tests/functional/ctime/ctime.c
@@ -38,7 +38,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <strings.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
diff --git a/tests/zfs-tests/tests/functional/hkdf/hkdf_test.c b/tests/zfs-tests/tests/functional/hkdf/hkdf_test.c
index e280af69b..473a9ba9a 100644
--- a/tests/zfs-tests/tests/functional/hkdf/hkdf_test.c
+++ b/tests/zfs-tests/tests/functional/hkdf/hkdf_test.c
@@ -18,13 +18,11 @@
*/
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include <sys/crypto/icp.h>
#include <sys/sha2.h>
#include <sys/hkdf.h>
-#define NELEMS(x) (sizeof (x) / sizeof ((x)[0]))
-
/*
* Byte arrays are given as char pointers so that they
* can be specified as strings.
@@ -214,7 +212,7 @@ main(void)
icp_init();
- for (i = 0; i < NELEMS(test_vectors); i++) {
+ for (i = 0; i < ARRAY_SIZE(test_vectors); i++) {
ret = run_test(i, &test_vectors[i]);
if (ret != 0)
break;