]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: simplify uuid_is_null() check
authorSami Kerola <kerolasa@iki.fi>
Sun, 22 Nov 2020 21:07:23 +0000 (21:07 +0000)
committerSami Kerola <kerolasa@iki.fi>
Mon, 28 Dec 2020 09:53:12 +0000 (09:53 +0000)
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>
libuuid/src/isnull.c

index 931e7e7dba2b30f801abbf045a0a763f8296fbf2..ecb44eac69a5239bea1ff325e92b353884ae91fe 100644 (file)
  */
 
 #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));
 }
-