Skip to contentSkip to conversation

ftrace: remove redundant test on nsigned

PATCH In review Roel Kluin 3 participants 4 messages Jun 22, 2009 – Jun 23, 2009

Subsystems (4)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ftrace: remove redundant test on nsigned

Unsigned `cnt' cannot be less than 0.

---
Or should it be `if (!cnt || cnt > MAX)' and what should MAX be then?

kernel/trace/trace_events.c +1 -1
index aa08be6..b83f030 100644
@@ -204,7 +204,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
 	char *buf;
 	char ch;
 
-	if (!cnt || cnt < 0)
+	if (!cnt)
 		return 0;
 
 	ret = tracing_update_buffers();
author
#1 lore raw

PATCH 1/1 spufs: remove redundant test on unsigned

Unsigned `len' cannot be less than 0.

---
Or should it be `if (!buf || len > MAX)' and what should MAX be then?

arch/powerpc/platforms/cell/spufs/sputrace.c +1 -1
index d0b1f3f..8f799ee 100644
@@ -73,7 +73,7 @@ static ssize_t sputrace_read(struct file *file, char __user *buf,
 {
 	int error = 0, cnt = 0;
 
-	if (!buf || len < 0)
+	if (!buf)
 		return -EINVAL;
 
 	while (cnt < len) {
#3 lore raw
In reply to Roel Kluin
Quoted 2 lines · Roel Kluin

Unsigned `cnt' cannot be less than 0.

The patch is fine, but there's a typo in the title s/nsigned/unsigned

Quoted 4 lines

---
Or should it be `if (!cnt || cnt > MAX)' and what should MAX be then?

No, note there is another check:

	if (cnt > EVENT_BUF_SIZE)
		cnt = EVENT_BUF_SIZE;
Quoted 14 lines
kernel/trace/trace_events.c +1 -2
index aa08be6..b83f030 100644
@@ -204,7 +204,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
 	char *buf;
 	char ch;
 
-	if (!cnt || cnt < 0)
+	if (!cnt)
 		return 0;
 
 	ret = tracing_update_buffers();
--