It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter). At the same time refactor
the NULL comparison.
This patch has no effect on runtime behavior.
Signed-off-by: Erick Archer <[email protected]>
---
drivers/iio/industrialio-event.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 910c1f14abd5..b99bfeff7d37 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -572,8 +572,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
iio_check_for_dynamic_events(indio_dev)))
return 0;
- ev_int = kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
- if (ev_int == NULL)
+ ev_int = kzalloc(sizeof(*ev_int), GFP_KERNEL);
+ if (!ev_int)
return -ENOMEM;
iio_dev_opaque->event_interface = ev_int;
--
2.25.1
On Sun, 2 Jun 2024 19:23:54 +0200
Erick Archer <[email protected]> wrote:
> It is preferred to use sizeof(*pointer) instead of sizeof(type)
> due to the type of the variable can change and one needs not
> change the former (unlike the latter). At the same time refactor
> the NULL comparison.
>
> This patch has no effect on runtime behavior.
>
> Signed-off-by: Erick Archer <[email protected]>
Applied.
> ---
> drivers/iio/industrialio-event.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
> index 910c1f14abd5..b99bfeff7d37 100644
> --- a/drivers/iio/industrialio-event.c
> +++ b/drivers/iio/industrialio-event.c
> @@ -572,8 +572,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
> iio_check_for_dynamic_events(indio_dev)))
> return 0;
>
> - ev_int = kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
> - if (ev_int == NULL)
> + ev_int = kzalloc(sizeof(*ev_int), GFP_KERNEL);
> + if (!ev_int)
> return -ENOMEM;
>
> iio_dev_opaque->event_interface = ev_int;