V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition?
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.
Hello Roel,
Quoted 4 lines · Roel Kluin
vi
drivers/media/dvb/dvb-core/dvb_demux.c+214and note:
Quoted 8 lines
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.
Quoted 6 lines
} 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