diff options
author | Sami Kerola <kerolasa@iki.fi> | 2020-11-22 21:07:23 +0000 |
---|---|---|
committer | Sami Kerola <kerolasa@iki.fi> | 2020-12-28 09:53:12 +0000 |
commit | a6fae86865210256a3de71a8d1bf74c2aca2be9f (patch) | |
tree | fc6a5a24567aecf33e6bee3550869174326d4a0e /libuuid | |
parent | ab85f756a07aec9e1c5e28c6300530f1937c20f0 (diff) | |
download | util-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.c | 10 |
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)); } - |