diff mbox series

[2/2] media: atomisp: don't use sizeof(NULL)

Message ID d33c9271ed30997eb1774d1a6af997f538ecd888.1706865681.git.hverkuil-cisco@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series media: atomisp: two sparse/smatch fixes | expand

Commit Message

Hans Verkuil Feb. 2, 2024, 9:21 a.m. UTC
Check the size of another pointer instead of NULL. This fixes this
smatch warning:

drivers/staging/media/atomisp/pci/sh_css.c:3609 ia_css_pipe_enqueue_buffer() warn: sizeof(NUMBER)?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/staging/media/atomisp/pci/sh_css.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicolas Dufresne Feb. 9, 2024, 3:59 p.m. UTC | #1
Hi,

Le vendredi 02 février 2024 à 10:21 +0100, Hans Verkuil a écrit :
> Check the size of another pointer instead of NULL. This fixes this
> smatch warning:
> 
> drivers/staging/media/atomisp/pci/sh_css.c:3609 ia_css_pipe_enqueue_buffer() warn: sizeof(NUMBER)?
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/staging/media/atomisp/pci/sh_css.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
> index 1d1fbda75da1..0d2ef96fabce 100644
> --- a/drivers/staging/media/atomisp/pci/sh_css.c
> +++ b/drivers/staging/media/atomisp/pci/sh_css.c
> @@ -3606,7 +3606,7 @@ ia_css_pipe_enqueue_buffer(struct ia_css_pipe *pipe,
>  
>  	assert(pipeline || pipe_id == IA_CSS_PIPE_ID_COPY);
>  
> -	assert(sizeof(NULL) <= sizeof(ddr_buffer.kernel_ptr));
> +	assert(sizeof(pipe) <= sizeof(ddr_buffer.kernel_ptr));

have you considered using a static_assert() instead ? There is no run-time value
involved. Also, I personally think this case would be more readable if you used
"sizeof(void*)", even though un-commonly used in Linux.

With or without any changes:
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

Nicolas

>  	ddr_buffer.kernel_ptr = HOST_ADDRESS(NULL);
>  	ddr_buffer.cookie_ptr = buffer->driver_cookie;
>  	ddr_buffer.timing_data = buffer->timing_data;
diff mbox series

Patch

diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index 1d1fbda75da1..0d2ef96fabce 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -3606,7 +3606,7 @@  ia_css_pipe_enqueue_buffer(struct ia_css_pipe *pipe,
 
 	assert(pipeline || pipe_id == IA_CSS_PIPE_ID_COPY);
 
-	assert(sizeof(NULL) <= sizeof(ddr_buffer.kernel_ptr));
+	assert(sizeof(pipe) <= sizeof(ddr_buffer.kernel_ptr));
 	ddr_buffer.kernel_ptr = HOST_ADDRESS(NULL);
 	ddr_buffer.cookie_ptr = buffer->driver_cookie;
 	ddr_buffer.timing_data = buffer->timing_data;