[PATCH igt 1/4] lib: Always set mismatching index for igt_find_crc_mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <chris@xxxxxxxxxxxxxxxxxx>
---
 lib/igt_debugfs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 4a119985..7399ae23 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -315,12 +315,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;
@@ -329,6 +327,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;
 }
 
-- 
2.16.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux