From 4a03bd897f2d46e651c62c9fe3172cbaae20552e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 19 Feb 2018 09:13:21 +0000 Subject: lib: Always set mismatching index for igt_find_crc_mismatch igt_debugfs.c: In function 'igt_assert_crc_equal': igt_debugfs.c:353:3: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized] igt_debugfs.c: In function 'igt_check_crc_equal': igt_debugfs.c:375:3: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized] Fixes: 7422d7540a3b ("lib/igt_debugfs: Introduce CRC check function, with logic made common") Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- lib/igt_debugfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/igt_debugfs.c') diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 09d42ea0..8adc02e9 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -325,12 +325,10 @@ bool igt_debugfs_search(int device, const char *filename, const char *substring) static bool igt_find_crc_mismatch(const igt_crc_t *a, const igt_crc_t *b, int *index) { + int nwords = min(a->n_words, b->n_words); int i; - if (a->n_words != b->n_words) - return true; - - for (i = 0; i < a->n_words; i++) { + for (i = 0; i < nwords; i++) { if (a->crc[i] != b->crc[i]) { if (index) *index = i; @@ -339,6 +337,12 @@ static bool igt_find_crc_mismatch(const igt_crc_t *a, const igt_crc_t *b, } } + if (a->n_words != b->n_words) { + if (index) + *index = i; + return true; + } + return false; } -- cgit v1.2.3