From dea1a0bee27b5644a4409903d0fe35a8cabdd86f Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 5 Jul 2021 23:26:09 +0300 Subject: [PATCH] audiotestsrc: convert `sizes` to const size_t `sizes` members participate in multiplication and subsequent assignment into port->bpf, which has size_t. So LGTM rightfully complains, there's a chance the multiplication will overflow before the assignment happens. Should have no influence on performance since 64 bit multiplication is as fast, and since the struct is constified, a wise compiler should make sure it doesn't take excess space either. Fixes LGTM warning: Multiplication result may overflow 'unsigned int' before it is converted to 'size_t'. --- spa/plugins/audiotestsrc/audiotestsrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 02ffc36cb..1ea4701cb 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -725,7 +725,7 @@ port_set_format(struct impl *this, } else { struct spa_audio_info info = { 0 }; int idx; - int sizes[4] = { 2, 4, 4, 8 }; + const size_t sizes[4] = { 2, 4, 4, 8 }; if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) return res;