From: Sami Kerola Date: Sun, 22 Nov 2020 21:07:23 +0000 (+0000) Subject: libuuid: simplify uuid_is_null() check X-Git-Tag: v2.37-rc1~202^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6fae86865210256a3de71a8d1bf74c2aca2be9f;p=thirdparty%2Futil-linux.git 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 --- 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)); } -