Forbid b{copy,zero,cmp}(). Don't include <strings.h> for <string.h>

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12996
This commit is contained in:
наб 2022-01-22 01:56:46 +01:00 committed by Brian Behlendorf
parent 861166b027
commit d465fc5844
61 changed files with 63 additions and 141 deletions

View File

@ -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"

View File

@ -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>

View File

@ -27,7 +27,6 @@
#include <stddef.h>
#include <string.h>
#include <strings.h>
#include <libuutil.h>
#include <libzfs.h>
#include <sys/types.h>

View File

@ -32,7 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <libzfs.h>

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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",

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -48,7 +48,6 @@ KERNEL_H = \
simd.h \
spl_condvar.h \
string.h \
strings.h \
sunddi.h \
sysmacros.h \
systeminfo.h \

View File

@ -1 +0,0 @@
/* do not delete */

View File

@ -33,7 +33,7 @@ KERNEL_H = \
signal.h \
simd.h \
stat.h \
strings.h \
string.h \
sunddi.h \
sysmacros.h \
systeminfo.h \

View File

@ -0,0 +1 @@
#include <linux/string.h>

View File

@ -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 */

View File

@ -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 */

View File

@ -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>

View File

@ -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>

View File

@ -15,7 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <wchar.h>
#include <sys/debug.h>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -29,7 +29,7 @@ libspl_HEADERS = \
simd.h \
stack.h \
stdtypes.h \
strings.h \
string.h \
stropts.h \
sunddi.h \
systeminfo.h \

View File

@ -0,0 +1 @@
#include <string.h>

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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,

View File

@ -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>

View File

@ -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)

View File

@ -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);
}

View File

@ -45,7 +45,6 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
static char *filebase;

View File

@ -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>

View File

@ -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>

View File

@ -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;