Re: [PATCH] ftrace: '< 0' test on unsigned

From: Steven Rostedt
Date: Sun Mar 01 2009 - 16:14:42 EST



On Sun, 1 Mar 2009, Roel Kluin wrote:

> or should this be fixed, with
>
> if (!cnt || cnt > DEFINE)
>
> if so, what should DEFINE be?

Hi Roel,

Thanks, but I already put in the fix for this. Since Andrew pointed out
that cnt was unsigned in my "cut and paste" from this function. I went
back and fixed it. There should be no DEFINE. cnt can never be less than
zero, so simply checking for (!cnt) is sufficient.

-- Steve


>
> This patch wasn't tested in any way.
> ------------------------------>8-------------8<---------------------------------
> cnt is unsigned, so the '< 0' test won't work.
>
> Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
> ---
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index fdf913d..6dab415 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -1129,7 +1129,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
> size_t read = 0;
> ssize_t ret;
>
> - if (!cnt || cnt < 0)
> + if (!cnt || (ssize_t)cnt < 0)
> return 0;
>
> mutex_lock(&ftrace_regex_lock);
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/