Message ID | 20220205092015.GA612@kili (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | hwmon: (asus-ec-sensors) fix a typo in asus_ec_probe() | expand |
On Sat, 5 Feb 2022 at 10:20, Dan Carpenter <dan.carpenter@oracle.com> wrote: > > There is no such struct as "asus_ec_sensors", it was supposed to be > "ec_sensors_data". This typo does not affect either build or runtime. Thank you for the fix! Perhaps you could also replace the sizeof argument below with *state to make the compiler check the declaration type? Eugene
On Sat, Feb 05, 2022 at 12:20:15PM +0300, Dan Carpenter wrote: > There is no such struct as "asus_ec_sensors", it was supposed to be > "ec_sensors_data". This typo does not affect either build or runtime. > > Fixes: c4b1687d6897 ("hwmon: (asus-ec-sensors) add driver for ASUS EC") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Applied. Thanks, Guenter > --- > drivers/hwmon/asus-ec-sensors.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c > index 7285334c7d80..cb266ba30c97 100644 > --- a/drivers/hwmon/asus-ec-sensors.c > +++ b/drivers/hwmon/asus-ec-sensors.c > @@ -653,7 +653,7 @@ static int __init configure_sensor_setup(struct device *dev) > > static int __init asus_ec_probe(struct platform_device *pdev) > { > - struct asus_ec_sensors *state; > + struct ec_sensors_data *state; > int status = 0; > > state = devm_kzalloc(&pdev->dev, sizeof(struct ec_sensors_data),
On 2/5/22 01:59, Eugene Shalygin wrote: > On Sat, 5 Feb 2022 at 10:20, Dan Carpenter <dan.carpenter@oracle.com> wrote: >> >> There is no such struct as "asus_ec_sensors", it was supposed to be >> "ec_sensors_data". This typo does not affect either build or runtime. > > Thank you for the fix! Perhaps you could also replace the sizeof > argument below with *state to make the compiler check the declaration > type? > The weirdness is coming from the fact that the probe function is really a shim and all work is done in configure_sensor_setup(). A more conventional implementation would not have that separate function. Changing the above won't change that and on its own adds little value. I applied the patch as-is. Guenter
On Sat, Feb 05, 2022 at 10:59:10AM +0100, Eugene Shalygin wrote: > On Sat, 5 Feb 2022 at 10:20, Dan Carpenter <dan.carpenter@oracle.com> wrote: > > > > There is no such struct as "asus_ec_sensors", it was supposed to be > > "ec_sensors_data". This typo does not affect either build or runtime. > > Thank you for the fix! Perhaps you could also replace the sizeof > argument below with *state to make the compiler check the declaration > type? No one likes resending patches especially for style issues that they didn't introduce. The sizeof() is how I noticed this, because I look at it whenever someone allocates a different size or different type struct from expected. I did want to change it, but it wasn't necessary and I couldn't find a compelling excuse to override the original author's style choices. ;) The kind of bugs where someone allocates the wrong size seldom reach real users. Normally they would show up in your testing. KASan is very good at detecting them. And we have a bunch of static analysis around this issue as well. It would be interesting to do a proper study on this to look at bugs which only changed a sizeof() and see the time since the Fixes tag. regards, dan carpenter
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c index 7285334c7d80..cb266ba30c97 100644 --- a/drivers/hwmon/asus-ec-sensors.c +++ b/drivers/hwmon/asus-ec-sensors.c @@ -653,7 +653,7 @@ static int __init configure_sensor_setup(struct device *dev) static int __init asus_ec_probe(struct platform_device *pdev) { - struct asus_ec_sensors *state; + struct ec_sensors_data *state; int status = 0; state = devm_kzalloc(&pdev->dev, sizeof(struct ec_sensors_data),
There is no such struct as "asus_ec_sensors", it was supposed to be "ec_sensors_data". This typo does not affect either build or runtime. Fixes: c4b1687d6897 ("hwmon: (asus-ec-sensors) add driver for ASUS EC") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/hwmon/asus-ec-sensors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)