From 495d6ba7964e433fecf2ea89f4d60ed7f9254506 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 22 Jul 2025 14:09:10 +0200 Subject: [PATCH] pod: remove some size checks These are already done by the caller. --- spa/include/spa/pod/compare.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/spa/include/spa/pod/compare.h b/spa/include/spa/pod/compare.h index d5d4b3dcc..cb8d5d3b1 100644 --- a/spa/include/spa/pod/compare.h +++ b/spa/include/spa/pod/compare.h @@ -171,12 +171,8 @@ SPA_API_POD_COMPARE int spa_pod_compare_is_compatible_flags(uint32_t type, const { switch (type) { case SPA_TYPE_Int: - if (size < sizeof(int32_t)) - return -EINVAL; return ((*(int32_t *) r1) & (*(int32_t *) r2)) != 0; case SPA_TYPE_Long: - if (size < sizeof(int64_t)) - return -EINVAL; return ((*(int64_t *) r1) & (*(int64_t *) r2)) != 0; default: return -ENOTSUP; @@ -190,11 +186,11 @@ SPA_API_POD_COMPARE int spa_pod_compare_is_step_of(uint32_t type, const void *r1 { switch (type) { case SPA_TYPE_Int: - if (size < sizeof(int32_t) || *(int32_t *)r2 < 1) + if (*(int32_t *)r2 < 1) return -EINVAL; return *(int32_t *) r1 % *(int32_t *) r2 == 0; case SPA_TYPE_Long: - if (size < sizeof(int64_t) || *(int64_t *)r2 < 1) + if (*(int64_t *)r2 < 1) return -EINVAL; return *(int64_t *) r1 % *(int64_t *) r2 == 0; case SPA_TYPE_Rectangle: @@ -202,12 +198,9 @@ SPA_API_POD_COMPARE int spa_pod_compare_is_step_of(uint32_t type, const void *r1 const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1, *rec2 = (struct spa_rectangle *) r2; - if (size < sizeof(struct spa_rectangle) || - rec2->width < 1 || - rec2->height < 1) - { + if (rec2->width < 1 || rec2->height < 1) return -EINVAL; - } + return (rec1->width % rec2->width == 0 && rec1->height % rec2->height == 0); }