mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
Drop checks for virURIFormat() retval
The virURIFormat() function either returns a string, or aborts (on OOM). There's no way this function can return NULL (as of v7.2.0-rc1~277). Therefore, it doesn't make sense to check its retval against NULL. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
65b9d9a619
commit
77d417d9ef
@ -427,17 +427,13 @@ virAdmConnectIsAlive(virAdmConnectPtr conn)
|
||||
char *
|
||||
virAdmConnectGetURI(virAdmConnectPtr conn)
|
||||
{
|
||||
char *uri = NULL;
|
||||
VIR_DEBUG("conn=%p", conn);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckAdmConnectReturn(conn, NULL);
|
||||
|
||||
if (!(uri = virURIFormat(conn->uri)))
|
||||
virDispatchError(NULL);
|
||||
|
||||
return uri;
|
||||
return virURIFormat(conn->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,21 +313,13 @@ virConnectGetHostname(virConnectPtr conn)
|
||||
char *
|
||||
virConnectGetURI(virConnectPtr conn)
|
||||
{
|
||||
char *name;
|
||||
VIR_DEBUG("conn=%p", conn);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckConnectReturn(conn, NULL);
|
||||
|
||||
if (!(name = virURIFormat(conn->uri)))
|
||||
goto error;
|
||||
|
||||
return name;
|
||||
|
||||
error:
|
||||
virDispatchError(conn);
|
||||
return NULL;
|
||||
return virURIFormat(conn->uri);
|
||||
}
|
||||
|
||||
|
||||
|
@ -407,8 +407,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSource *src,
|
||||
if (!(uri = qemuBlockStorageSourceGetURI(src)))
|
||||
return NULL;
|
||||
|
||||
if (!(uristr = virURIFormat(uri)))
|
||||
return NULL;
|
||||
uristr = virURIFormat(uri);
|
||||
|
||||
if (!onlytarget) {
|
||||
if (src->auth) {
|
||||
|
@ -3777,8 +3777,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver,
|
||||
/* Send well-formed URI only if uri_in was well-formed */
|
||||
if (well_formed_uri) {
|
||||
uri->port = port;
|
||||
if (!(*uri_out = virURIFormat(uri)))
|
||||
goto cleanup;
|
||||
*uri_out = virURIFormat(uri);
|
||||
} else {
|
||||
*uri_out = g_strdup_printf("%s:%d", uri_in, port);
|
||||
}
|
||||
|
@ -843,9 +843,6 @@ doRemoteOpen(virConnectPtr conn,
|
||||
name = virURIFormat(&tmpuri);
|
||||
|
||||
VIR_FREE(tmpuri.query);
|
||||
|
||||
if (!name)
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -195,11 +195,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGlusterState *state,
|
||||
|
||||
tmp = state->uri->path;
|
||||
state->uri->path = g_strdup_printf("/%s", path);
|
||||
if (!(vol->target.path = virURIFormat(state->uri))) {
|
||||
VIR_FREE(state->uri->path);
|
||||
state->uri->path = tmp;
|
||||
return -1;
|
||||
}
|
||||
vol->target.path = virURIFormat(state->uri);
|
||||
VIR_FREE(state->uri->path);
|
||||
state->uri->path = tmp;
|
||||
|
||||
|
@ -194,7 +194,7 @@ virURIParse(const char *uri)
|
||||
* Wrapper for xmlSaveUri
|
||||
*
|
||||
* This function constructs back everything that @ref virURIParse
|
||||
* changes after parsing
|
||||
* changes after parsing. It aborts on error.
|
||||
*
|
||||
* @returns the constructed uri as a string
|
||||
*/
|
||||
|
@ -118,8 +118,7 @@ static int testURIParse(const void *args)
|
||||
VIR_FREE(uri->query);
|
||||
uri->query = virURIFormatParams(uri);
|
||||
|
||||
if (!(uristr = virURIFormat(uri)))
|
||||
return -1;
|
||||
uristr = virURIFormat(uri);
|
||||
|
||||
if (STRNEQ(uristr, data->uri_out)) {
|
||||
VIR_TEST_DEBUG("URI did not roundtrip, expect '%s', actual '%s'",
|
||||
|
Loading…
Reference in New Issue
Block a user