[master] 931ead585 Slight polish

Poul-Henning Kamp phk at FreeBSD.org
Wed Aug 22 07:12:10 UTC 2018


commit 931ead585eaedfc4916e1d5e0aebdc4f47d13f2f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Aug 22 07:11:46 2018 +0000

    Slight polish

diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c
index e17dd8960..dfdbb3e9e 100644
--- a/lib/libvmod_blob/hex.c
+++ b/lib/libvmod_blob/hex.c
@@ -109,7 +109,7 @@ hex_decode(const enum encoding dec, char *restrict const buf,
 	char *dest = buf;
 	const char *b;
 	unsigned char extranib = 0;
-	ssize_t len = 0;
+	size_t len = 0;
 
 	AN(buf);
 	AN(strings);
@@ -123,25 +123,19 @@ hex_decode(const enum encoding dec, char *restrict const buf,
 		b = s;
 		while (*s) {
 			if (!isxdigit(*s++)) {
-				len = -1;
-				break;
+				errno = EINVAL;
+				return (-1);
 			}
 		}
-		if (len == -1)
-			break;
 		len += s - b;
 	}
 
 	if (len == 0)
 		return 0;
-	if (len == -1) {
-		errno = EINVAL;
-		return -1;
-	}
 	if (n != -1 && len > n)
 		len = n;
 
-	if ((len+1) >> 1 > buflen) {
+	if (((len+1) >> 1) > buflen) {
 		errno = ENOMEM;
 		return -1;
 	}


More information about the varnish-commit mailing list