1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-05 09:18:06 +03:00

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 <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
This commit is contained in:
Michael Tokarev 2024-11-18 15:00:05 +03:00 committed by Pavel Filipensky
parent 712117155e
commit bf1e1387ea
7 changed files with 7 additions and 20 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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