Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1547318 > unrolled thread

[PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string

Started byNicolas Iooss <nicolas.iooss_linux@m4x.org>
First post2016-12-26 14:40 +0100
Last post2016-12-28 10:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2016-12-26 14:40 +0100
    Re: [PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte  string Kieran Bingham <kieran@ksquared.org.uk> - 2016-12-28 10:50 +0100

#1547318 — [PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string

FromNicolas Iooss <nicolas.iooss_linux@m4x.org>
Date2016-12-26 14:40 +0100
Subject[PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string
Message-ID<sSDFo-5nj-9@gated-at.bofh.it>
Using %4s to format f->fmt.pix_mp.pixelformat in fdp1_try_fmt() and
fdp1_s_fmt() may lead to more characters being printed (when the byte
following field pixelformat is not zero).

Add ".4" to the format specifier to limit the number of printed
characters to four. The resulting format specifier "%4.4s" is also used
by other media drivers to print pixelformat value.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 drivers/media/platform/rcar_fdp1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
index 674cc1309b43..42f25d241edd 100644
--- a/drivers/media/platform/rcar_fdp1.c
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -1596,7 +1596,7 @@ static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 	else
 		fdp1_try_fmt_capture(ctx, NULL, &f->fmt.pix_mp);
 
-	dprintk(ctx->fdp1, "Try %s format: %4s (0x%08x) %ux%u field %u\n",
+	dprintk(ctx->fdp1, "Try %s format: %4.4s (0x%08x) %ux%u field %u\n",
 		V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
 		(char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
 		f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
@@ -1671,7 +1671,7 @@ static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 
 	fdp1_set_format(ctx, &f->fmt.pix_mp, f->type);
 
-	dprintk(ctx->fdp1, "Set %s format: %4s (0x%08x) %ux%u field %u\n",
+	dprintk(ctx->fdp1, "Set %s format: %4.4s (0x%08x) %ux%u field %u\n",
 		V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
 		(char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
 		f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
-- 
2.11.0

[toc] | [next] | [standalone]


#1547893 — Re: [PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string

FromKieran Bingham <kieran@ksquared.org.uk>
Date2016-12-28 10:50 +0100
SubjectRe: [PATCH 1/1] [media] v4l: rcar_fdp1: use %4.4s to format a 4-byte string
Message-ID<sTj1T-6mQ-1@gated-at.bofh.it>
In reply to#1547318
Hi Nicolas,

Thankyou for the patch

This looks like a good catch,

On 26/12/16 13:31, Nicolas Iooss wrote:
> Using %4s to format f->fmt.pix_mp.pixelformat in fdp1_try_fmt() and
> fdp1_s_fmt() may lead to more characters being printed (when the byte
> following field pixelformat is not zero).
> 
> Add ".4" to the format specifier to limit the number of printed
> characters to four. The resulting format specifier "%4.4s" is also used
> by other media drivers to print pixelformat value.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>

Reviewed-by: Kieran Bingham <kieran@bingham.xyz>

> ---
>  drivers/media/platform/rcar_fdp1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
> index 674cc1309b43..42f25d241edd 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -1596,7 +1596,7 @@ static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  	else
>  		fdp1_try_fmt_capture(ctx, NULL, &f->fmt.pix_mp);
>  
> -	dprintk(ctx->fdp1, "Try %s format: %4s (0x%08x) %ux%u field %u\n",
> +	dprintk(ctx->fdp1, "Try %s format: %4.4s (0x%08x) %ux%u field %u\n",
>  		V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
>  		(char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
>  		f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
> @@ -1671,7 +1671,7 @@ static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  
>  	fdp1_set_format(ctx, &f->fmt.pix_mp, f->type);
>  
> -	dprintk(ctx->fdp1, "Set %s format: %4s (0x%08x) %ux%u field %u\n",
> +	dprintk(ctx->fdp1, "Set %s format: %4.4s (0x%08x) %ux%u field %u\n",
>  		V4L2_TYPE_IS_OUTPUT(f->type) ? "output" : "capture",
>  		(char *)&f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.pixelformat,
>  		f->fmt.pix_mp.width, f->fmt.pix_mp.height, f->fmt.pix_mp.field);
> 

-- 
Regards

Kieran Bingham

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web