SQUASHME: decorate truncated signatures with "..."
diff mbox

Message ID 1291300808-14568-1-git-send-email-bhalevy@panasas.com
State RFC, archived
Delegated to: Trond Myklebust
Headers show

Commit Message

Benny Halevy Dec. 2, 2010, 2:40 p.m. UTC
None

Patch
diff mbox

diff --git a/utils/blkmapd/device-process.c b/utils/blkmapd/device-process.c
index 0584bf9..ea8b8ec 100644
--- a/utils/blkmapd/device-process.c
+++ b/utils/blkmapd/device-process.c
@@ -64,10 +64,12 @@  static char *pretty_sig(char *sig, uint32_t siglen)
 		}
 		sprintf(rs, "0x%0llx", sigval);
 	} else {
-		if (siglen > sizeof rs - 1)
-			siglen = sizeof rs - 1;
+		if (siglen > sizeof rs - 4) {
+			siglen = sizeof rs - 4;
+			sprintf(&rs[siglen], "...");
+		} else
+			rs[siglen] = '\0';
 		memcpy(rs, sig, siglen);
-		rs[siglen] = '\0';
 	}
 	return rs;
 }