提交 6ac33f22 编写于 作者: J Ján Tomko

util: uuid: remove use of virHexToBin

Prefer g_ascii_xdigit_value to virHexToBin.

Check the return value of the function and
remove the g_ascii_isxdigit calls, since
they're done anyway internally.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NLaine Stump <laine@redhat.com>
上级 49f4d549
......@@ -29,7 +29,6 @@
#include <unistd.h>
#include "internal.h"
#include "virutil.h"
#include "virerror.h"
#include "virlog.h"
#include "viralloc.h"
......@@ -105,6 +104,7 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid)
cur++;
for (i = 0; i < VIR_UUID_BUFLEN;) {
int val;
uuid[i] = 0;
if (*cur == 0)
return -1;
......@@ -112,16 +112,15 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid)
cur++;
continue;
}
if (!g_ascii_isxdigit(*cur))
if ((val = g_ascii_xdigit_value(*cur)) < 0)
return -1;
uuid[i] = virHexToBin(*cur);
uuid[i] *= 16;
uuid[i] = 16 * val;
cur++;
if (*cur == 0)
return -1;
if (!g_ascii_isxdigit(*cur))
if ((val = g_ascii_xdigit_value(*cur)) < 0)
return -1;
uuid[i] += virHexToBin(*cur);
uuid[i] += val;
i++;
cur++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册