Package: mcelog
Version: 0.7-4
Tags: patch

mcelog reads 64-bit addresses from the MCE, but passes them around with
type ‘unsigned long’, which causes mcelog --dmi to give incorrect
results on 32-bit systems with more than 4 GiB of RAM.  The attached
patch changes this type to ‘unsigned long long’.

diff -ur mcelog-0.7.orig/dmi.c mcelog-0.7/dmi.c
--- mcelog-0.7.orig/dmi.c	2006-05-03 02:55:54.000000000 -0400
+++ mcelog-0.7/dmi.c	2007-08-10 02:27:42.000000000 -0400
@@ -263,18 +263,18 @@
 			Wprintf("%s ", type_details[i]);
 }
 
-void dump_memdev(unsigned handle, unsigned long addr)
+void dump_memdev(unsigned handle, unsigned long long addr)
 {
 	char tmp[20];
 	struct dmi_memdev *md = (struct dmi_memdev *)handle_to_entry[handle];
 	if (!md) { 
-		Wprintf("Cannot resolve memory device %x for %lx\n", 
+		Wprintf("Cannot resolve memory device %x for %Lx\n", 
 			handle, addr);
 		return;
 	}
 	if (md->header.length < 
 			offsetof(struct dmi_memdev, manufacturer)) { 
-		Wprintf("Memory device %x for address %lx too short %hu expected %lu\n",
+		Wprintf("Memory device %x for address %Lx too short %hu expected %lu\n",
 			handle, addr, md->header.length, 
 			sizeof(struct dmi_memdev));
 		return;
@@ -316,14 +316,14 @@
 	Wprintf("WARNING: SMBIOS data is often unreliable. Take with a grain of salt!\n");
 }
 
-int dmi_decodeaddr(unsigned long addr) 
+int dmi_decodeaddr(unsigned long long addr) 
 { 
 	int i, found, matching;
 	struct dmi_entry *e, *next;
 	e = entries;
 	found = 0;
 	matching = 0;
-	Wprintf("Resolving address %lx using SMBIOS\n", addr);
+	Wprintf("Resolving address %Lx using SMBIOS\n", addr);
 	for (i = 0; i < numentries; i++, e = next) {
 		if (!check_entry(e, &next))
 			break; 
@@ -357,7 +357,7 @@
 		Wprintf("No DIMMs found in SMBIOS tables\n");
 	else if (!matching) 
 		Wprintf(
-	     "No matching memory address found for %lx in SMBIOS\n",
+	     "No matching memory address found for %Lx in SMBIOS\n",
 	     addr);
 	return matching > 0;
 } 
@@ -373,7 +373,7 @@
 		verbose = atoi(av[2]);
 	if (opendmi() < 0) 
 		exit(1);
-	dmi_decodeaddr(strtoul(av[1], NULL, 0));
+	dmi_decodeaddr(strtoull(av[1], NULL, 0));
 	return 0;
 }
 #endif
diff -ur mcelog-0.7.orig/dmi.h mcelog-0.7/dmi.h
--- mcelog-0.7.orig/dmi.h	2006-05-03 02:55:54.000000000 -0400
+++ mcelog-0.7/dmi.h	2007-08-10 02:15:52.000000000 -0400
@@ -1,2 +1,2 @@
 int opendmi(void);
-int dmi_decodeaddr(unsigned long addr);
+int dmi_decodeaddr(unsigned long long addr);
diff -ur mcelog-0.7.orig/mcelog.c mcelog-0.7/mcelog.c
--- mcelog-0.7.orig/mcelog.c	2007-08-10 02:19:41.000000000 -0400
+++ mcelog-0.7/mcelog.c	2007-08-10 02:11:40.000000000 -0400
@@ -73,7 +73,7 @@
 	}
 } 
 
-void resolveaddr(unsigned long addr)
+void resolveaddr(unsigned long long addr)
 {
 	if (addr && do_dmi)
 		dmi_decodeaddr(addr);
Only in mcelog-0.7: mcelog.o
Only in mcelog-0.7: p4.o

Reply via email to