]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Rename nlmsg_for_each_msg() to nlmsg_for_each()
authorThomas Graf <tgraf@suug.ch>
Tue, 23 Nov 2010 12:29:45 +0000 (13:29 +0100)
committerThomas Graf <tgraf@suug.ch>
Tue, 23 Nov 2010 12:29:45 +0000 (13:29 +0100)
Also put remaining variable on local stack instead of requiring the user
to supply it. Old interface is kept for compatibility.

include/netlink/msg.h

index 12b20617b839c5c6a6f41157758c73def10ba8f0..ef805a4922103ed5e65d66a90cbe3407a4ba2bff 100644 (file)
@@ -126,12 +126,14 @@ extern void               nl_msg_dump(struct nl_msg *, FILE *);
  * @arg pos    loop counter, set to current message
  * @arg head   head of message stream
  * @arg len    length of message stream
- * @arg rem    initialized to len, holds bytes currently remaining in stream
  */
+#define nlmsg_for_each(pos, head, len) \
+       for (int rem = len, pos = head; \
+               nlmsg_ok(pos, rem); \
+               pos = nlmsg_next(pos, &rem))
+
 #define nlmsg_for_each_msg(pos, head, len, rem) \
-       for (pos = head, rem = len; \
-            nlmsg_ok(pos, rem); \
-            pos = nlmsg_next(pos, &(rem)))
+               nlmsg_for_each(pos, head, len)
 
 /** @} */