[ovs-dev] [PATCH 4/4] uuid: New macro UUID_ZERO for an all-zero expression or initializer.
Ben Pfaff
blp at ovn.org
Wed Feb 8 16:32:31 UTC 2017
This is convenient in expressions, e.g. "uuid = x ? *x : UUID_ZERO;".
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
lib/uuid.c | 2 +-
lib/uuid.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/uuid.c b/lib/uuid.c
index bd98d40..a9094d3 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -115,7 +115,7 @@ uuid_set_bits_v4(struct uuid *uuid)
void
uuid_zero(struct uuid *uuid)
{
- uuid->parts[0] = uuid->parts[1] = uuid->parts[2] = uuid->parts[3] = 0;
+ *uuid = UUID_ZERO;
}
/* Returns true if 'uuid' is all zero, otherwise false. */
diff --git a/lib/uuid.h b/lib/uuid.h
index 113574c..605ec17 100644
--- a/lib/uuid.h
+++ b/lib/uuid.h
@@ -18,6 +18,9 @@
#include "openvswitch/uuid.h"
+/* An initializer or expression for an all-zero UUID. */
+#define UUID_ZERO ((struct uuid) { .parts = { 0, 0, 0, 0 } })
+
/* Formats a UUID as a string, in the conventional format.
*
* Example:
--
2.10.2
More information about the dev
mailing list