From: Karel Zak Date: Thu, 13 Jun 2013 12:33:47 +0000 (+0200) Subject: libblkid: make uuid_is_empty() usable for whole library X-Git-Tag: v2.24-rc1~499 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c06cdbf61465509df37c6c58694ce8ea07ed943;p=thirdparty%2Futil-linux.git libblkid: make uuid_is_empty() usable for whole library Signed-off-by: Karel Zak --- diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h index 7cc585932a..1c0596832d 100644 --- a/libblkid/src/blkidP.h +++ b/libblkid/src/blkidP.h @@ -518,6 +518,8 @@ extern int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset, extern void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) __attribute__((nonnull)); +extern int blkid_uuid_is_empty(const unsigned char *buf, size_t len); + extern size_t blkid_rtrim_whitespace(unsigned char *str) __attribute__((nonnull)); extern size_t blkid_ltrim_whitespace(unsigned char *str) diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c index 954b08708c..d2b301d7f0 100644 --- a/libblkid/src/probe.c +++ b/libblkid/src/probe.c @@ -1637,6 +1637,16 @@ void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) } #endif +/* like uuid_is_null() from libuuid, but works with arbitrary size of UUID */ +int blkid_uuid_is_empty(const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + if (buf[i]) + return 0; + return 1; +} /* Removes whitespace from the right-hand side of a string (trailing * whitespace). diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index 03bcabc913..5f43b24861 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -617,17 +617,6 @@ int blkid_probe_set_utf8label(blkid_probe pr, unsigned char *label, return 0; } -/* like uuid_is_null() from libuuid, but works with arbitrary size of UUID */ -static int uuid_is_empty(const unsigned char *buf, size_t len) -{ - size_t i; - - for (i = 0; i < len; i++) - if (buf[i]) - return 0; - return 1; -} - int blkid_probe_sprintf_uuid(blkid_probe pr, unsigned char *uuid, size_t len, const char *fmt, ...) { @@ -638,7 +627,7 @@ int blkid_probe_sprintf_uuid(blkid_probe pr, unsigned char *uuid, if (len > BLKID_PROBVAL_BUFSIZ) len = BLKID_PROBVAL_BUFSIZ; - if (uuid_is_empty(uuid, len)) + if (blkid_uuid_is_empty(uuid, len)) return 0; if ((chn->flags & BLKID_SUBLKS_UUIDRAW) && @@ -703,7 +692,7 @@ int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *nam struct blkid_chain *chn = blkid_probe_get_chain(pr); struct blkid_prval *v; - if (uuid_is_empty(uuid, 16)) + if (blkid_uuid_is_empty(uuid, 16)) return 0; if (!name) {