From 3f7f247a8f1240f715cbb17de2a6339830ee1d0f Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Tue, 5 Mar 2024 21:21:29 -0500 Subject: [PATCH 1/2] Code cleanup: remove accidental self-assigns in mbr.c that have no effect --- libclamav/mbr.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libclamav/mbr.c b/libclamav/mbr.c index 1d0e95532b..202300ef8c 100644 --- a/libclamav/mbr.c +++ b/libclamav/mbr.c @@ -179,14 +179,12 @@ cl_error_t cli_scanmbr(cli_ctx *ctx, size_t sectorsize) /* MBR checks */ status = mbr_check_mbr(&mbr, maplen, sectorsize); if (status != CL_SUCCESS) { - status = status; goto done; } /* MBR is valid, examine bootstrap code */ status = cli_magic_scan_nested_fmap_type(ctx->fmap, 0, sectorsize, ctx, CL_TYPE_ANY, NULL, LAYER_ATTRIBUTES_NONE); if (status != CL_SUCCESS) { - status = status; goto done; } @@ -194,7 +192,6 @@ cl_error_t cli_scanmbr(cli_ctx *ctx, size_t sectorsize) if (SCAN_HEURISTIC_PARTITION_INTXN && (ctx->dconf->other & OTHER_CONF_PRTNINTXN)) { status = mbr_primary_partition_intersection(ctx, mbr, sectorsize); if (status != CL_SUCCESS) { - status = status; goto done; } } @@ -225,7 +222,6 @@ cl_error_t cli_scanmbr(cli_ctx *ctx, size_t sectorsize) status = mbr_scanextprtn(ctx, &prtncount, mbr.entries[i].firstLBA, mbr.entries[i].numLBA, sectorsize); if (status != CL_SUCCESS) { - status = status; goto done; } } else { @@ -236,7 +232,6 @@ cl_error_t cli_scanmbr(cli_ctx *ctx, size_t sectorsize) mbr_parsemsg("cli_magic_scan_nested_fmap_type: [%u, +%u)\n", partoff, partsize); status = cli_magic_scan_nested_fmap_type(ctx->fmap, partoff, partsize, ctx, CL_TYPE_PART_ANY, NULL, LAYER_ATTRIBUTES_NONE); if (status != CL_SUCCESS) { - status = status; goto done; } } From 0aee605c9c02c6b8b4e64706fdf8b2eb70bc827a Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Fri, 8 Mar 2024 09:37:50 -0500 Subject: [PATCH 2/2] Eliminate unused param warnigns when MPOOL disabled --- libclamav/hashtab.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c index fc13f72244..39ba3ca3ce 100644 --- a/libclamav/hashtab.c +++ b/libclamav/hashtab.c @@ -192,6 +192,10 @@ cl_error_t cli_hashtab_init(struct cli_hashtable *s, size_t capacity) cl_error_t cli_htu32_init(struct cli_htu32 *s, size_t capacity, mpool_t *mempool) { +#ifndef USE_MPOOL + UNUSEDPARAM(mempool); +#endif + if (!s) return CL_ENULLARG; @@ -491,6 +495,10 @@ cl_error_t cli_htu32_insert(struct cli_htu32 *s, const struct cli_htu32_element size_t tries = 1; size_t idx; +#ifndef USE_MPOOL + UNUSEDPARAM(mempool); +#endif + if (!s) return CL_ENULLARG; if (s->used > s->maxfill) { @@ -582,6 +590,10 @@ void cli_hashtab_free(struct cli_hashtable *s) void cli_htu32_free(struct cli_htu32 *s, mpool_t *mempool) { +#ifndef USE_MPOOL + UNUSEDPARAM(mempool); +#endif + MPOOL_FREE(mempool, s->htable); s->htable = NULL; s->capacity = 0; @@ -707,9 +719,9 @@ void cli_hashset_destroy(struct cli_hashset *hs) hs->capacity = 0; } -#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t)1 << ((val)&0x1f))) -#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t)1 << ((val)&0x1f))) -#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t)1 << ((val)&0x1f))) +#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t)1 << ((val) & 0x1f))) +#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t)1 << ((val) & 0x1f))) +#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t)1 << ((val) & 0x1f))) /* * searches the hashset for the @key.