* [PATCH] ftrace: '< 0' test on unsigned
@ 2009-03-01 20:55 Roel Kluin
2009-03-01 21:14 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-03-01 20:55 UTC (permalink / raw)
To: Steven Rostedt; +Cc: lkml, Andrew Morton
or should this be fixed, with
if (!cnt || cnt > DEFINE)
if so, what should DEFINE be?
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@gmail.com>
---
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);
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ftrace: '< 0' test on unsigned
2009-03-01 20:55 [PATCH] ftrace: '< 0' test on unsigned Roel Kluin
@ 2009-03-01 21:14 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2009-03-01 21:14 UTC (permalink / raw)
To: Roel Kluin; +Cc: lkml, Andrew Morton
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@gmail.com>
> ---
> 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);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-01 21:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01 20:55 [PATCH] ftrace: '< 0' test on unsigned Roel Kluin
2009-03-01 21:14 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox