From 5b42da1be86b0388254f0d3acdb732a7874ebf14 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Wed, 9 Oct 2024 12:32:53 +0200 Subject: [PATCH] util/format: nr_channels is always <= 4 While the nr_channels is defined with 3 bits, which allows up to 7 channels, actually the number of channels is less or equal to 4. This adds an assertion that helps static analyzers to avoid several false positives related with this. Reviewed-by: Erik Faye-Lund Signed-off-by: Juan A. Suarez Romero Part-of: --- src/util/format/u_format.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/format/u_format.h b/src/util/format/u_format.h index 818c073025f..95976ec14a6 100644 --- a/src/util/format/u_format.h +++ b/src/util/format/u_format.h @@ -1361,6 +1361,8 @@ static inline unsigned util_format_get_nr_components(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); + assert(desc->nr_channels <= 4); + return desc->nr_channels; }