cleanup: Change datatype of graphic's members to boolean

This commit is contained in:
Osier Yang 2013-04-12 16:49:38 +08:00
parent b044b4d78f
commit 00b6828dc2
8 changed files with 36 additions and 36 deletions

View File

@ -7419,18 +7419,18 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if (def->data.vnc.port == -1) { if (def->data.vnc.port == -1) {
if (flags & VIR_DOMAIN_XML_INACTIVE) if (flags & VIR_DOMAIN_XML_INACTIVE)
def->data.vnc.port = 0; def->data.vnc.port = 0;
def->data.vnc.autoport = 1; def->data.vnc.autoport = true;
} }
} else { } else {
def->data.vnc.port = 0; def->data.vnc.port = 0;
def->data.vnc.autoport = 1; def->data.vnc.autoport = true;
} }
if ((autoport = virXMLPropString(node, "autoport")) != NULL) { if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
if (STREQ(autoport, "yes")) { if (STREQ(autoport, "yes")) {
if (flags & VIR_DOMAIN_XML_INACTIVE) if (flags & VIR_DOMAIN_XML_INACTIVE)
def->data.vnc.port = 0; def->data.vnc.port = 0;
def->data.vnc.autoport = 1; def->data.vnc.autoport = true;
} }
VIR_FREE(autoport); VIR_FREE(autoport);
} }
@ -7446,9 +7446,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if (fullscreen != NULL) { if (fullscreen != NULL) {
if (STREQ(fullscreen, "yes")) { if (STREQ(fullscreen, "yes")) {
def->data.sdl.fullscreen = 1; def->data.sdl.fullscreen = true;
} else if (STREQ(fullscreen, "no")) { } else if (STREQ(fullscreen, "no")) {
def->data.sdl.fullscreen = 0; def->data.sdl.fullscreen = false;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen); _("unknown fullscreen value '%s'"), fullscreen);
@ -7457,7 +7457,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
} }
VIR_FREE(fullscreen); VIR_FREE(fullscreen);
} else { } else {
def->data.sdl.fullscreen = 0; def->data.sdl.fullscreen = false;
} }
def->data.sdl.xauth = virXMLPropString(node, "xauth"); def->data.sdl.xauth = virXMLPropString(node, "xauth");
def->data.sdl.display = virXMLPropString(node, "display"); def->data.sdl.display = virXMLPropString(node, "display");
@ -7476,17 +7476,17 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
} }
/* Legacy compat syntax, used -1 for auto-port */ /* Legacy compat syntax, used -1 for auto-port */
if (def->data.rdp.port == -1) if (def->data.rdp.port == -1)
def->data.rdp.autoport = 1; def->data.rdp.autoport = true;
VIR_FREE(port); VIR_FREE(port);
} else { } else {
def->data.rdp.port = 0; def->data.rdp.port = 0;
def->data.rdp.autoport = 1; def->data.rdp.autoport = true;
} }
if ((autoport = virXMLPropString(node, "autoport")) != NULL) { if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
if (STREQ(autoport, "yes")) if (STREQ(autoport, "yes"))
def->data.rdp.autoport = 1; def->data.rdp.autoport = true;
VIR_FREE(autoport); VIR_FREE(autoport);
} }
@ -7496,14 +7496,14 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) { if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
if (STREQ(replaceUser, "yes")) { if (STREQ(replaceUser, "yes")) {
def->data.rdp.replaceUser = 1; def->data.rdp.replaceUser = true;
} }
VIR_FREE(replaceUser); VIR_FREE(replaceUser);
} }
if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) { if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) {
if (STREQ(multiUser, "yes")) { if (STREQ(multiUser, "yes")) {
def->data.rdp.multiUser = 1; def->data.rdp.multiUser = true;
} }
VIR_FREE(multiUser); VIR_FREE(multiUser);
} }
@ -7513,9 +7513,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if (fullscreen != NULL) { if (fullscreen != NULL) {
if (STREQ(fullscreen, "yes")) { if (STREQ(fullscreen, "yes")) {
def->data.desktop.fullscreen = 1; def->data.desktop.fullscreen = true;
} else if (STREQ(fullscreen, "no")) { } else if (STREQ(fullscreen, "no")) {
def->data.desktop.fullscreen = 0; def->data.desktop.fullscreen = false;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen); _("unknown fullscreen value '%s'"), fullscreen);
@ -7524,7 +7524,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
} }
VIR_FREE(fullscreen); VIR_FREE(fullscreen);
} else { } else {
def->data.desktop.fullscreen = 0; def->data.desktop.fullscreen = false;
} }
def->data.desktop.display = virXMLPropString(node, "display"); def->data.desktop.display = virXMLPropString(node, "display");
@ -7563,7 +7563,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if ((autoport = virXMLPropString(node, "autoport")) != NULL) { if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
if (STREQ(autoport, "yes")) if (STREQ(autoport, "yes"))
def->data.spice.autoport = 1; def->data.spice.autoport = true;
VIR_FREE(autoport); VIR_FREE(autoport);
} }
@ -7583,7 +7583,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) { if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) {
/* Legacy compat syntax, used -1 for auto-port */ /* Legacy compat syntax, used -1 for auto-port */
def->data.spice.autoport = 1; def->data.spice.autoport = true;
} }
if (def->data.spice.autoport && (flags & VIR_DOMAIN_XML_INACTIVE)) { if (def->data.spice.autoport && (flags & VIR_DOMAIN_XML_INACTIVE)) {

View File

@ -1375,7 +1375,7 @@ struct _virDomainGraphicsDef {
union { union {
struct { struct {
int port; int port;
unsigned int autoport :1; bool autoport;
char *keymap; char *keymap;
char *socket; char *socket;
virDomainGraphicsAuthDef auth; virDomainGraphicsAuthDef auth;
@ -1383,17 +1383,17 @@ struct _virDomainGraphicsDef {
struct { struct {
char *display; char *display;
char *xauth; char *xauth;
int fullscreen; bool fullscreen;
} sdl; } sdl;
struct { struct {
int port; int port;
unsigned int autoport :1; bool autoport;
unsigned int replaceUser :1; bool replaceUser;
unsigned int multiUser :1; bool multiUser;
} rdp; } rdp;
struct { struct {
char *display; char *display;
unsigned int fullscreen :1; bool fullscreen;
} desktop; } desktop;
struct { struct {
int port; int port;
@ -1401,7 +1401,7 @@ struct _virDomainGraphicsDef {
int mousemode; int mousemode;
char *keymap; char *keymap;
virDomainGraphicsAuthDef auth; virDomainGraphicsAuthDef auth;
unsigned int autoport :1; bool autoport;
int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST]; int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */ int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */
int image; int image;

View File

@ -615,13 +615,13 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
if (STREQ(tmp, "auto")) { if (STREQ(tmp, "auto")) {
if (virJSONValueObjectGetNumberUint(jobj, "port", &port) < 0) if (virJSONValueObjectGetNumberUint(jobj, "port", &port) < 0)
port = 0; port = 0;
gr->data.vnc.autoport = 1; gr->data.vnc.autoport = true;
} else { } else {
if (virJSONValueObjectGetNumberUint(jobj, "port", &port) < 0) { if (virJSONValueObjectGetNumberUint(jobj, "port", &port) < 0) {
parallelsParseError(); parallelsParseError();
goto cleanup; goto cleanup;
} }
gr->data.vnc.autoport = 0; gr->data.vnc.autoport = false;
} }
gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;

View File

@ -9189,7 +9189,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
virDomainDefPtr def; virDomainDefPtr def;
int i; int i;
int nographics = 0; int nographics = 0;
int fullscreen = 0; bool fullscreen = false;
char *path; char *path;
int nnics = 0; int nnics = 0;
const char **nics = NULL; const char **nics = NULL;
@ -9354,7 +9354,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
goto no_memory; goto no_memory;
} }
vnc->data.vnc.port += 5900; vnc->data.vnc.port += 5900;
vnc->data.vnc.autoport = 0; vnc->data.vnc.autoport = false;
} }
if (VIR_REALLOC_N(def->graphics, def->ngraphics+1) < 0) { if (VIR_REALLOC_N(def->graphics, def->ngraphics+1) < 0) {
@ -9511,7 +9511,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
} else if (STREQ(arg, "-nographic")) { } else if (STREQ(arg, "-nographic")) {
nographics = 1; nographics = 1;
} else if (STREQ(arg, "-full-screen")) { } else if (STREQ(arg, "-full-screen")) {
fullscreen = 1; fullscreen = true;
} else if (STREQ(arg, "-localtime")) { } else if (STREQ(arg, "-localtime")) {
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME; def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
} else if (STREQ(arg, "-kernel")) { } else if (STREQ(arg, "-kernel")) {

View File

@ -2566,7 +2566,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
VBOX_UTF16_FREE(VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsValue);
#endif /* VBOX_API_VERSION >= 4000 */ #endif /* VBOX_API_VERSION >= 4000 */
} else { } else {
def->graphics[def->ngraphics]->data.rdp.autoport = 1; def->graphics[def->ngraphics]->data.rdp.autoport = true;
} }
def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_RDP; def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_RDP;
@ -2590,12 +2590,12 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
VRDxServer->vtbl->GetAllowMultiConnection(VRDxServer, &allowMultiConnection); VRDxServer->vtbl->GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
if (allowMultiConnection) { if (allowMultiConnection) {
def->graphics[def->ngraphics]->data.rdp.multiUser = 1; def->graphics[def->ngraphics]->data.rdp.multiUser = true;
} }
VRDxServer->vtbl->GetReuseSingleConnection(VRDxServer, &reuseSingleConnection); VRDxServer->vtbl->GetReuseSingleConnection(VRDxServer, &reuseSingleConnection);
if (reuseSingleConnection) { if (reuseSingleConnection) {
def->graphics[def->ngraphics]->data.rdp.replaceUser = 1; def->graphics[def->ngraphics]->data.rdp.replaceUser = true;
} }
def->ngraphics++; def->ngraphics++;

View File

@ -1870,14 +1870,14 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
"is missing, the VNC port is unknown"); "is missing, the VNC port is unknown");
(*def)->data.vnc.port = 0; (*def)->data.vnc.port = 0;
(*def)->data.vnc.autoport = 1; (*def)->data.vnc.autoport = true;
} else { } else {
if (port < 5900 || port > 5964) { if (port < 5900 || port > 5964) {
VIR_WARN("VNC port %lld it out of [5900..5964] range", port); VIR_WARN("VNC port %lld it out of [5900..5964] range", port);
} }
(*def)->data.vnc.port = port; (*def)->data.vnc.port = port;
(*def)->data.vnc.autoport = 0; (*def)->data.vnc.autoport = false;
} }
return 0; return 0;

View File

@ -825,7 +825,7 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
port = 5900 + def->id; port = 5900 + def->id;
if ((unused && STREQ(unused, "1")) || port == -1) if ((unused && STREQ(unused, "1")) || port == -1)
graphics->data.vnc.autoport = 1; graphics->data.vnc.autoport = true;
graphics->data.vnc.port = port; graphics->data.vnc.port = port;
if (listenAddr && if (listenAddr &&
@ -949,7 +949,7 @@ xenParseSxprGraphicsNew(virDomainDefPtr def,
} }
if ((unused && STREQ(unused, "1")) || port == -1) if ((unused && STREQ(unused, "1")) || port == -1)
graphics->data.vnc.autoport = 1; graphics->data.vnc.autoport = true;
if (port >= 0 && port < 5900) if (port >= 0 && port < 5900)
port += 5900; port += 5900;

View File

@ -1012,7 +1012,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
if (STRPREFIX(key, "vncunused=")) { if (STRPREFIX(key, "vncunused=")) {
if (STREQ(key + 10, "1")) if (STREQ(key + 10, "1"))
graphics->data.vnc.autoport = 1; graphics->data.vnc.autoport = true;
} else if (STRPREFIX(key, "vnclisten=")) { } else if (STRPREFIX(key, "vnclisten=")) {
if (virDomainGraphicsListenSetAddress(graphics, 0, key+10, if (virDomainGraphicsListenSetAddress(graphics, 0, key+10,
-1, true) < 0) -1, true) < 0)