diff --git a/src/win/udp.c b/src/win/udp.c index 1c4977af968..33407a89460 100644 --- a/src/win/udp.c +++ b/src/win/udp.c @@ -752,6 +752,9 @@ int uv__udp_set_source_membership6(uv_udp_t* handle, int optname; int err; + STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr)); + STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr)); + if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) return UV_EINVAL; @@ -774,8 +777,6 @@ int uv__udp_set_source_membership6(uv_udp_t* handle, mreq.gsr_interface = 0; } - STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr)); - STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr)); memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr)); memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr)); diff --git a/src/win/util.c b/src/win/util.c index c63cdde3da3..8acdbd7c21f 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -492,6 +492,8 @@ uint64_t uv_hrtime(void) { uint64_t uv__hrtime(unsigned int scale) { LARGE_INTEGER counter; + double scaled_freq; + double result; assert(hrtime_frequency_ != 0); assert(scale != 0); @@ -504,8 +506,8 @@ uint64_t uv__hrtime(unsigned int scale) { * performance counter interval, integer math could cause this computation * to overflow. Therefore we resort to floating point math. */ - double scaled_freq = (double)hrtime_frequency_ / scale; - double result = (double) counter.QuadPart / scaled_freq; + scaled_freq = (double) hrtime_frequency_ / scale; + result = (double) counter.QuadPart / scaled_freq; return (uint64_t) result; }