From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
"Igor M. Liplianin" <liplianin@me.by>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2] [media] ds3000: off by one in ds3000_read_snr()
Date: Wed, 18 Jan 2012 17:06:46 +0000 [thread overview]
Message-ID: <4F16FC26.80306@bfs.de> (raw)
In-Reply-To: <20120117073021.GB11358@elgon.mountain>
Am 17.01.2012 08:30, schrieb Dan Carpenter:
> This is a static checker patch and I don't have the hardware to test
> this, so please review it carefully. The dvbs2_snr_tab[] array has 80
> elements so when we cap it at 80, that's off by one. I would have
> assumed that the test was wrong but in the lines right before we have
> the same test but use "snr_reading - 1" as the array offset. I've done
> the same thing here.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/media/dvb/frontends/ds3000.c b/drivers/media/dvb/frontends/ds3000.c
> index af65d01..3f5ae0a 100644
> --- a/drivers/media/dvb/frontends/ds3000.c
> +++ b/drivers/media/dvb/frontends/ds3000.c
> @@ -681,7 +681,7 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 *snr)
> snr_reading = dvbs2_noise_reading / tmp;
> if (snr_reading > 80)
> snr_reading = 80;
> - *snr = -(dvbs2_snr_tab[snr_reading] / 1000);
> + *snr = -(dvbs2_snr_tab[snr_reading - 1] / 1000);
> }
> dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__,
> snr_reading, *snr);
hi dan,
perhaps it is more useful to do it in the check above ?
thinking about that why not replace the number (80) with ARRAY_SIZE() ?
re,
wh
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
"Igor M. Liplianin" <liplianin@me.by>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2] [media] ds3000: off by one in ds3000_read_snr()
Date: Wed, 18 Jan 2012 18:06:46 +0100 [thread overview]
Message-ID: <4F16FC26.80306@bfs.de> (raw)
In-Reply-To: <20120117073021.GB11358@elgon.mountain>
Am 17.01.2012 08:30, schrieb Dan Carpenter:
> This is a static checker patch and I don't have the hardware to test
> this, so please review it carefully. The dvbs2_snr_tab[] array has 80
> elements so when we cap it at 80, that's off by one. I would have
> assumed that the test was wrong but in the lines right before we have
> the same test but use "snr_reading - 1" as the array offset. I've done
> the same thing here.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/media/dvb/frontends/ds3000.c b/drivers/media/dvb/frontends/ds3000.c
> index af65d01..3f5ae0a 100644
> --- a/drivers/media/dvb/frontends/ds3000.c
> +++ b/drivers/media/dvb/frontends/ds3000.c
> @@ -681,7 +681,7 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 *snr)
> snr_reading = dvbs2_noise_reading / tmp;
> if (snr_reading > 80)
> snr_reading = 80;
> - *snr = -(dvbs2_snr_tab[snr_reading] / 1000);
> + *snr = -(dvbs2_snr_tab[snr_reading - 1] / 1000);
> }
> dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__,
> snr_reading, *snr);
hi dan,
perhaps it is more useful to do it in the check above ?
thinking about that why not replace the number (80) with ARRAY_SIZE() ?
re,
wh
next prev parent reply other threads:[~2012-01-18 17:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 7:30 [patch 2/2] [media] ds3000: off by one in ds3000_read_snr() Dan Carpenter
2012-01-17 7:30 ` Dan Carpenter
2012-01-18 17:06 ` walter harms [this message]
2012-01-18 17:06 ` walter harms
2012-01-19 9:33 ` Dan Carpenter
2012-01-19 9:33 ` Dan Carpenter
2012-01-19 10:26 ` walter harms
2012-01-19 10:26 ` walter harms
2012-01-19 12:22 ` Dan Carpenter
2012-01-19 12:22 ` Dan Carpenter
2012-01-21 15:58 ` Dan Carpenter
2012-01-21 15:58 ` Dan Carpenter
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=4F16FC26.80306@bfs.de \
--to=wharms@bfs.de \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=liplianin@me.by \
--cc=mchehab@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.