On 23.08.2023 15:57, Jason Andryuk wrote: > On Wed, Aug 23, 2023 at 9:47 AM Jan Beulich <[email protected]> wrote: >> @@ -316,6 +277,22 @@ int xc_get_cpufreq_para(xc_interface *xc >> BUILD_BUG_ON(sizeof(((struct xc_get_cpufreq_para *)0)->u) != >> sizeof(((struct xen_get_cpufreq_para *)0)->u)); > > This check... > >> + /* Sanity check layout of the union subject to memcpy() below. */ >> + BUILD_BUG_ON(sizeof(user_para->u) != sizeof(sys_para->u)); > > And this check are the same? Your newer one is nicer, so maybe drop the > first?
Oh, indeed. Will do (and Jürgen, I'll assume this won't invalidate your R-b). >> +#define CHK_FIELD(fld) \ >> + BUILD_BUG_ON(offsetof(typeof(user_para->u), fld) != \ >> + offsetof(typeof(sys_para->u), fld)) >> + >> + CHK_FIELD(s.scaling_cur_freq); >> + CHK_FIELD(s.scaling_governor); >> + CHK_FIELD(s.scaling_max_freq); >> + CHK_FIELD(s.scaling_min_freq); >> + CHK_FIELD(s.u.userspace); >> + CHK_FIELD(s.u.ondemand); >> + CHK_FIELD(cppc_para); >> + >> +#undef CHK_FIELD >> + >> memcpy(&user_para->u, &sys_para->u, sizeof(sys_para->u)); >> } >> > > Reviewed-by: Jason Andryuk <[email protected]> Thanks. Jan
