From c1d8293cc79350aa0ee803c7408a9c970f8eebc8 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Tue, 13 Jan 2015 11:50:02 +0000 Subject: [PATCH] intel_gpu_frequency: fix array bounds warning Add a parameter for the size of the act_upon array in the parse function since its size cannot be calculated with ARRAY_SIZE from just the pointer. Cc: Ben Widawsky Signed-off-by: Thomas Wood --- tools/intel_gpu_frequency.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c index d9e7d228..aedceb45 100644 --- a/tools/intel_gpu_frequency.c +++ b/tools/intel_gpu_frequency.c @@ -179,7 +179,7 @@ version(const char *prog) /* Returns read or write operation */ static bool -parse(int argc, char *argv[], bool *act_upon, int *new_freq) +parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq) { int c, tmp; bool write = false; @@ -193,7 +193,7 @@ parse(int argc, char *argv[], bool *act_upon, int *new_freq) /* No args means -g" */ if (argc == 1) { - for (c = 0; c < ARRAY_SIZE(act_upon); c++) + for (c = 0; c < act_upon_n; c++) act_upon[c] = true; goto done; } @@ -233,7 +233,7 @@ parse(int argc, char *argv[], bool *act_upon, int *new_freq) } } else { int i; - for (i = 0; i < ARRAY_SIZE(act_upon); i++) + for (i = 0; i < act_upon_n; i++) act_upon[i] = true; } break; @@ -333,7 +333,7 @@ int main(int argc, char *argv[]) devid = intel_get_drm_devid(drm_open_any()); device = drm_get_card(); - write = parse(argc, argv, targets, set_freq); + write = parse(argc, argv, targets, ARRAY_SIZE(targets), set_freq); fail = write; /* If we've previously locked the frequency, we need to make sure to set things