From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> The current regex match rule is If pattern is NULL and string is NULL -> accept media else if pattern is NULL or string is NULL -> reject media else -> do regex compare The regex match rules ought to be If pattern is NULL -> accept media Else if string is NULL -> reject media else -> do regex compare The idea is that if the Osinfo database pattern is NULL, then regardless of whether the string is NULL or not, then we should allow that match. In effect a pattern == NULL, should be treated as equivalent to a regex ".*" --- osinfo/osinfo_db.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index ecc8fbd..52c7868 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -30,9 +30,10 @@ G_DEFINE_TYPE (OsinfoDb, osinfo_db, G_TYPE_OBJECT); #define OSINFO_DB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DB, OsinfoDbPrivate)) -#define match_regex(pattern, str) (((pattern) == NULL && (str) == NULL) || \ - ((pattern) != NULL && (str) != NULL && \ - g_regex_match_simple((pattern), (str), 0, 0))) +#define match_regex(pattern, str) \ + (((pattern) == NULL) || \ + (((str) != NULL) && \ + g_regex_match_simple((pattern), (str), 0, 0))) /** * SECTION:osinfo_db @@ -386,11 +387,10 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, const gchar *os_publisher = osinfo_media_get_publisher_id(os_media); const gchar *os_application = osinfo_media_get_application_id(os_media); - if ((match_regex (os_volume, media_volume) || - match_regex (os_application, media_application)) - && - (match_regex (os_system, media_system) || - match_regex (os_publisher, media_publisher))) { + if (match_regex (os_volume, media_volume) && + match_regex (os_application, media_application) && + match_regex (os_system, media_system) && + match_regex (os_publisher, media_publisher)) { ret = os; if (matched_media != NULL) *matched_media = os_media; -- 1.7.7.6