All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Oberritter <obi@linuxtv.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: mchehab@redhat.com, linux-media@vger.kernel.org
Subject: Re: V4L/DVB: dvb_dmx_swfilter_section_copy_dump() assignment or addition?
Date: Wed, 04 Mar 2009 03:41:14 +0100	[thread overview]
Message-ID: <49ADEA4A.4080800@linuxtv.org> (raw)
In-Reply-To: <49ADAB54.5020004@gmail.com>

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

      reply	other threads:[~2009-03-04  2:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=49ADEA4A.4080800@linuxtv.org \
    --to=obi@linuxtv.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=roel.kluin@gmail.com \
    /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.