Remove bcopy(), bzero(), bcmp()

bcopy() has a confusing argument order and is actually a move, not a
copy; they're all deprecated since POSIX.1-2001 and removed in -2008,
and we shim them out to mem*() on Linux anyway

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12996
This commit is contained in:
наб
2022-02-25 14:26:54 +01:00
committed by Brian Behlendorf
parent 1d77d62f5a
commit 861166b027
129 changed files with 990 additions and 1051 deletions
+6 -7
View File
@@ -865,7 +865,7 @@ efi_read(int fd, struct dk_gpt *vtoc)
j < sizeof (conversion_array)
/ sizeof (struct uuid_to_ptag); j++) {
if (bcmp(&vtoc->efi_parts[i].p_guid,
if (memcmp(&vtoc->efi_parts[i].p_guid,
&conversion_array[j].uuid,
sizeof (struct uuid)) == 0) {
vtoc->efi_parts[i].p_tag = j;
@@ -920,18 +920,17 @@ write_pmbr(int fd, struct dk_gpt *vtoc)
/* LINTED -- always longlong aligned */
dk_ioc.dki_data = (efi_gpt_t *)buf;
if (efi_ioctl(fd, DKIOCGETEFI, &dk_ioc) == -1) {
(void) memcpy(&mb, buf, sizeof (mb));
bzero(&mb, sizeof (mb));
memset(&mb, 0, sizeof (mb));
mb.signature = LE_16(MBB_MAGIC);
} else {
(void) memcpy(&mb, buf, sizeof (mb));
if (mb.signature != LE_16(MBB_MAGIC)) {
bzero(&mb, sizeof (mb));
memset(&mb, 0, sizeof (mb));
mb.signature = LE_16(MBB_MAGIC);
}
}
bzero(&mb.parts, sizeof (mb.parts));
memset(&mb.parts, 0, sizeof (mb.parts));
cp = (uchar_t *)&mb.parts[0];
/* bootable or not */
*cp++ = 0;
@@ -1455,8 +1454,8 @@ efi_write(int fd, struct dk_gpt *vtoc)
(void) uuid_generate((uchar_t *)
&vtoc->efi_parts[i].p_uguid);
}
bcopy(&vtoc->efi_parts[i].p_uguid,
&efi_parts[i].efi_gpe_UniquePartitionGUID,
memcpy(&efi_parts[i].efi_gpe_UniquePartitionGUID,
&vtoc->efi_parts[i].p_uguid,
sizeof (uuid_t));
}
efi->efi_gpt_PartitionEntryArrayCRC32 =
+1 -3
View File
@@ -46,12 +46,10 @@
static int
nvlist_print_json_string(FILE *fp, const char *input)
{
mbstate_t mbr;
mbstate_t mbr = {0};
wchar_t c;
size_t sz;
bzero(&mbr, sizeof (mbr));
FPRINTF(fp, "\"");
while ((sz = mbrtowc(&c, input, MB_CUR_MAX, &mbr)) > 0) {
if (sz == (size_t)-1 || sz == (size_t)-2) {
+5 -5
View File
@@ -383,9 +383,9 @@ typedef struct kstat32 {
*
* ksp->ks_snaptime = gethrtime();
* if (rw == KSTAT_WRITE)
* bcopy(buf, ksp->ks_data, ksp->ks_data_size);
* memcpy(ksp->ks_data, buf, ksp->ks_data_size);
* else
* bcopy(ksp->ks_data, buf, ksp->ks_data_size);
* memcpy(buf, ksp->ks_data, ksp->ks_data_size);
* return (0);
*
* A more illuminating example is taking a snapshot of a linked list:
@@ -394,7 +394,7 @@ typedef struct kstat32 {
* if (rw == KSTAT_WRITE)
* return (EACCES); ... See below ...
* for (foo = first_foo; foo; foo = foo->next) {
* bcopy((char *) foo, (char *) buf, sizeof (struct foo));
* memcpy(buf, foo, sizeof (struct foo));
* buf = ((struct foo *) buf) + 1;
* }
* return (0);
@@ -423,12 +423,12 @@ typedef struct kstat32 {
* uint_t i;
*
* ... Do the regular copy ...
* bcopy(ksp->ks_data, buf, sizeof (kstat_named_t) * ksp->ks_ndata);
* memcpy(buf, ksp->ks_data, sizeof (kstat_named_t) * ksp->ks_ndata);
*
* for (i = 0; i < ksp->ks_ndata; i++, knp++) {
* if (knp[i].data_type == KSTAT_DATA_STRING &&
* KSTAT_NAMED_STR_PTR(knp) != NULL) {
* bcopy(KSTAT_NAMED_STR_PTR(knp), end,
* memcpy(end, KSTAT_NAMED_STR_PTR(knp),
* KSTAT_NAMED_STR_BUFLEN(knp));
* KSTAT_NAMED_STR_PTR(knp) = end;
* end += KSTAT_NAMED_STR_BUFLEN(knp);
+1 -1
View File
@@ -788,7 +788,7 @@ derive_key(libzfs_handle_t *hdl, zfs_keyformat_t format, uint64_t iters,
switch (format) {
case ZFS_KEYFORMAT_RAW:
bcopy(key_material, key, WRAPPING_KEY_LEN);
memcpy(key, key_material, WRAPPING_KEY_LEN);
break;
case ZFS_KEYFORMAT_HEX:
ret = hex_key_to_raw((char *)key_material,
+1 -2
View File
@@ -3931,14 +3931,13 @@ zpool_vdev_remove(zpool_handle_t *zhp, const char *path)
int
zpool_vdev_remove_cancel(zpool_handle_t *zhp)
{
zfs_cmd_t zc;
zfs_cmd_t zc = {{0}};
char msg[1024];
libzfs_handle_t *hdl = zhp->zpool_hdl;
(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot cancel removal"));
bzero(&zc, sizeof (zc));
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_cookie = 1;
+3 -5
View File
@@ -4285,9 +4285,9 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
boolean_t recursive;
char *snapname = NULL;
char destsnap[MAXPATHLEN * 2];
char origin[MAXNAMELEN];
char origin[MAXNAMELEN] = {0};
char name[MAXPATHLEN];
char tmp_keylocation[MAXNAMELEN];
char tmp_keylocation[MAXNAMELEN] = {0};
nvlist_t *rcvprops = NULL; /* props received from the send stream */
nvlist_t *oxprops = NULL; /* override (-o) and exclude (-x) props */
nvlist_t *origprops = NULL; /* original props (if destination exists) */
@@ -4303,8 +4303,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
#endif
clock_gettime(CLOCK_MONOTONIC_RAW, &begin_time);
bzero(origin, MAXNAMELEN);
bzero(tmp_keylocation, MAXNAMELEN);
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"cannot receive"));
@@ -5228,7 +5226,7 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
* We computed the checksum in the wrong byteorder in
* recv_read() above; do it again correctly.
*/
bzero(&zcksum, sizeof (zio_cksum_t));
memset(&zcksum, 0, sizeof (zio_cksum_t));
fletcher_4_incremental_byteswap(&drr, sizeof (drr), &zcksum);
flags->byteswap = B_TRUE;
+1 -1
View File
@@ -807,7 +807,7 @@ zfs_realloc(libzfs_handle_t *hdl, void *ptr, size_t oldsize, size_t newsize)
return (NULL);
}
bzero((char *)ret + oldsize, (newsize - oldsize));
memset((char *)ret + oldsize, 0, newsize - oldsize);
return (ret);
}
+3 -3
View File
@@ -103,9 +103,9 @@ execvPe(const char *name, const char *path, char * const *argv,
16);
continue;
}
bcopy(p, buf, lp);
memcpy(buf, p, lp);
buf[lp] = '/';
bcopy(name, buf + lp + 1, ln);
memcpy(buf + lp + 1, name, ln);
buf[lp + ln + 1] = '\0';
retry: (void) execve(bp, argv, envp);
@@ -135,7 +135,7 @@ retry: (void) execve(bp, argv, envp);
if (cnt > 0) {
memp[0] = argv[0];
memp[1] = bp;
bcopy(argv + 1, memp + 2,
memcpy(memp + 2, argv + 1,
cnt * sizeof (char *));
} else {
memp[0] = "sh";