diff mbox

SQUASHME: blkmapd: fix pretty_sig short sig endianess agnosticity

Message ID 1291300542-14378-1-git-send-email-bhalevy@panasas.com (mailing list archive)
State RFC, archived
Delegated to: Trond Myklebust
Headers show

Commit Message

Benny Halevy Dec. 2, 2010, 2:35 p.m. UTC
None
diff mbox

Patch

diff --git a/utils/blkmapd/device-process.c b/utils/blkmapd/device-process.c
index 0c5060b..0584bf9 100644
--- a/utils/blkmapd/device-process.c
+++ b/utils/blkmapd/device-process.c
@@ -52,11 +52,17 @@ 
 static char *pretty_sig(char *sig, uint32_t siglen)
 {
 	static char rs[100];
-	unsigned long i = 0;
+	uint64_t sigval;
 
-	if (siglen <= sizeof i) {
-		memcpy(&i, sig, siglen);
-		sprintf(rs, "0x%0lx", i);
+	if (siglen <= sizeof(sigval)) {
+		int i;
+
+		sigval = 0;
+		for (i = 0; i < siglen; i++) {
+			sigval <<= 8;
+			sigval += ((unsigned char *)sig)[i];
+		}
+		sprintf(rs, "0x%0llx", sigval);
 	} else {
 		if (siglen > sizeof rs - 1)
 			siglen = sizeof rs - 1;