[master] 84fcb2e Make the compile-time initialized suckaddr emmiting code sizeof(unsigned long long) agnostic.

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 12 21:22:10 CET 2013


commit 84fcb2e8bbd64e33b66a98df9230bbec1006907f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 12 20:21:22 2013 +0000

    Make the compile-time initialized suckaddr emmiting code sizeof(unsigned
    long long) agnostic.

diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index 9a9ed2a..c340cde 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -95,13 +95,13 @@ vcc_regexp(struct vcc *tl)
 static const char *
 vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal)
 {
-	unsigned n = (vsa_suckaddr_len + 7) / 8, len;
+	const int sz = sizeof(unsigned long long);
+	const unsigned n = (vsa_suckaddr_len + sz - 1) / sz;
+	unsigned len;
 	unsigned long long b[n];
 	struct suckaddr *sua;
 	char *p;
 
-	assert(sizeof(unsigned long long) == 8);
-
 	AN(sa);
 	AN(sal);
 
@@ -113,7 +113,7 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal)
 	memcpy(b, sua, vsa_suckaddr_len);
 	free(sua);
 	for (len = 0; len < n; len++)
-		Fh(tl, 0, "%s    0x%016llx", len ? ",\n" : "", b[len]);
+		Fh(tl, 0, "%s    0x%0*llx", len ? ",\n" : "", sz * 2, b[len]);
 	Fh(tl, 0, "\n};\n");
 
 	p = TlAlloc(tl, 40);



More information about the varnish-commit mailing list