mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
osinfo: use guestfs_int_version_from_x_y to parse the os version
Make use of the common version code, and avoid a separate regexp.
This commit is contained in:
17
src/osinfo.c
17
src/osinfo.c
@@ -65,8 +65,6 @@
|
||||
#include "guestfs.h"
|
||||
#include "guestfs-internal.h"
|
||||
|
||||
COMPILE_REGEXP (re_major_minor, "(\\d+)\\.(\\d+)", 0)
|
||||
|
||||
gl_lock_define_initialized (static, osinfo_db_lock);
|
||||
static ssize_t osinfo_db_size = 0; /* 0 = unread, -1 = error, >= 1 = #records */
|
||||
static struct osinfo *osinfo_db = NULL;
|
||||
@@ -436,17 +434,16 @@ static int
|
||||
parse_version (guestfs_h *g, xmlNodePtr node, struct osinfo *osinfo)
|
||||
{
|
||||
CLEANUP_FREE char *content = NULL;
|
||||
CLEANUP_FREE char *major = NULL, *minor = NULL;
|
||||
|
||||
content = (char *) xmlNodeGetContent (node);
|
||||
if (content) {
|
||||
if (match2 (g, content, re_major_minor, &major, &minor)) {
|
||||
osinfo->major_version = guestfs_int_parse_unsigned_int (g, major);
|
||||
if (osinfo->major_version == -1)
|
||||
return -1;
|
||||
osinfo->minor_version = guestfs_int_parse_unsigned_int (g, minor);
|
||||
if (osinfo->minor_version == -1)
|
||||
return -1;
|
||||
struct version version;
|
||||
int res = guestfs_int_version_from_x_y (g, &version, content);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
else if (res > 0) {
|
||||
osinfo->major_version = version.v_major;
|
||||
osinfo->minor_version = version.v_minor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user