]> xenbits.xensource.com Git - libvirt.git/commitdiff
virPCIVPDResourceGetKeywordPrefix: Fix logging
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Jan 2024 14:13:16 +0000 (15:13 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 31 Jan 2024 16:24:07 +0000 (17:24 +0100)
Use VIR_DEBUG instead of VIR_INFO as that's more appropriate and report
relevant information for debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virpcivpd.c

index b303e161ae350a3b06ec63ad267a0934920eb3f7..67065dec460d7107bfa32960d487c534379f7150 100644 (file)
@@ -61,20 +61,20 @@ virPCIVPDResourceGetKeywordPrefix(const char *keyword)
     g_autofree char *key = NULL;
 
     /* Keywords must have a length of 2 bytes. */
-    if (strlen(keyword) != 2) {
-        VIR_INFO("The keyword length is not 2 bytes: %s", keyword);
-        return NULL;
-    } else if (!(virPCIVPDResourceIsUpperOrNumber(keyword[0]) &&
-                 virPCIVPDResourceIsUpperOrNumber(keyword[1]))) {
-        VIR_INFO("The keyword is not comprised only of uppercase ASCII letters or digits");
-        return NULL;
-    }
+    if (strlen(keyword) != 2 ||
+        !(virPCIVPDResourceIsUpperOrNumber(keyword[0]) &&
+          virPCIVPDResourceIsUpperOrNumber(keyword[1])))
+        goto cleanup;
+
     /* Special-case the system-specific keywords since they share the "Y" prefix with "YA". */
     if (virPCIVPDResourceIsSystemKeyword(keyword) || virPCIVPDResourceIsVendorKeyword(keyword))
         key = g_strndup(keyword, 1);
     else
         key = g_strndup(keyword, 2);
 
+ cleanup:
+    VIR_DEBUG("keyword='%s' key='%s'", keyword, NULLSTR(key));
+
     return g_steal_pointer(&key);
 }