Re: [PATCH 3/7] libsupport: don't use bzero in cache.c

Darrick J. Wong
2026-05-05T00:15:03Z

On Mon, May 04, 2026 at 07:32:57PM -0400, Theodore Ts'o wrote:
> The bzero() function is deprecated and not available in some
> platforms. It's not needed in any case because we can just use an
> automatic initializer.
>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Fixes: 30b3c80ed6bc ("libsupport: add a cache")

Yeesh. What a sordid legacy this function has (see manpage). :(
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
> lib/support/cache.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/lib/support/cache.c b/lib/support/cache.c
> index f9669e3fc..aec785347 100644
> --- a/lib/support/cache.c
> +++ b/lib/support/cache.c
> @@ -850,7 +850,7 @@ cache_report(
> {
> int i;
> unsigned long count, index, total;
> - unsigned long hash_bucket_lengths[HASH_REPORT + 2];
> + unsigned long hash_bucket_lengths[HASH_REPORT + 2] = { 0 };
>
> if ((cache->c_hits + cache->c_misses) == 0)
> return;
> @@ -886,8 +886,6 @@ cache_report(
> cache->c_mrus[i].cm_count * 100 / cache->c_count);
>
> /* report hash bucket lengths */
> - bzero(hash_bucket_lengths, sizeof(hash_bucket_lengths));
> -
> for (i = 0; i < cache->c_hashsize; i++) {
> count = cache->c_hash[i].ch_count;
> if (count > HASH_REPORT)
> --
> 2.53.0
>
>