Skip to contentSkip to conversation

ehci-dbg: evaluate negative snprintf() retvals in qh_lines()

PATCH New Roel Kluin 1 participant 1 message Apr 17, 2008

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ehci-dbg: evaluate negative snprintf() retvals in qh_lines()

Only when signed, a snprintf() retval below zero can be evaluated.

---

drivers/usb/host/ehci-dbg.c +3 -4
index 64ebfc5..25a98c1 100644
@@ -394,7 +394,7 @@ static void qh_lines (
 	u32			hw_curr;
 	struct list_head	*entry;
 	struct ehci_qtd		*td;
-	unsigned		temp;
+	int			temp;
 	unsigned		size = *sizep;
 	char			*next = *nextp;
 	char			mark;
@@ -459,9 +459,9 @@ static void qh_lines (
 		else if (size < temp)
 			temp = size;
 		size -= temp;
-		next += temp;
 		if (temp == size)
 			goto done;
+		next += temp;
 	}
 
 	temp = snprintf (next, size, "\n");
@@ -470,11 +470,10 @@ static void qh_lines (
 	else if (size < temp)
 		temp = size;
 	size -= temp;
-	next += temp;
 
 done:
 	*sizep = size;
-	*nextp = next;
+	*nextp = next + temp;
 }
 
 static ssize_t fill_async_buffer(struct debug_buffer *buf)