This is convenient in expressions, e.g. "uuid = x ? *x : UUID_ZERO;".
Signed-off-by: Ben Pfaff <[email protected]> --- 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 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
