Skip to contentSkip to conversation

V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition?

DISCUSSION Roel Kluin 2 participants 2 messages Mar 3, 2009 – Mar 4, 2009 Media (V4L/DVB)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

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.

#1 lore raw

Hello Roel,

Quoted 4 lines · Roel Kluin

vi drivers/media/dvb/dvb-core/dvb_demux.c +214

and 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