[master] 35d1e51 Avoid sign-extension in hexdump
Poul-Henning Kamp
phk at FreeBSD.org
Fri Mar 24 12:02:06 CET 2017
commit 35d1e519ec717f10a1e274423eb1666d7ed965e2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Mar 24 06:58:19 2017 +0000
Avoid sign-extension in hexdump
diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h
index 8ba61c2..ba0fb1c 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -107,8 +107,7 @@ void vtc_fatal(struct vtclog *vl, const char *, ...)
__attribute__((__noreturn__)) __v_printflike(2,3);
void vtc_dump(struct vtclog *vl, int lvl, const char *pfx,
const char *str, int len);
-void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
- const char *str, int len);
+void vtc_hexdump(struct vtclog *, int , const char *, const void *, int );
int vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
const struct suckaddr *sas);
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index 7f31744..df786e8 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -231,17 +231,18 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len)
void
vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
- const char *str, int len)
+ const void *ptr, int len)
{
int nl = 1;
unsigned l;
+ const uint8_t *ss = ptr;
AN(pfx);
GET_VL(vl);
- if (str == NULL)
+ if (ss == NULL)
vtc_leadin(vl, lvl, "%s(null)\n", pfx);
else {
- for (l = 0; l < len; l++, str++) {
+ for (l = 0; l < len; l++, ss++) {
if (l > 512) {
VSB_printf(vl->vsb, "...");
break;
@@ -250,7 +251,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
vtc_leadin(vl, lvl, "%s| ", pfx);
nl = 0;
}
- VSB_printf(vl->vsb, " %02x", *str);
+ VSB_printf(vl->vsb, " %02x", *ss);
if ((l & 0xf) == 0xf) {
VSB_printf(vl->vsb, "\n");
nl = 1;
More information about the varnish-commit
mailing list