util: remove OOM error log from virGetHostnameImpl()
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>
This commit is contained in:
parent
59afd0b0bc
commit
852ee1950a
@ -503,8 +503,7 @@ virGetHostnameImpl(bool quiet)
|
|||||||
* string as-is; it's up to callers to check whether "localhost"
|
* string as-is; it's up to callers to check whether "localhost"
|
||||||
* is allowed.
|
* is allowed.
|
||||||
*/
|
*/
|
||||||
result = g_strdup(hostname);
|
return g_strdup(hostname);
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise, it's a shortened, non-localhost, hostname. Attempt to
|
/* otherwise, it's a shortened, non-localhost, hostname. Attempt to
|
||||||
@ -519,8 +518,7 @@ virGetHostnameImpl(bool quiet)
|
|||||||
if (!quiet)
|
if (!quiet)
|
||||||
VIR_WARN("getaddrinfo failed for '%s': %s",
|
VIR_WARN("getaddrinfo failed for '%s': %s",
|
||||||
hostname, gai_strerror(r));
|
hostname, gai_strerror(r));
|
||||||
result = g_strdup(hostname);
|
return g_strdup(hostname);
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell static analyzers about getaddrinfo semantics. */
|
/* Tell static analyzers about getaddrinfo semantics. */
|
||||||
@ -538,10 +536,6 @@ virGetHostnameImpl(bool quiet)
|
|||||||
result = g_strdup(info->ai_canonname);
|
result = g_strdup(info->ai_canonname);
|
||||||
|
|
||||||
freeaddrinfo(info);
|
freeaddrinfo(info);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (!result)
|
|
||||||
virReportOOMError();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user