From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, mjpeg-users@lists.sourceforge.net,
linux-media@vger.kernel.org
Subject: Re: [PATCH 07/25] drivers/media: Use static const char arrays
Date: Mon, 13 Sep 2010 18:50:13 -0300 [thread overview]
Message-ID: <4C8E9C95.8070201@infradead.org> (raw)
In-Reply-To: <6b7055a2e53510e8903828a53cad300a7d5bb912.1284406638.git.joe@perches.com>
Em 13-09-2010 16:47, Joe Perches escreveu:
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/media/video/zoran/zoran_device.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c
> index 6f846ab..ea8a1e9 100644
> --- a/drivers/media/video/zoran/zoran_device.c
> +++ b/drivers/media/video/zoran/zoran_device.c
> @@ -1470,8 +1470,7 @@ zoran_irq (int irq,
> (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
> zr->codec_mode == BUZ_MODE_MOTION_COMPRESS)) {
> if (zr36067_debug > 1 && (!zr->frame_num || zr->JPEG_error)) {
> - char sc[] = "0000";
> - char sv[5];
> + char sv[sizeof("0000")];
> int i;
>
> printk(KERN_INFO
> @@ -1481,7 +1480,7 @@ zoran_irq (int irq,
> zr->jpg_settings.field_per_buff,
> zr->JPEG_missed);
>
> - strcpy(sv, sc);
> + strcpy(sv, "0000");
> for (i = 0; i < 4; i++) {
> if (le32_to_cpu(zr->stat_com[i]) & 1)
> sv[i] = '1';
This looks ugly to me, as someone may change the string at strcpy and not change at sizeof.
Could you please try to work on a better alternative?
The cleaner way seems to be to rewrite it as:
#define BUZ_MODE_STAT 4
char sv[BUZ_MODE_STAT + 1];
...
for (i = 0; i < BUZ_MODE_STAT; i++)
sv[i] = (le32_to_cpu(zr->stat_com[i]) & 1)? '1' : '0';
Cheers,
Mauro
next prev parent reply other threads:[~2010-09-13 21:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1284406638.git.joe@perches.com>
2010-09-13 19:47 ` [PATCH 07/25] drivers/media: Use static const char arrays Joe Perches
2010-09-13 21:50 ` Mauro Carvalho Chehab [this message]
2010-09-13 22:07 ` [PATCH 07/25] drivers/media/video/zoran: Don't use initialized char array Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C8E9C95.8070201@infradead.org \
--to=mchehab@infradead.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mjpeg-users@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox