mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vboxDumpDisplay: clean up VIR_STRDUP usage
Two VIR_STRDUP calls are redundant - just steal the string converted by VBOX_UTF16_TO_UTF8. Report an error when the third one fails.
This commit is contained in:
parent
8f8c473a98
commit
fcecbb37bf
@ -3300,8 +3300,6 @@ static int
|
|||||||
vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
||||||
{
|
{
|
||||||
/* dump display options vrdp/gui/sdl */
|
/* dump display options vrdp/gui/sdl */
|
||||||
char *guiDisplay = NULL;
|
|
||||||
char *sdlDisplay = NULL;
|
|
||||||
PRUnichar *keyTypeUtf16 = NULL;
|
PRUnichar *keyTypeUtf16 = NULL;
|
||||||
PRUnichar *valueTypeUtf16 = NULL;
|
PRUnichar *valueTypeUtf16 = NULL;
|
||||||
char *valueTypeUtf8 = NULL;
|
char *valueTypeUtf8 = NULL;
|
||||||
@ -3343,41 +3341,25 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ(valueTypeUtf8, "sdl")) {
|
if (STREQ(valueTypeUtf8, "sdl")) {
|
||||||
if (VIR_STRDUP(sdlDisplay, valueDisplayUtf8) < 0) {
|
|
||||||
/* just don't go to cleanup yet as it is ok to have
|
|
||||||
* sdlDisplay as NULL and we check it below if it
|
|
||||||
* exist and then only use it there
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
||||||
if (sdlDisplay)
|
graphics->data.sdl.display = valueDisplayUtf8;
|
||||||
graphics->data.sdl.display = sdlDisplay;
|
valueDisplayUtf8 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ(valueTypeUtf8, "gui")) {
|
if (STREQ(valueTypeUtf8, "gui")) {
|
||||||
if (VIR_STRDUP(guiDisplay, valueDisplayUtf8) < 0) {
|
|
||||||
/* just don't go to cleanup yet as it is ok to have
|
|
||||||
* guiDisplay as NULL and we check it below if it
|
|
||||||
* exist and then only use it there
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
||||||
if (guiDisplay)
|
graphics->data.desktop.display = valueDisplayUtf8;
|
||||||
graphics->data.desktop.display = guiDisplay;
|
valueDisplayUtf8 = NULL;
|
||||||
}
|
}
|
||||||
VBOX_UTF8_FREE(valueDisplayUtf8);
|
VBOX_UTF8_FREE(valueDisplayUtf8);
|
||||||
} else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) {
|
} else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) {
|
||||||
const char *tmp;
|
|
||||||
if (VIR_ALLOC(graphics) < 0)
|
if (VIR_ALLOC(graphics) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
||||||
tmp = virGetEnvBlockSUID("DISPLAY");
|
if (VIR_STRDUP(graphics->data.desktop.display,
|
||||||
if (VIR_STRDUP(graphics->data.desktop.display, tmp) < 0) {
|
virGetEnvBlockSUID("DISPLAY")) < 0)
|
||||||
/* just don't go to cleanup yet as it is ok to have
|
goto cleanup;
|
||||||
* display as NULL
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graphics) {
|
if (graphics) {
|
||||||
|
Loading…
Reference in New Issue
Block a user