Messages in this thread | | | Subject | Re: [PATCH] divide by 3*sizeof(u32) when computing array_size | From | Philipp Hahn <> | Date | Tue, 13 Jul 2021 08:02:26 +0200 |
| |
Hello,
Disclaimer: I have no idea what 'pwm-stm32' is or does
Am 13.07.21 um 01:19 schrieb Salah Triki: > Divide by 3*sizeof(u32) when computing array_size, since stm32_breakinput > has 3 fields of type u32. ... > --- a/drivers/pwm/pwm-stm32.c > +++ b/drivers/pwm/pwm-stm32.c > @@ -544,7 +544,7 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv, > return -EINVAL; > > priv->num_breakinputs = nb; > - array_size = nb * sizeof(struct stm32_breakinput) / sizeof(u32); > + array_size = nb * sizeof(struct stm32_breakinput) / (3 * sizeof(u32));
Maybe it's too early in the morning for me, but this does not look right:
> struct stm32_breakinput { > u32 index; > u32 level; > u32 filter; > };
then "sizeof(struct stm32_breakinput)" == "(3 * sizeof(u32))", which would simply make "arrray_site := nb" ?
Philipp
| |