summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-12 11:27:32 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-12 11:53:04 +0000
commit4bcd0b3c1766e459426e7d4138619790d4dd77d8 (patch)
tree547edef6dee620ef132c3de111a039ecf3941abe
parentcd3f2986eee8dbadc8253d4c3462f7e214f1236d (diff)
downloadlibguestfs-4bcd0b3c1766e459426e7d4138619790d4dd77d8.tar.gz
libguestfs-4bcd0b3c1766e459426e7d4138619790d4dd77d8.tar.xz
libguestfs-4bcd0b3c1766e459426e7d4138619790d4dd77d8.zip
inspect: Use 1/0 instead of true/false, and fix a bug in UUID parsing.
UUID parsing returned 'false' (ie. 0 == OK) when the UUID contained illegal characters. Now it returns -1 == failure.
-rw-r--r--src/inspect_fs_unix.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c
index fe44c3aa..09d47d6b 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -913,10 +913,10 @@ uuid_cmp(const void *x, const void *y)
const md_uuid *b = y;
for (size_t i = 0; i < 1; i++) {
- if (a->uuid[i] != b->uuid[i]) return false;
+ if (a->uuid[i] != b->uuid[i]) return 0;
}
- return true;
+ return 1;
}
static void
@@ -929,23 +929,27 @@ md_uuid_free(void *x)
/* Taken from parse_uuid in mdadm */
static int
-parse_uuid(const char *str, uint32_t *uuid)
+parse_uuid (const char *str, uint32_t *uuid)
{
- for (size_t i = 0; i < 4; i++) uuid[i] = 0;
-
- int hit = 0; /* number of Hex digIT */
+ size_t hit = 0; /* number of Hex digIT */
char c;
+ size_t i;
+ int n;
+
+ for (i = 0; i < 4; i++)
+ uuid[i] = 0;
+
while ((c = *str++)) {
- int n;
if (c >= '0' && c <= '9')
n = c - '0';
else if (c >= 'a' && c <= 'f')
n = 10 + c - 'a';
else if (c >= 'A' && c <= 'F')
n = 10 + c - 'A';
- else if (strchr(":. -", c))
+ else if (strchr (":. -", c))
continue;
- else return false;
+ else
+ return -1;
if (hit < 32) {
uuid[hit / 8] <<= 4;