From 4fee9a2f9eceb88937f45b44340e567d8c945773 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 8 May 2023 16:04:58 -0500 Subject: [PATCH] Remove almost all bcopy/bzero/bcmp calls Get rid of some remaining references to bcopy, bzero, and bcmp. In a few places (such as ka-forwarder.c, and linked_list.c), these were being called without including strings.h, which causes errors on AIX when using the clang-based xlc 17.1 compiler. Remove references even inside comments or documentation, to make it easier to make sure they've all been removed. Leave some references inside platform-specific or kernel code, since those are more likely to need bcopy() et al, and tend to only impact that platform. Note that most references to bcopy() et al were removed by commit c5c521af0e (convert-from-bsd-to-posix-string-and-memory-functions-20010807). Change-Id: I28d1b139348c2a4b2259a259de0c93997c684c40 Reviewed-on: https://gerrit.openafs.org/15432 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie --- doc/man-pages/pod1/rxgen.pod | 2 +- doc/protocol/rx-spec.h | 6 +++--- src/afs/VNOPS/afs_vnop_strategy.c | 2 +- src/afs/afs_dcache.c | 2 +- src/afs/afs_user.c | 2 +- src/aklog/linked_list.c | 2 +- src/bozo/bos_util.c | 2 +- src/budb/database.c | 2 +- src/kauth/ka-forwarder.c | 10 +++++----- src/kauth/knfs.c | 2 +- src/rx/rx.c | 4 ++-- src/rx/rx_user.c | 2 +- src/tests/fsx.c | 8 ++++---- src/tools/dumpscan/afsdump_xsed.c | 4 ++-- src/vol/vol-salvage.c | 2 +- src/vol/volume.c | 4 ++-- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/doc/man-pages/pod1/rxgen.pod b/doc/man-pages/pod1/rxgen.pod index f14e26ce01..ac724b4915 100644 --- a/doc/man-pages/pod1/rxgen.pod +++ b/doc/man-pages/pod1/rxgen.pod @@ -669,7 +669,7 @@ Sample CLIENT code: vldb_list linkedvldbs; vldblist vllist, vllist1; - bzero(&linkedvldbs, sizeof(vldb_list)); + memset(&linkedvldbs, 0, sizeof(vldb_list)); code = VL_LinkedList(&attributes, &nentries, &linkedvldbs); if (!code) { printf("We got %d vldb entries\n", nentries); diff --git a/doc/protocol/rx-spec.h b/doc/protocol/rx-spec.h index f8e42c150d..d3ad9b05d9 100644 --- a/doc/protocol/rx-spec.h +++ b/doc/protocol/rx-spec.h @@ -4389,7 +4389,7 @@ * \par * \#define rx_Read(call, buf, nbytes) * \n ((call)->nLeft > (nbytes) ? - * \n bcopy((call)->bufPtr, (buf), (nbytes)), + * \n memcpy((buf), (call)->bufPtr, (nbytes)), * \n (call)->nLeft -= (nbytes), (call)->bufPtr += (nbytes), (nbytes) * \n : rx_ReadProc((call), (buf), (nbytes))) * \par @@ -4410,7 +4410,7 @@ * \par * \#define rx_Write(call, buf, nbytes) * \n ((call)->nFree > (nbytes) ? - * \n bcopy((buf), (call)->bufPtr, (nbytes)), + * \n memcpy((call)->bufPtr, (buf), (nbytes)), * \n (call)->nFree -= (nbytes), * \n (call)->bufPtr += (nbytes), (nbytes) * \n : rx_WriteProc((call), (buf), (nbytes))) @@ -5269,7 +5269,7 @@ * pn, rn, hostEntP->h_length, sizeof(u_long)); * exit(1); * } - * bcopy(hostEntP->h_addr, (char *)&hostIPAddr, sizeof(hostIPAddr)); + * memcpy(&hostIPAddr, hostEntP->h_addr, sizeof(hostIPAddr)); * return(hostIPAddr); * } /* GetIpAddress */ * \endcode diff --git a/src/afs/VNOPS/afs_vnop_strategy.c b/src/afs/VNOPS/afs_vnop_strategy.c index c4296bb6f3..bb12d60481 100644 --- a/src/afs/VNOPS/afs_vnop_strategy.c +++ b/src/afs/VNOPS/afs_vnop_strategy.c @@ -70,7 +70,7 @@ int afs_ustrategy(struct buf *abp) if ((abp->b_flags & B_READ) == B_READ) { #endif /* read b_bcount bytes into kernel address b_un.b_addr starting - * at byte DEV_BSIZE * b_blkno. Bzero anything we can't read, + * at byte DEV_BSIZE * b_blkno. Zero anything we can't read, * and finally call iodone(abp). File is in abp->b_vp. Credentials * are from u area?? */ diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 8a941d6af0..c1c6413a69 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -2029,7 +2029,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, shortcut = 0; - /* check hints first! (might could use bcmp or some such...) */ + /* check hints first! */ if ((tdc = avc->dchint)) { int dcLocked; diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index 5631b37d0c..c87c35bfaa 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -335,7 +335,7 @@ afs_ComputePAGStats(void) /* * Initialize the tallies, then sweep through each hash chain. We - * can't bzero the structure, since some fields are cumulative over + * can't zero the structure, since some fields are cumulative over * the CM's lifetime. */ authP = &(afs_stats_cmfullperf.authent); diff --git a/src/aklog/linked_list.c b/src/aklog/linked_list.c index 289d645bea..3e9eae14c5 100644 --- a/src/aklog/linked_list.c +++ b/src/aklog/linked_list.c @@ -40,7 +40,7 @@ void ll_init(linked_list *list) } /* This sets everything to zero, which is what we want. */ - bzero((char *)list, sizeof(linked_list)); + memset(list, 0, sizeof(linked_list)); } ll_node *ll_add_node(linked_list *list, ll_end which_end) diff --git a/src/bozo/bos_util.c b/src/bozo/bos_util.c index 62293a270b..97709a9edb 100644 --- a/src/bozo/bos_util.c +++ b/src/bozo/bos_util.c @@ -136,7 +136,7 @@ main(int argc, char **argv) exit(1); } kvno = atoi(argv[2]); - bzero(tkey, sizeof(tkey)); + memset(tkey, 0, sizeof(tkey)); code = kname_parse(name, inst, realm, argv[4]); if (code != 0) { printf("Invalid kerberos name\n"); diff --git a/src/budb/database.c b/src/budb/database.c index a68b1f241c..ce5c2ad9a9 100644 --- a/src/budb/database.c +++ b/src/budb/database.c @@ -213,7 +213,7 @@ UpdateCache(struct ubik_trans *ut, void *rock) db.h.lastUpdate = db.h.lastDumpId = htonl(time(0)); db.h.eofPtr = htonl(sizeof(db.h)); - /* text ptrs cleared by bzero */ + /* text ptrs cleared by memset */ ht_DBInit(); code = dbwrite(ut, 0, (char *)&db.h, sizeof(db.h)); diff --git a/src/kauth/ka-forwarder.c b/src/kauth/ka-forwarder.c index 8d82acc576..55d46064fc 100644 --- a/src/kauth/ka-forwarder.c +++ b/src/kauth/ka-forwarder.c @@ -108,7 +108,7 @@ setup_servers(int argc, char **argv) fprintf(stderr, "%s: unknown host %s\n", prog, host); exit(1); } - bcopy(h->h_addr, &fwdaddr, 4); + memcpy(&fwdaddr, h->h_addr, 4); } servers[i].sin_family = AF_INET; @@ -221,8 +221,8 @@ main(int argc, char **argv) to = &reply; reply.sin_family = AF_INET; - bcopy(bufp, &reply.sin_addr.s_addr, 4); - bcopy(bufp + 4, &reply.sin_port, 2); + memcpy(&reply.sin_addr.s_addr, bufp, 4); + memcpy(&reply.sin_port, bufp + 4, 2); sendptr = bufp + 8; sendlen = rv - 8; } @@ -232,8 +232,8 @@ main(int argc, char **argv) cur_server = (cur_server + 1) % num_servers; to = &servers[cur_server]; - bcopy(&from.sin_addr.s_addr, bufp - 8, 4); - bcopy(&from.sin_port, bufp - 4, 2); + memcpy(bufp - 8, &from.sin_addr.s_addr, 4); + memcpy(bufp - 4, &from.sin_port, 2); sendptr = bufp - 8; sendlen = rv + 8; diff --git a/src/kauth/knfs.c b/src/kauth/knfs.c index 8b6dd8297a..020ab3c8c2 100644 --- a/src/kauth/knfs.c +++ b/src/kauth/knfs.c @@ -260,7 +260,7 @@ NFSCopyToken(afs_int32 ahost, afs_int32 auid) char space[1200]; struct ClearToken ct; afs_int32 index, newIndex; - afs_int32 temp; /* for bcopy */ + afs_int32 temp; char *tp; struct ViceIoctl blob; diff --git a/src/rx/rx.c b/src/rx/rx.c index ab5bbb1196..5071287e14 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -3096,7 +3096,7 @@ rxi_FindPeer(afs_uint32 host, u_short port, int create) } if (!pp) { if (create) { - pp = rxi_AllocPeer(); /* This bzero's *pp */ + pp = rxi_AllocPeer(); /* This zeroes *pp */ pp->host = host; /* set here or in InitPeerParams is zero */ pp->port = port; #ifdef AFS_RXERRQ_ENV @@ -3219,7 +3219,7 @@ rxi_FindConnection(osi_socket socket, afs_uint32 host, *unknownService = 1; return (struct rx_connection *)0; } - conn = rxi_AllocConnection(); /* This bzero's the connection */ + conn = rxi_AllocConnection(); /* This zeroes the connection */ MUTEX_INIT(&conn->conn_call_lock, "conn call lock", MUTEX_DEFAULT, 0); MUTEX_INIT(&conn->conn_data_lock, "conn data lock", MUTEX_DEFAULT, 0); CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0); diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index 15695265ec..a93dd22769 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -705,7 +705,7 @@ rxi_InitPeerParams(struct rx_peer *pp) pp->ifMTU = 0; rx_rto_setPeerTimeoutSecs(pp, 2); - /* I don't initialize these, because I presume they are bzero'd... + /* I don't initialize these, because I presume they are zeroed... * pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec */ diff --git a/src/tests/fsx.c b/src/tests/fsx.c index 2ce2ee0adb..479159cd5f 100644 --- a/src/tests/fsx.c +++ b/src/tests/fsx.c @@ -296,7 +296,7 @@ check_buffers(unsigned offset, unsigned size) unsigned op = 0; unsigned bad = 0; - if (bcmp(good_buf + offset, temp_buf, size) != 0) { + if (memcmp(good_buf + offset, temp_buf, size) != 0) { prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n", offset, size); prt("OFFSET\tGOOD\tBAD\tRANGE\n"); while (size > 0) { @@ -500,7 +500,7 @@ dowrite(unsigned offset, unsigned size) gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { if (file_size < offset) - bzero(good_buf + file_size, offset - file_size); + memset(good_buf + file_size, 0, offset - file_size); file_size = offset + size; if (lite) { warn("Lite file size bug in fsx!"); @@ -556,7 +556,7 @@ domapwrite(unsigned offset, unsigned size) gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { if (file_size < offset) - bzero(good_buf + file_size, offset - file_size); + memset(good_buf + file_size, 0, offset - file_size); file_size = offset + size; if (lite) { warn("Lite file size bug in fsx!"); @@ -618,7 +618,7 @@ dotruncate(unsigned size) log4(OP_TRUNCATE, size, (unsigned)file_size, 0); if (size > file_size) - bzero(good_buf + file_size, size - file_size); + memset(good_buf + file_size, 0, size - file_size); file_size = size; if (testcalls <= simulatedopcount) diff --git a/src/tools/dumpscan/afsdump_xsed.c b/src/tools/dumpscan/afsdump_xsed.c index cd5208693c..877c29625c 100644 --- a/src/tools/dumpscan/afsdump_xsed.c +++ b/src/tools/dumpscan/afsdump_xsed.c @@ -339,7 +339,7 @@ main(int argc, char **argv) exit(2); } - bzero(&dp, sizeof(dp)); + memset(&dp, 0, sizeof(dp)); dp.cb_error = my_error_cb; dp.repair_flags = repairflags; if (X->is_seekable) @@ -365,7 +365,7 @@ main(int argc, char **argv) dt_uint64 where; dp.print_flags = printflags & DSPRINT_DEBUG; - bzero(&phi, sizeof(phi)); + memset(&phi, 0, sizeof(phi)); phi.p = &dp; if ((r = xftell(X, &where)) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index d2300efcaf..dc3df1d6ba 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -2426,7 +2426,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp, for (i = 0; i < MAXINODETYPE; i++) { if (stuff[i].inodeType == VI_LINKTABLE) { - /* Gross hack: SalvageHeader does a bcmp on the volume header. + /* Gross hack: SalvageHeader does a memcmp on the volume header. * And we may have recreated the link table earlier, so set the * RW header as well. The header magic was already checked. */ diff --git a/src/vol/volume.c b/src/vol/volume.c index 3d2564d880..e4e5122963 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -3236,7 +3236,7 @@ attach2(Error * ec, VolumeId volumeId, char *path, struct DiskPartition64 *partp /* * We just read in the diskstuff part of the header. If the detailed - * volume stats area has not yet been initialized, we should bzero the + * volume stats area has not yet been initialized, we should zero the * area and mark it as initialized. */ if (!(V_stat_initialized(vp))) { @@ -6761,7 +6761,7 @@ VAdjustVolumeStatistics_r(Volume * vp) V_dayUseDate(vp) = Midnight(now); /* - * All we need to do is bzero the entire VOL_STATS_BYTES of + * All we need to do is zero the entire VOL_STATS_BYTES of * the detailed volume statistics area. */ memset((V_stat_area(vp)), 0, VOL_STATS_BYTES);