* V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition?
@ 2009-03-03 22:12 Roel Kluin
2009-03-04 2:41 ` Andreas Oberritter
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-03-03 22:12 UTC (permalink / raw)
To: mchehab; +Cc: linux-media
vi drivers/media/dvb/dvb-core/dvb_demux.c +214
and note:
static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
const u8 *buf, u8 len)
{
...
if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
...
len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
^------------shouldn't this be '+='?
}
if (len <= 0)
return 0;
Also note: len cannot be less than 0 since it's an u8.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition?
2009-03-03 22:12 V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition? Roel Kluin
@ 2009-03-04 2:41 ` Andreas Oberritter
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Oberritter @ 2009-03-04 2:41 UTC (permalink / raw)
To: Roel Kluin; +Cc: mchehab, linux-media
Hello Roel,
Roel Kluin wrote:
> vi drivers/media/dvb/dvb-core/dvb_demux.c +214
>
> and note:
>
> static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
> const u8 *buf, u8 len)
> {
> ...
> if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
> ...
> len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
> ^------------shouldn't this be '+='?
No. Read it like this: If there isn't enough space for 'len' bytes,
then reduce 'len' to the number of bytes available.
> }
>
> if (len <= 0)
> return 0;
>
> Also note: len cannot be less than 0 since it's an u8.
Yes. This function seems to be overcautious in other places, too.
These two checks can probably get removed:
if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0;
if (limit > DMX_MAX_SECFEED_SIZE)
return -1; /* internal error should never happen */
Regards,
Andreas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-04 2:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 22:12 V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition? Roel Kluin
2009-03-04 2:41 ` Andreas Oberritter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox