2022-11-17 13:36:30

by Umang Jain

[permalink] [raw]
Subject: [PATCH 0/2] vc04_services: vchiq-mmal: Drop bool usage

Simple fixes to drop bool usage from vchiq-mmal.
Individual patches contains details.

Dave Stevenson (1):
staging: vc04_services: mmal-vchiq: Do not assign bool to u32

Umang Jain (1):
staging: vc04_services: mmal-common: Do not use bool in structures

drivers/staging/vc04_services/vchiq-mmal/mmal-common.h | 6 +++---
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

--
2.38.1



2022-11-17 13:59:06

by Umang Jain

[permalink] [raw]
Subject: [PATCH 1/2] staging: vc04_services: mmal-vchiq: Do not assign bool to u32

From: Dave Stevenson <[email protected]>

struct vchiq_mmal_component.enabled is a u32 type. Do not assign
it a bool.

Fixes: 640e77466e69 ("staging: mmal-vchiq: Avoid use of bool in structures")
Signed-off-by: Dave Stevenson <[email protected]>
Signed-off-by: Umang Jain <[email protected]>
---
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
index cb921c94996a..17f8ceda87ca 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1773,7 +1773,7 @@ int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,

ret = enable_component(instance, component);
if (ret == 0)
- component->enabled = true;
+ component->enabled = 1;

mutex_unlock(&instance->vchiq_mutex);

--
2.38.1


2022-11-17 14:00:50

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/2] staging: vc04_services: mmal-vchiq: Do not assign bool to u32

On Thu, Nov 17, 2022 at 06:29:52PM +0530, Umang Jain wrote:
> From: Dave Stevenson <[email protected]>
>
> struct vchiq_mmal_component.enabled is a u32 type. Do not assign
> it a bool.
>
> Fixes: 640e77466e69 ("staging: mmal-vchiq: Avoid use of bool in structures")
> Signed-off-by: Dave Stevenson <[email protected]>
> Signed-off-by: Umang Jain <[email protected]>
> ---
> drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> index cb921c94996a..17f8ceda87ca 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> @@ -1773,7 +1773,7 @@ int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
>
> ret = enable_component(instance, component);
> if (ret == 0)
> - component->enabled = true;
> + component->enabled = 1;

Why not make enabled a bool instead?

thanks,

greg k-h

2022-11-17 14:01:21

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/2] staging: vc04_services: mmal-vchiq: Do not assign bool to u32

On Thu, Nov 17, 2022 at 06:29:52PM +0530, Umang Jain wrote:
> From: Dave Stevenson <[email protected]>
>
> struct vchiq_mmal_component.enabled is a u32 type. Do not assign
> it a bool.

It's not a u32 type so this is wrong.

u32 enabled:1;

But also "true" is better than "1" in terms of a human reading the code.

Perhaps this is from a static checker? I am also the author of a checker
tool so I know how stupid they can be. When the checker says something
dumb, then the correct response is to be be briefly amused and not to
slavishly obey it.

regards,
dan


2022-11-17 14:02:07

by Umang Jain

[permalink] [raw]
Subject: [PATCH 2/2] staging: vc04_services: mmal-common: Do not use bool in structures

Do not use bool in structures, it already gets flagged by checkpatch:

"Avoid using bool structure members because of possible alignment issues"

Hence, modify struct mmal_fmt.remove_padding to use u32. No change in
assignments as 0/1 are already being used with mmal_fmt.remove_padding.

Signed-off-by: Umang Jain <[email protected]>
---
drivers/staging/vc04_services/vchiq-mmal/mmal-common.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
index b33129403a30..fd02440f41b2 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
@@ -32,9 +32,9 @@ struct mmal_fmt {
int depth;
u32 mmal_component; /* MMAL component index to be used to encode */
u32 ybbp; /* depth of first Y plane for planar formats */
- bool remove_padding; /* Does the GPU have to remove padding,
- * or can we do hide padding via bytesperline.
- */
+ u32 remove_padding; /* Does the GPU have to remove padding,
+ * or can we do hide padding via bytesperline.
+ */
};

/* buffer for one video frame */
--
2.38.1


2022-11-17 14:05:16

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 2/2] staging: vc04_services: mmal-common: Do not use bool in structures

On Thu, Nov 17, 2022 at 06:29:53PM +0530, Umang Jain wrote:
> Do not use bool in structures, it already gets flagged by checkpatch:
>
> "Avoid using bool structure members because of possible alignment issues"
>

This checkpatch warning was removed almost 4 years ago.

regards,
dan carpenter