diff mbox

[4/4] intel_error_decode: Future proof ring count

Message ID 1366657257-5017-4-git-send-email-ben@bwidawsk.net (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky April 22, 2013, 7 p.m. UTC
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 tools/intel_error_decode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Chris Wilson April 22, 2013, 7:11 p.m. UTC | #1
On Mon, Apr 22, 2013 at 12:00:57PM -0700, Ben Widawsky wrote:
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>

Fold this into the earlier patch.
-Chris
diff mbox

Patch

diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index 96aaf72..d2e91e7 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -283,6 +283,7 @@  print_fence(unsigned int devid, uint64_t fence)
 static void
 read_data_file(FILE *file)
 {
+#define MAX_RINGS 10 /* I really hope this never... */
 	struct drm_intel_decode *decode_ctx = NULL;
 	uint32_t devid = PCI_CHIP_I855_GM;
 	uint32_t *data = NULL;
@@ -295,7 +296,7 @@  read_data_file(FILE *file)
 	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
 	char *ring_name = NULL;
 	int is_batch = 1;
-	uint32_t raw_head = -1, head[3] = {-1, -1, -1}, acthd[3] = {-1,-1,-1};
+	uint32_t raw_head = -1, head[MAX_RINGS] = {-1, -1, -1}, acthd[MAX_RINGS] = {-1,-1,-1};
 	int i = 0, num_rings = -1;
 
 	while (getline(&line, &line_size, file) > 0) {
@@ -400,6 +401,7 @@  read_data_file(FILE *file)
 			if (matched == 1) {
 				head[i++] = print_head(reg);
 				raw_head = reg;
+				assert(i < MAX_RINGS);
 			}
 
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);