diff options
author | Ben Pfaff <blp@ovn.org> | 2016-11-11 15:47:54 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-02-08 11:41:15 -0800 |
commit | 42a1d93e290aa0c985de82c1398384dcc29f427c (patch) | |
tree | d8a745d1cc031f8bec8c12181622d5262165afd3 | |
parent | b5f0fe21a0bd3d122f90cfd6b9daa6fcd80585e5 (diff) | |
download | openvswitch-42a1d93e290aa0c985de82c1398384dcc29f427c.tar.gz |
uuid: New macro UUID_ZERO for an all-zero expression or initializer.
This is convenient in expressions, e.g. "uuid = x ? *x : UUID_ZERO;".
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
-rw-r--r-- | lib/uuid.c | 2 | ||||
-rw-r--r-- | lib/uuid.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/uuid.c b/lib/uuid.c index bd98d4060..a9094d367 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 113574c6d..605ec17b7 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: |