[master] 4502a1b9d VCL_BYTES is a subtype of VCL_INT
Poul-Henning Kamp
phk at FreeBSD.org
Wed May 19 12:29:06 UTC 2021
commit 4502a1b9d21d8fd3e495ed85d640e6c425b8dc4f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed May 19 11:55:52 2021 +0000
VCL_BYTES is a subtype of VCL_INT
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 58308d951..5c4139153 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -431,7 +431,7 @@ void Resolve_Sockaddr(struct vcc *tl, const char *host, const char *defport,
const char **ipv6_ascii, const char **p_ascii, int maxips,
const struct token *t_err, const char *errid);
double vcc_DurationUnit(struct vcc *);
-void vcc_ByteVal(struct vcc *, double *);
+void vcc_ByteVal(struct vcc *, VCL_INT *);
void vcc_Duration(struct vcc *tl, double *);
unsigned vcc_UintVal(struct vcc *tl);
int vcc_IsFlag(struct vcc *tl);
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 3a762a1ee..99f42df66 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -689,7 +689,7 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
const char *ip, *sign;
struct token *t;
struct symbol *sym;
- double d;
+ VCL_INT vi;
sign = "";
*e = NULL;
@@ -805,9 +805,9 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
case CNUM:
assert(fmt != VOID);
if (fmt == BYTES) {
- vcc_ByteVal(tl, &d);
+ vcc_ByteVal(tl, &vi);
ERRCHK(tl);
- e1 = vcc_mk_expr(BYTES, "%.1f", d);
+ e1 = vcc_mk_expr(BYTES, "%ju", (intmax_t)vi);
} else {
t = tl->t;
vcc_NextToken(tl);
diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index 7e4e00a99..3c6ac8c29 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -333,7 +333,7 @@ vcc_Duration(struct vcc *tl, double *d)
/*--------------------------------------------------------------------*/
void
-vcc_ByteVal(struct vcc *tl, double *d)
+vcc_ByteVal(struct vcc *tl, VCL_INT *d)
{
double v, sc;
@@ -355,7 +355,7 @@ vcc_ByteVal(struct vcc *tl, double *d)
return;
}
vcc_NextToken(tl);
- *d = v * sc;
+ *d = (VCL_INT)round((v * sc));
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list