Skip to contentSkip to conversation

xen: Fix console buffer content length calculation

PATCH In review Daniel Kiper 1 participant 1 message Mar 15, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 xen: Fix console buffer content length calculation

Function displaying console buffer always assumes its content lenght equal to console buffer size. This is not true and sometimes it sends garbage to the screen. This patch fixes this issue.

Additionally, remove references to unused conringc variable.

xen_hyper_command.c +8 -12
diff -Npru crash-6.1.4.orig/xen_hyper_command.c crash-6.1.4/xen_hyper_command.c
@@ -585,11 +585,10 @@ xen_hyper_cmd_log(void)
 void
 xen_hyper_dump_log(void)
 {
-	uint conringc, conringp;
-	uint warp, start, len, idx, i;
+	uint conringp, warp, len, idx, i;
 	ulong conring;
 	char *buf;
-	char last;
+	char last = 0;
 	uint32_t conring_size;
 
 	if (get_symbol_type("conring", NULL, NULL) == TYPE_CODE_ARRAY)
@@ -597,7 +596,6 @@ xen_hyper_dump_log(void)
 	else
 		get_symbol_data("conring", sizeof(ulong), &conring);
 
-	get_symbol_data("conringc", sizeof(uint), &conringc);
 	get_symbol_data("conringp", sizeof(uint), &conringp);
 
 	if (symbol_exists("conring_size"))
@@ -605,21 +603,19 @@ xen_hyper_dump_log(void)
 	else
 		conring_size = XEN_HYPER_CONRING_SIZE;
 
-	warp = FALSE;
 	if (conringp >= conring_size) {
-		if ((start = conringp & (conring_size - 1))) {
-			warp = TRUE;
-		}
+		idx = conringp & (conring_size - 1);
+		len = conring_size;
+		warp = TRUE;
 	} else {
-		start = 0;
+		idx = 0;
+		len = conringp;
+		warp = FALSE;
 	}
 
 	buf = GETBUF(conring_size);
 	readmem(conring, KVADDR, buf, conring_size,
 		"conring contents", FAULT_ON_ERROR);
-	idx = start;
-	len = conring_size;
-	last = 0;
 
 wrap_around:
 	for (i = idx; i < len; i++) {