All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: mchehab@redhat.com, video4linux-list@redhat.com,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] DVB: negative internal->sub_range won't get noticed
Date: Mon, 26 Jan 2009 22:40:39 -0800	[thread overview]
Message-ID: <20090126224039.e43186e1.akpm@linux-foundation.org> (raw)
In-Reply-To: <4973BCD3.6080803@gmail.com>

On Mon, 19 Jan 2009 00:35:47 +0100 Roel Kluin <roel.kluin@gmail.com> wrote:

> internal->sub_range is unsigned, a negative won't get noticed.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
> index 83dc7e1..2ea32da 100644
> --- a/drivers/media/dvb/frontends/stb0899_algo.c
> +++ b/drivers/media/dvb/frontends/stb0899_algo.c
> @@ -464,13 +464,14 @@ static void next_sub_range(struct stb0899_state *state)
>  
>  	if (internal->sub_dir > 0) {
>  		old_sub_range = internal->sub_range;
> -		internal->sub_range = MIN((internal->srch_range / 2) -
> +		if (internal->tuner_offst + internal->sub_range / 2 >=
> +				internal->srch_range / 2)
> +			internal->sub_range = 0;
> +		else
> +			internal->sub_range = MIN((internal->srch_range / 2) -
>  					  (internal->tuner_offst + internal->sub_range / 2),
>  					   internal->sub_range);
>  
> -		if (internal->sub_range < 0)
> -			internal->sub_range = 0;
> -
>  		internal->tuner_offst += (old_sub_range + internal->sub_range) / 2;
>  	}

I hope someone understands that function :(

Do we actually need that test at all?  Perhaps it has never triggered? 
Perhaps values in the 0x80000000 - 0xffffffff are actually OK?

This driver has managed to get itself a secret private version of the
min(), max() and abs() macros.  They're buggy - they reference their
argument multiple times.  The driver should be converted to use the
kernel.h versions.


WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: video4linux-list@redhat.com, mchehab@redhat.com,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] DVB: negative internal->sub_range won't get noticed
Date: Mon, 26 Jan 2009 22:40:39 -0800	[thread overview]
Message-ID: <20090126224039.e43186e1.akpm@linux-foundation.org> (raw)
In-Reply-To: <4973BCD3.6080803@gmail.com>

On Mon, 19 Jan 2009 00:35:47 +0100 Roel Kluin <roel.kluin@gmail.com> wrote:

> internal->sub_range is unsigned, a negative won't get noticed.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
> index 83dc7e1..2ea32da 100644
> --- a/drivers/media/dvb/frontends/stb0899_algo.c
> +++ b/drivers/media/dvb/frontends/stb0899_algo.c
> @@ -464,13 +464,14 @@ static void next_sub_range(struct stb0899_state *state)
>  
>  	if (internal->sub_dir > 0) {
>  		old_sub_range = internal->sub_range;
> -		internal->sub_range = MIN((internal->srch_range / 2) -
> +		if (internal->tuner_offst + internal->sub_range / 2 >=
> +				internal->srch_range / 2)
> +			internal->sub_range = 0;
> +		else
> +			internal->sub_range = MIN((internal->srch_range / 2) -
>  					  (internal->tuner_offst + internal->sub_range / 2),
>  					   internal->sub_range);
>  
> -		if (internal->sub_range < 0)
> -			internal->sub_range = 0;
> -
>  		internal->tuner_offst += (old_sub_range + internal->sub_range) / 2;
>  	}

I hope someone understands that function :(

Do we actually need that test at all?  Perhaps it has never triggered? 
Perhaps values in the 0x80000000 - 0xffffffff are actually OK?

This driver has managed to get itself a secret private version of the
min(), max() and abs() macros.  They're buggy - they reference their
argument multiple times.  The driver should be converted to use the
kernel.h versions.

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  reply	other threads:[~2009-01-27  6:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 23:35 [PATCH] DVB: negative internal->sub_range won't get noticed Roel Kluin
2009-01-27  6:40 ` Andrew Morton [this message]
2009-01-27  6:40   ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2009-01-27 18:40 Manu Abraham
2009-01-18 23:31 Roel Kluin

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=20090126224039.e43186e1.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=roel.kluin@gmail.com \
    --cc=video4linux-list@redhat.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.