Thread (34 messages) 34 messages, 6 authors, 2019-01-24

Re: [v4 2/3] LPM config file read option.

From: Mcnamara, John <hidden>
Date: 2017-03-06 13:57:24

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: dev@dpdk.org
Cc: Ananyev, Konstantin <redacted>; Richardson, Bruce
[off-list ref]; Ravi Kerur [off-list ref]
Subject: [dpdk-dev] [v4 2/3] LPM config file read option.

...
+
+#define	IPV6_ADDR_LEN	16
+#define	IPV6_ADDR_U16	(IPV6_ADDR_LEN / sizeof(uint16_t))
+#define	IPV6_ADDR_U32	(IPV6_ADDR_LEN / sizeof(uint32_t))
+
+#define GET_CB_FIELD(in, fd, base, lim, dlm)	do {            \
+	unsigned long val;                                      \
+	char *end;                                              \
+	errno = 0;                                              \
+	val = strtoul((in), &end, (base));                      \
+	if (errno != 0 || end[0] != (dlm) || val > (lim))       \
+		return -EINVAL;                               \
+	(fd) = (typeof(fd))val;                                 \
+	(in) = end + 1;                                         \
+} while (0)
Hi,

It is probably worth putting a comment before this macro to
explain what it does. Also, it isn't clear, to me, what CB
stands for. Also, having a return in the middle of the macro
might be problematic if it is used in a function with a
different, or not, return value.

John
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help