summaryrefslogtreecommitdiff
path: root/libuuid
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2020-11-22 21:07:23 +0000
committerSami Kerola <kerolasa@iki.fi>2020-12-28 09:53:12 +0000
commita6fae86865210256a3de71a8d1bf74c2aca2be9f (patch)
treefc6a5a24567aecf33e6bee3550869174326d4a0e /libuuid
parentab85f756a07aec9e1c5e28c6300530f1937c20f0 (diff)
downloadutil-linux-a6fae86865210256a3de71a8d1bf74c2aca2be9f.tar.gz
libuuid: simplify uuid_is_null() check
There is no need to check uuid byte by byte. Also by using size of the uuid type magic constant can be avoided. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libuuid')
-rw-r--r--libuuid/src/isnull.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libuuid/src/isnull.c b/libuuid/src/isnull.c
index 931e7e7db..ecb44eac6 100644
--- a/libuuid/src/isnull.c
+++ b/libuuid/src/isnull.c
@@ -33,16 +33,12 @@
*/
#include "uuidP.h"
+#include <string.h>
/* Returns 1 if the uuid is the NULL uuid */
int uuid_is_null(const uuid_t uu)
{
- const unsigned char *cp;
- int i;
+ const uuid_t nil = { 0 };
- for (i=0, cp = uu; i < 16; i++)
- if (*cp++)
- return 0;
- return 1;
+ return !memcmp(uu, nil, sizeof(nil));
}
-