]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: remove OOM error log from virGetHostnameImpl()
authorLaine Stump <laine@redhat.com>
Fri, 19 Jun 2020 02:33:28 +0000 (22:33 -0400)
committerLaine Stump <laine@redhat.com>
Sun, 5 Jul 2020 04:01:07 +0000 (00:01 -0400)
The strings allocated in virGetHostnameImpl() are all allocated via
g_strdup(), which will exit on OOM anyway, so the call to
virReportOOMError() is redundant, and removing it allows slight
modification to the code, in particular the cleanup label can be
eliminated.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virutil.c

index f39122e8dd7274d6d4eb43afba64aaab0bb457f3..04f882fda75389ca07fcbfa2318580c8706fca64 100644 (file)
@@ -503,8 +503,7 @@ virGetHostnameImpl(bool quiet)
          * string as-is; it's up to callers to check whether "localhost"
          * is allowed.
          */
-        result = g_strdup(hostname);
-        goto cleanup;
+        return g_strdup(hostname);
     }
 
     /* otherwise, it's a shortened, non-localhost, hostname.  Attempt to
@@ -519,8 +518,7 @@ virGetHostnameImpl(bool quiet)
         if (!quiet)
             VIR_WARN("getaddrinfo failed for '%s': %s",
                      hostname, gai_strerror(r));
-        result = g_strdup(hostname);
-        goto cleanup;
+        return g_strdup(hostname);
     }
 
     /* Tell static analyzers about getaddrinfo semantics.  */
@@ -538,10 +536,6 @@ virGetHostnameImpl(bool quiet)
         result = g_strdup(info->ai_canonname);
 
     freeaddrinfo(info);
-
- cleanup:
-    if (!result)
-        virReportOOMError();
     return result;
 }