From: Michael Tokarev Date: Mon, 18 Nov 2024 12:00:05 +0000 (+0300) Subject: remove usage of bzero X-Git-Tag: tdb-1.4.13~238 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf1e1387ea4a136d06029863eb63b3b1db1c7db0;p=thirdparty%2Fsamba.git remove usage of bzero bzero() function has been deprecated for a long time. In samba it is replaced with memset(). But samba also provides common memory-zeroing macros, like ZERO_STRUCT(). In all places where bzero() is used, it actually meant to zero a structure or an array. So replace these bzero() calls with ZERO_STRUCT() or ZERO_ARRAY() as appropriate, and remove bzero() replacement and testing entirely. While at it, also stop checking for presence of memset() - this function is standard for a very long time, and the only conditional where HAVE_MEMSET were used, was to provide replacement for bzero() - in all other places memset() is used unconditionally. Signed-off-by: Michael Tokarev Reviewed-by: Andreas Schneider Reviewed-by: Pavel Filipenský --- diff --git a/ctdb/server/ctdb_statistics.c b/ctdb/server/ctdb_statistics.c index 4cf8f9e2726..d804c8511cd 100644 --- a/ctdb/server/ctdb_statistics.c +++ b/ctdb/server/ctdb_statistics.c @@ -42,7 +42,7 @@ static void ctdb_statistics_update(struct tevent_context *ev, ctdb->statistics_history[0].statistics_current_time = timeval_current(); - bzero(&ctdb->statistics_current, sizeof(struct ctdb_statistics)); + ZERO_STRUCT(ctdb->statistics_current); ctdb->statistics_current.statistics_start_time = timeval_current(); tevent_add_timer(ctdb->ev, ctdb, @@ -52,13 +52,13 @@ static void ctdb_statistics_update(struct tevent_context *ev, int ctdb_statistics_init(struct ctdb_context *ctdb) { - bzero(&ctdb->statistics, sizeof(struct ctdb_statistics)); + ZERO_STRUCT(ctdb->statistics); ctdb->statistics.statistics_start_time = timeval_current(); - bzero(&ctdb->statistics_current, sizeof(struct ctdb_statistics)); + ZERO_STRUCT(ctdb->statistics_current); ctdb->statistics_current.statistics_start_time = timeval_current(); - bzero(ctdb->statistics_history, sizeof(ctdb->statistics_history)); + ZERO_ARRAY(ctdb->statistics_history); tevent_add_timer(ctdb->ev, ctdb, timeval_current_ofs(ctdb->tunable.stat_history_interval, 0), diff --git a/ctdb/server/ipalloc_common.c b/ctdb/server/ipalloc_common.c index a5177d41dc6..e9a9f8b8584 100644 --- a/ctdb/server/ipalloc_common.c +++ b/ctdb/server/ipalloc_common.c @@ -123,7 +123,7 @@ uint32_t *ip_key(ctdb_sock_addr *ip) { static uint32_t key[IP_KEYLEN]; - bzero(key, sizeof(key)); + ZERO_ARRAY(key); switch (ip->sa.sa_family) { case AF_INET: diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index bf99e7bc526..44ab248391b 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -5597,7 +5597,7 @@ static int control_checktcpport(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, return errno; } - bzero(&sin, sizeof(sin)); + ZERO_STRUCT(sin); sin.sin_family = AF_INET; sin.sin_port = htons(port); ret = bind(s, (struct sockaddr *)&sin, sizeof(sin)); diff --git a/lib/replace/README b/lib/replace/README index 6612eabd22a..d9155aa7b99 100644 --- a/lib/replace/README +++ b/lib/replace/README @@ -40,7 +40,6 @@ dlclose dlsym dlerror chroot -bzero strerror errno mkdtemp @@ -123,6 +122,5 @@ Optional C keywords: volatile Prerequisites: -memset (for bzero) syslog (for vsyslog) mktemp (for mkstemp and mkdtemp) diff --git a/lib/replace/replace.h b/lib/replace/replace.h index b4bc1327824..4923e1f301d 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -414,10 +414,6 @@ int rep_ftruncate(int,off_t); int rep_initgroups(char *name, gid_t id); #endif -#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) -#define bzero(a,b) memset((a),'\0',(b)) -#endif - #ifndef HAVE_DLERROR #define dlerror rep_dlerror char *rep_dlerror(void); diff --git a/lib/replace/tests/testsuite.c b/lib/replace/tests/testsuite.c index 58624f11eb6..7c9195b4753 100644 --- a/lib/replace/tests/testsuite.c +++ b/lib/replace/tests/testsuite.c @@ -451,12 +451,6 @@ static int test_chroot(void) return true; } -static int test_bzero(void) -{ - /* FIXME: bzero */ - return true; -} - static int test_strerror(void) { /* FIXME */ @@ -1200,7 +1194,6 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_seekdir(); ret &= test_dlopen(); ret &= test_chroot(); - ret &= test_bzero(); ret &= test_strerror(); ret &= test_errno(); ret &= test_mkdtemp(); diff --git a/lib/replace/wscript b/lib/replace/wscript index f5114b69ffc..9c0cb7047f1 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -397,7 +397,7 @@ def configure(conf): msg='Checking for fallthrough attribute') # these may be builtins, so we need the link=False strategy - conf.CHECK_FUNCS('strdup memmem printf memset memcpy memmove strcpy strncpy bzero', link=False) + conf.CHECK_FUNCS('strdup memmem printf memcpy memmove strcpy strncpy', link=False) # See https://bugzilla.samba.org/show_bug.cgi?id=1097 #