staging: media: sunxi: Change return type of cedrus_find_format()
PATCH 1/2 staging: media: sunxi: Change return type of cedrus_find_format()
Change return type of cedrus_find_format to bool as it is only called once, by a function whose return value is bool, and the return value of cedrus_find_format is returned as-is at the call-site.
Issue found with Coccinelle.
--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_video.c +4 -7
@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static struct cedrus_format *cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_find_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;
@@ -70,13 +70,10 @@ static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions,if (fmt->pixelformat == pixelformat && (fmt->directions & directions) !=0 ) -break ; +return true; } -if (i ==CEDRUS_FORMATS_COUNT ) -return NULL ; - -return &cedrus_formats[i]; +return false; } static bool cedrus_check_format(u32 pixelformat, u32 directions,
Signature · 1 line
2.19.1
PATCH 2/2 staging: media: sunxi: Replace function cedrus_check_format()
Remove function cedrus_check_format as all it does is call cedrus_find_format.
Rename cedrus_find_format to cedrus_check_format to maintain compatibility with call sites.
Issue found with Coccinelle.
--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_video.c +2 -8
@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static bool cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_check_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;
@@ -76,12 +76,6 @@ static bool cedrus_find_format(u32 pixelformat, u32 directions,return false; } -static bool cedrus_check_format (u32 pixelformat,u32 directions, -unsigned int capabilities) -{ -return cedrus_find_format (pixelformat, directions, capabilities); -} -static void cedrus_prepare_format (struct v4l2_pix_format *pix_fmt) {unsigned int width = pix_fmt->width;
Signature · 1 line
2.19.1
Re: [PATCH 2/2] staging: media: sunxi: Replace function cedrus_check_format()
Hi,
Quoted 5 lines · Nishka Dasgupta
Remove function
cedrus_check_formatas all it does is callcedrus_find_format.
Renamecedrus_find_formattocedrus_check_formatto maintain compatibility with call sites.
Issue found with Coccinelle.
Maybe we could have a !! or a bool cast to make coccinelle happy here?
Cheers,
Paul
Quoted 36 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)drivers/staging/media/sunxi/cedrus/cedrus_video.c +2
-8@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static bool cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_check_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;@@ -76,12 +76,6 @@ static bool cedrus_find_format(u32 pixelformat, u32 directions,return false; } -static bool cedrus_check_format (u32 pixelformat,u32 directions, -unsigned int capabilities) -{ -return cedrus_find_format (pixelformat, directions, capabilities); -} -static void cedrus_prepare_format (struct v4l2_pix_format *pix_fmt) {unsigned int width = pix_fmt->width;Signature · 1 line
2.19.1
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH 2/2] staging: media: sunxi: Replace function cedrus_check_format()
Quoted 10 lines · Paul Kocialkowski
Hi,
Quoted 5 lines · Nishka Dasgupta
Remove function
cedrus_check_formatas all it does is callcedrus_find_format.
Renamecedrus_find_formattocedrus_check_formatto maintain compatibility with call sites.
Issue found with Coccinelle.Maybe we could have a !! or a bool cast to make coccinelle happy here?
Coccinelle didn't flag the type mismatch, just the single-line functions. I could add the bool cast then?
Thanking you,
Nishka
Quoted 41 lines
Cheers,
Paul
Quoted 36 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)drivers/staging/media/sunxi/cedrus/cedrus_video.c +2
-8@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static bool cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_check_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;@@ -76,12 +76,6 @@ static bool cedrus_find_format(u32 pixelformat, u32 directions,return false; } -static bool cedrus_check_format (u32 pixelformat,u32 directions, -unsigned int capabilities) -{ -return cedrus_find_format (pixelformat, directions, capabilities); -} -static void cedrus_prepare_format (struct v4l2_pix_format *pix_fmt) {unsigned int width = pix_fmt->width;Signature · 1 line
2.19.1
Re: [PATCH 2/2] staging: media: sunxi: Replace function cedrus_check_format()
Hi,
Quoted 10 lines · Nishka Dasgupta
Quoted 9 lines · Paul Kocialkowski
Hi,
Quoted 5 lines · Nishka Dasgupta
Remove function
cedrus_check_formatas all it does is callcedrus_find_format.
Renamecedrus_find_formattocedrus_check_formatto maintain compatibility with call sites.
Issue found with Coccinelle.
Quoted 4 lines
Quoted 1 line
Maybe we could have a !! or a bool cast to make coccinelle happy here?
Coccinelle didn't flag the type mismatch, just the single-line functions. I could add the bool cast then?
Looks like I failed to follow-up on this in due time, sorry.
Yes a bool cast would definitely be welcome :)
Cheers,
Paul
Quoted 43 lines
Thanking you,
NishkaQuoted 39 lines
Cheers,
Paul
Quoted 34 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)drivers/staging/media/sunxi/cedrus/cedrus_video.c +2
-8@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static bool cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_check_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;@@ -76,12 +76,6 @@ static bool cedrus_find_format(u32 pixelformat, u32 directions,return false; } -static bool cedrus_check_format (u32 pixelformat,u32 directions, -unsigned int capabilities) -{ -return cedrus_find_format (pixelformat, directions, capabilities); -} -static void cedrus_prepare_format (struct v4l2_pix_format *pix_fmt) {unsigned int width = pix_fmt->width;Signature · 1 line
2.19.1
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Hi,
Quoted 4 lines · Nishka Dasgupta
Change return type of
cedrus_find_formatto bool as it is only called once, by a function whose return value is bool, and the return value ofcedrus_find_formatis returned as-is at the call-site.
Issue found with Coccinelle.
The purpose of this function (although definitely under-used at this point), was to return the pointer to the element structure, not to indicate whether the format format is part of the list or not.
In spite of that, this change reduces the use case for the function, so I do not think it is beneficial, sorry.
Cheers,
Paul
Quoted 39 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/staging/media/sunxi/cedrus/cedrus_video.c +4
-7@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static struct cedrus_format *cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_find_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;@@ -70,13 +70,10 @@ static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions,if (fmt->pixelformat == pixelformat && (fmt->directions & directions) !=0 ) -break ; +return true; } -if (i ==CEDRUS_FORMATS_COUNT ) -return NULL ; - -return &cedrus_formats[i]; +return false; } static bool cedrus_check_format(u32 pixelformat, u32 directions,Signature · 1 line
2.19.1
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 8 lines · Paul Kocialkowski
Hi,
Quoted 4 lines · Nishka Dasgupta
Change return type of
cedrus_find_formatto bool as it is only called once, by a function whose return value is bool, and the return value ofcedrus_find_formatis returned as-is at the call-site.
Issue found with Coccinelle.
Quoted 6 lines
The purpose of this function (although definitely under-used at this point), was to return the pointer to the element structure, not to indicate whether the format format is part of the list or not.
In spite of that, this change reduces the use case for the function, so I do not think it is beneficial, sorry.
Okay, thank you for the clarification.
Nishka
Quoted 44 lines
Cheers,
Paul
Quoted 39 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/staging/media/sunxi/cedrus/cedrus_video.c +4
-7@@ -55,8 +55,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static struct cedrus_format *cedrus_find_format (u32 pixelformat,u32 directions, -unsigned int capabilities) +static bool cedrus_find_format (u32 pixelformat,u32 directions, +unsigned int capabilities) {struct cedrus_format *fmt;unsigned int i;@@ -70,13 +70,10 @@ static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions,if (fmt->pixelformat == pixelformat && (fmt->directions & directions) !=0 ) -break ; +return true; } -if (i ==CEDRUS_FORMATS_COUNT ) -return NULL ; - -return &cedrus_formats[i]; +return false; } static bool cedrus_check_format(u32 pixelformat, u32 directions,Signature · 1 line
2.19.1