summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorAdrian Moreno <amorenoz@redhat.com>2022-03-23 12:56:22 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-03-30 16:59:03 +0200
commitb54067b24a25c37d6ef0e6cfba9e6ea2d8f9202e (patch)
tree8441b0e416dff8a4df5113081344b0e786ab0f07 /ovsdb
parentd293965d7b06bd47a1b016e0a90461acaabb1b6e (diff)
downloadopenvswitch-b54067b24a25c37d6ef0e6cfba9e6ea2d8f9202e.tar.gz
idlc: support short version of SAFE macros.
In order to be consistent with the rest of the SAFE loop macros, overload each of the generated *_SAFE macro with a SHORT version that does not require the user to provide the NEXT variable. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'ovsdb')
-rwxr-xr-xovsdb/ovsdb-idlc.in19
1 files changed, 17 insertions, 2 deletions
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 10a70ae26..13c535939 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -251,10 +251,18 @@ const struct %(s)s *%(s)s_table_first(const struct %(s)s_table *);
for ((ROW) = %(s)s_table_first(TABLE); \\
(ROW); \\
(ROW) = %(s)s_next(ROW))
-#define %(S)s_TABLE_FOR_EACH_SAFE(ROW, NEXT, TABLE) \\
+#define %(S)s_TABLE_FOR_EACH_SAFE_LONG(ROW, NEXT, TABLE) \\
for ((ROW) = %(s)s_table_first(TABLE); \\
(ROW) ? ((NEXT) = %(s)s_next(ROW), 1) : 0; \\
(ROW) = (NEXT))
+#define %(S)s_TABLE_FOR_EACH_SAFE_SHORT(ROW, TABLE) \\
+ for (const struct %(s)s * ROW__next = ((ROW) = %(s)s_table_first(TABLE), NULL); \\
+ (ROW) ? (ROW__next = %(s)s_next(ROW), 1) : (ROW__next = NULL, 0); \\
+ (ROW) = ROW__next)
+#define %(S)s_TABLE_FOR_EACH_SAFE(...) \\
+ OVERLOAD_SAFE_MACRO(%(S)s_TABLE_FOR_EACH_SAFE_LONG, \\
+ %(S)s_TABLE_FOR_EACH_SAFE_SHORT, 3, __VA_ARGS__)
+
const struct %(s)s *%(s)s_get_for_uuid(const struct ovsdb_idl *, const struct uuid *);
const struct %(s)s *%(s)s_table_get_for_uuid(const struct %(s)s_table *, const struct uuid *);
@@ -264,10 +272,17 @@ const struct %(s)s *%(s)s_next(const struct %(s)s *);
for ((ROW) = %(s)s_first(IDL); \\
(ROW); \\
(ROW) = %(s)s_next(ROW))
-#define %(S)s_FOR_EACH_SAFE(ROW, NEXT, IDL) \\
+#define %(S)s_FOR_EACH_SAFE_LONG(ROW, NEXT, IDL) \\
for ((ROW) = %(s)s_first(IDL); \\
(ROW) ? ((NEXT) = %(s)s_next(ROW), 1) : 0; \\
(ROW) = (NEXT))
+#define %(S)s_FOR_EACH_SAFE_SHORT(ROW, IDL) \\
+ for (const struct %(s)s * ROW__next = ((ROW) = %(s)s_first(IDL), NULL); \\
+ (ROW) ? (ROW__next = %(s)s_next(ROW), 1) : (ROW__next = NULL, 0); \\
+ (ROW) = ROW__next)
+#define %(S)s_FOR_EACH_SAFE(...) \\
+ OVERLOAD_SAFE_MACRO(%(S)s_FOR_EACH_SAFE_LONG, \\
+ %(S)s_FOR_EACH_SAFE_SHORT, 3, __VA_ARGS__)
unsigned int %(s)s_get_seqno(const struct ovsdb_idl *);
unsigned int %(s)s_row_get_seqno(const struct %(s)s *row, enum ovsdb_idl_change change);