Commit bd7505c0 authored by Nils Goroll's avatar Nils Goroll

assert that VCL_INT is sufficiently large

parent d9060fc7
......@@ -58,9 +58,9 @@ struct vmod_shard_shard {
};
/*
* our key is a uint32_t, but VCL_INT is a (signed) long and we don't have a
* VCL_UINT - so we cast back and forth assuming that compilers agree that using
* a longer machine type as a container is safe
* our key is a uint32_t, but VCL_INT is a (signed) long. We cast back and
* forth, asserting in vmod_shard__init() that VCL_INT is a large enough
* container
*/
VCL_INT __match_proto__(td_shard_key)
vmod_key(VRT_CTX, VCL_STRING s, VCL_ENUM alg_s)
......@@ -78,6 +78,15 @@ vmod_shard__init(VRT_CTX, struct vmod_shard_shard **vshardp,
const char *vcl_name)
{
struct vmod_shard_shard *vshard;
VCL_INT t1;
uint32_t t2a, t2b;
/* see vmod_key comment */
assert(sizeof(VCL_INT) >= sizeof(uint32_t));
t2a = UINT32_MAX;
t1 = (VCL_INT)t2a;
t2b = (uint32_t)t1;
assert(t2a == t2b);
(void) ctx;
AN(vshardp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment