[igt-dev] [PATCH i-g-t] i915/i915_pm_rps: ensure array size matches loop method
Lucas De Marchi
lucas.demarchi at intel.com
Tue Aug 17 17:24:39 UTC 2021
There are 2 methods often used to loop over an array: 1) a sentinel
item; 2) keep around the number of elements. Here we were mixing both.
Since NUMFREQ is required for stack declarations, use it and
ensure the array we are looping over matches it.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
tests/i915/i915_pm_rps.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index b37f15c2..40740be7 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -26,6 +26,7 @@
*
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -72,9 +73,10 @@ struct sysfs_file {
{ "RP1", "r", NULL },
{ "RPn", "r", NULL },
{ "boost", "rb+", NULL },
- { NULL, NULL, NULL }
};
+static_assert(ARRAY_SIZE(sysfs_files) == NUMFREQ, "array size mismatch");
+
static int readval(FILE *filp)
{
int val;
--
2.31.1
More information about the igt-dev
mailing list