fix sizeof parameters in allocations This clears `clang-tidy` bugprone-sizeof-expression warnings. The issue in `ext_part_init` was valid. The warnings in `alloc_read_metadata` and `aom_img_add_metadata` were false positives, but the allocations were changed to use the target variable in the expression which cleared the warnings. Change-Id: Id59607f0fb366c552bfc893efec71ee67e33e9ad (cherry picked from commit 615e91d83876b9406b500fdaac9f80cfff203bf5)
diff --git a/aom/src/aom_image.c b/aom/src/aom_image.c index a33262d..497dff3 100644 --- a/aom/src/aom_image.c +++ b/aom/src/aom_image.c
@@ -386,9 +386,9 @@ aom_metadata_t *metadata = aom_img_metadata_alloc(type, data, sz, insert_flag); if (!metadata) return -1; - aom_metadata_t **metadata_array = - (aom_metadata_t **)realloc(img->metadata->metadata_array, - (img->metadata->sz + 1) * sizeof(metadata)); + aom_metadata_t **metadata_array = (aom_metadata_t **)realloc( + img->metadata->metadata_array, + (img->metadata->sz + 1) * sizeof(*metadata_array)); if (!metadata_array) { aom_img_metadata_free(metadata); return -1;
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c index 6d6aa41..ea4b1b6 100644 --- a/av1/decoder/obu.c +++ b/av1/decoder/obu.c
@@ -613,9 +613,9 @@ aom_internal_error(&pbi->error, AOM_CODEC_MEM_ERROR, "Error allocating metadata"); } - aom_metadata_t **metadata_array = - (aom_metadata_t **)realloc(pbi->metadata->metadata_array, - (pbi->metadata->sz + 1) * sizeof(metadata)); + aom_metadata_t **metadata_array = (aom_metadata_t **)realloc( + pbi->metadata->metadata_array, + (pbi->metadata->sz + 1) * sizeof(*metadata_array)); if (!metadata_array) { aom_img_metadata_free(metadata); aom_internal_error(&pbi->error, AOM_CODEC_MEM_ERROR,
diff --git a/av1/encoder/external_partition.c b/av1/encoder/external_partition.c index 45bd433..f3c8dfe 100644 --- a/av1/encoder/external_partition.c +++ b/av1/encoder/external_partition.c
@@ -9,6 +9,8 @@ * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ +#include <string.h> + #include "av1/common/common.h" #include "av1/encoder/external_partition.h" #include "config/aom_config.h" @@ -40,7 +42,7 @@ if (ext_part_controller == NULL) { return AOM_CODEC_INVALID_PARAM; } - av1_zero(ext_part_controller); + memset(ext_part_controller, 0, sizeof(*ext_part_controller)); return AOM_CODEC_OK; }