Cast through uintptr_t to narrow the buf domain pointer on 32-bit archs

arg2 is an intmax_t, which on 32-bit architectures is 64 bits, wider than a
pointer.  When &bdomain[i] is added to arg2 it widens from uintptr_t to
intmax_t, then gcc whines when it gets cast to a pointer.  Casting through
uintptr_t silences this warning.
This commit is contained in:
jhibbits 2018-03-20 02:01:30 +00:00
parent bfec8330e8
commit 68f6ae368c

View File

@ -435,7 +435,7 @@ sysctl_bufdomain_int(SYSCTL_HANDLER_ARGS)
return (error);
*(int *)arg1 = value;
for (i = 0; i < buf_domains; i++)
*(int *)(((uintptr_t)&bdomain[i]) + arg2) =
*(int *)(uintptr_t)(((uintptr_t)&bdomain[i]) + arg2) =
value / buf_domains;
return (error);
@ -454,7 +454,7 @@ sysctl_bufdomain_long(SYSCTL_HANDLER_ARGS)
return (error);
*(long *)arg1 = value;
for (i = 0; i < buf_domains; i++)
*(long *)(((uintptr_t)&bdomain[i]) + arg2) =
*(long *)(uintptr_t)(((uintptr_t)&bdomain[i]) + arg2) =
value / buf_domains;
return (error);