Skip to contentSkip to conversation

ftrace: '< 0' test on unsigned

PATCH In review Roel Kluin 2 participants 2 messages Mar 1, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ftrace: '< 0' test on unsigned

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.

---

kernel/trace/ftrace.c +1 -1
index fdf913d..6dab415 100644
@@ -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);
maintainer
#1 lore raw
Quoted 5 lines · Roel Kluin

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

Quoted 22 lines

This patch wasn't tested in any way. ------------------------------>8-------------8<--------------------------------- cnt is unsigned, so the '< 0' test won't work.

---

kernel/trace/ftrace.c +1 -1
index fdf913d..6dab415 100644
@@ -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);