Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: event: use sizeof(*pointer) instead of sizeof(type)
@ 2024-06-02 17:23 Erick Archer
  2024-06-08 14:16 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Erick Archer @ 2024-06-02 17:23 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Kees Cook,
	Gustavo A. R. Silva, Justin Stitt
  Cc: Erick Archer, linux-iio, linux-kernel, linux-hardening

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 <erick.archer@outlook.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: event: use sizeof(*pointer) instead of sizeof(type)
  2024-06-02 17:23 [PATCH] iio: event: use sizeof(*pointer) instead of sizeof(type) Erick Archer
@ 2024-06-08 14:16 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-06-08 14:16 UTC (permalink / raw)
  To: Erick Archer
  Cc: Lars-Peter Clausen, Kees Cook, Gustavo A. R. Silva, Justin Stitt,
	linux-iio, linux-kernel, linux-hardening

On Sun,  2 Jun 2024 19:23:54 +0200
Erick Archer <erick.archer@outlook.com> 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 <erick.archer@outlook.com>

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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-08 14:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02 17:23 [PATCH] iio: event: use sizeof(*pointer) instead of sizeof(type) Erick Archer
2024-06-08 14:16 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox