From a6fae86865210256a3de71a8d1bf74c2aca2be9f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 22 Nov 2020 21:07:23 +0000 Subject: [PATCH] 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 --- libuuid/src/isnull.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libuuid/src/isnull.c b/libuuid/src/isnull.c index 931e7e7dba..ecb44eac69 100644 --- a/libuuid/src/isnull.c +++ b/libuuid/src/isnull.c @@ -33,16 +33,12 @@ */ #include "uuidP.h" +#include /* 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)); } - -- 2.47.2