Thread (1 message) 1 message, 1 author, 2011-08-07

Re: [patch v2 34/37] add rxe_net_sysfs.c

From: Bart Van Assche <hidden>
Date: 2011-08-07 09:27:48

On Sun, Jul 24, 2011 at 9:43 PM,  [off-list ref] wrote:
+/* Copy argument and remove trailing CR. Return the new length. */
As far as I can see the function below removes a trailing newline
instead of a trailing carriage return ?
+static int sanitize_arg(const char *val, char *intf, int intf_len)
+{
+	int len;
+
+	if (!val)
+		return 0;
+
+	/* Remove newline. */
+	for (len = 0; len < intf_len - 1 && val[len] && val[len] != '\n'; len++)
+		intf[len] = val[len];
+	intf[len] = 0;
+
+	if (len == 0 || (val[len] != 0 && val[len] != '\n'))
+		return 0;
+
+	return len;
+}
Has it been considered to use strchr() to find the first occurrence of
a newline character in "val" ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help