From: Debian Samba Maintainers Date: Tue, 30 Jan 2024 09:12:42 +0000 (+0300) Subject: use bzero() instead of memset_s() X-Git-Tag: archive/raspbian/2%4.19.4+dfsg-3+rpi1^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1badc09663d2ea5b62c14f99adc931e2e8896a5d;p=samba.git use bzero() instead of memset_s() lib/replace/replace.h header defines ZERO_STRUCT macro which uses memset_s() function (which is similar to memset() but can not be optimized out by the compiler). Glibc has bzero() with similar property, while memset_s() have is implemented in lib/replace/replace.c, - this way, some binaries needlessly link with libreplace-samba4 just to get rep_memset_s() symbol. By using bzero() instead, this endless linkage is eliminated, so we can package, for example, libldb (which uses ZERO_STRUCT) without it linking to libreplace-samba4. Note: actually using explicit_bzero() so it is not optimized out by the compiler - this is the original goal of using memset_s(). Gbp-Pq: Name use-bzero-instead-of-memset_s.diff --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index 25e6e145..d6d63b36 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -815,7 +815,7 @@ typedef unsigned long long ptrdiff_t ; /** * Zero a structure. */ -#define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x)) +#define ZERO_STRUCT(x) explicit_bzero((char *)&(x), sizeof(x)) /** * Zero a structure given a pointer to the structure.