]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virhostcpu.c: modernize virHostCPUGetMicrocodeVersion()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 24 Aug 2020 13:27:52 +0000 (10:27 -0300)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Aug 2020 17:06:19 +0000 (19:06 +0200)
Use g_autofree and remove the cleanup label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/util/virhostcpu.c

index 6cea75536d6ce6e909db13531291a989657f3251..d7aa39c13134c5d723f69334dae0b4c987c5ba07 100644 (file)
@@ -1241,7 +1241,7 @@ virHostCPUGetKVMMaxVCPUs(void)
 unsigned int
 virHostCPUGetMicrocodeVersion(void)
 {
-    char *outbuf = NULL;
+    g_autofree char *outbuf = NULL;
     char *cur;
     unsigned int version = 0;
 
@@ -1254,16 +1254,14 @@ virHostCPUGetMicrocodeVersion(void)
     /* Account for format 'microcode    : XXXX'*/
     if (!(cur = strstr(outbuf, "microcode")) ||
         !(cur = strchr(cur, ':')))
-        goto cleanup;
+        return 0;
     cur++;
 
     /* Linux places the microcode revision in a 32-bit integer, so
      * ui is fine for us too.  */
     if (virStrToLong_ui(cur, &cur, 0, &version) < 0)
-        goto cleanup;
+        return 0;
 
- cleanup:
-    VIR_FREE(outbuf);
     return version;
 }