Remove use of anonymous unions for non-GCC (John Levon)

This commit is contained in:
Daniel P. Berrange 2008-12-17 18:12:07 +00:00
parent 6ded3ebad5
commit 7e58aaa7ae
6 changed files with 35 additions and 25 deletions

View File

@ -1,3 +1,12 @@
Wed Dec 17 18:10:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
Anonymous union fixes for non-GCC compilers (John Levon)
* domain_conf.c, qemu_conf.c, qemu_driver.c: Remove use
of anonymous union
* domain_conf.h: Give a name to the anonymous union for
host devices. Add 'dummy' field to avoid empty struct
* remote_internal.c: Remove gcc-ism in empty "x ? : y"
Wed Dec 17 19:06:53 +0100 2008 Jim Meyering <meyering@redhat.com> Wed Dec 17 19:06:53 +0100 2008 Jim Meyering <meyering@redhat.com>
portability: don't include <endian.h> or <byteswap.h> portability: don't include <endian.h> or <byteswap.h>

View File

@ -1479,7 +1479,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
if (vendor) { if (vendor) {
if (virStrToLong_ui(vendor, NULL, 0, if (virStrToLong_ui(vendor, NULL, 0,
&def->source.subsys.usb.vendor) < 0) { &def->source.subsys.u.usb.vendor) < 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot parse vendor id %s"), vendor); _("cannot parse vendor id %s"), vendor);
VIR_FREE(vendor); VIR_FREE(vendor);
@ -1496,7 +1496,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
if (product) { if (product) {
if (virStrToLong_ui(product, NULL, 0, if (virStrToLong_ui(product, NULL, 0,
&def->source.subsys.usb.product) < 0) { &def->source.subsys.u.usb.product) < 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot parse product %s"), product); _("cannot parse product %s"), product);
VIR_FREE(product); VIR_FREE(product);
@ -1514,7 +1514,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
bus = virXMLPropString(cur, "bus"); bus = virXMLPropString(cur, "bus");
if (bus) { if (bus) {
if (virStrToLong_ui(bus, NULL, 0, if (virStrToLong_ui(bus, NULL, 0,
&def->source.subsys.usb.bus) < 0) { &def->source.subsys.u.usb.bus) < 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot parse bus %s"), bus); _("cannot parse bus %s"), bus);
VIR_FREE(bus); VIR_FREE(bus);
@ -1530,7 +1530,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
device = virXMLPropString(cur, "device"); device = virXMLPropString(cur, "device");
if (device) { if (device) {
if (virStrToLong_ui(device, NULL, 0, if (virStrToLong_ui(device, NULL, 0,
&def->source.subsys.usb.device) < 0) { &def->source.subsys.u.usb.device) < 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot parse device %s"), _("cannot parse device %s"),
device); device);
@ -1552,14 +1552,14 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
cur = cur->next; cur = cur->next;
} }
if (def->source.subsys.usb.vendor == 0 && if (def->source.subsys.u.usb.vendor == 0 &&
def->source.subsys.usb.product != 0) { def->source.subsys.u.usb.product != 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("missing vendor")); "%s", _("missing vendor"));
goto out; goto out;
} }
if (def->source.subsys.usb.vendor != 0 && if (def->source.subsys.u.usb.vendor != 0 &&
def->source.subsys.usb.product == 0) { def->source.subsys.u.usb.product == 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("missing product")); "%s", _("missing product"));
goto out; goto out;
@ -3004,15 +3004,15 @@ virDomainHostdevDefFormat(virConnectPtr conn,
virBufferVSprintf(buf, " <hostdev mode='%s' type='%s'>\n", mode, type); virBufferVSprintf(buf, " <hostdev mode='%s' type='%s'>\n", mode, type);
virBufferAddLit(buf, " <source>\n"); virBufferAddLit(buf, " <source>\n");
if (def->source.subsys.usb.vendor) { if (def->source.subsys.u.usb.vendor) {
virBufferVSprintf(buf, " <vendor id='0x%.4x'/>\n", virBufferVSprintf(buf, " <vendor id='0x%.4x'/>\n",
def->source.subsys.usb.vendor); def->source.subsys.u.usb.vendor);
virBufferVSprintf(buf, " <product id='0x%.4x'/>\n", virBufferVSprintf(buf, " <product id='0x%.4x'/>\n",
def->source.subsys.usb.product); def->source.subsys.u.usb.product);
} else { } else {
virBufferVSprintf(buf, " <address bus='%d' device='%d'/>\n", virBufferVSprintf(buf, " <address bus='%d' device='%d'/>\n",
def->source.subsys.usb.bus, def->source.subsys.u.usb.bus,
def->source.subsys.usb.device); def->source.subsys.u.usb.device);
} }
virBufferAddLit(buf, " </source>\n"); virBufferAddLit(buf, " </source>\n");

View File

@ -308,12 +308,13 @@ struct _virDomainHostdevDef {
unsigned slot; unsigned slot;
unsigned function; unsigned function;
} pci; } pci;
}; } u;
} subsys; } subsys;
struct { struct {
/* TBD: struct capabilities see: /* TBD: struct capabilities see:
* https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
*/ */
int dummy;
} caps; } caps;
} source; } source;
char* target; char* target;

View File

@ -1263,15 +1263,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
if(hostdev->source.subsys.usb.vendor) { if(hostdev->source.subsys.u.usb.vendor) {
ret = asprintf(&usbdev, "host:%.4x:%.4x", ret = asprintf(&usbdev, "host:%.4x:%.4x",
hostdev->source.subsys.usb.vendor, hostdev->source.subsys.u.usb.vendor,
hostdev->source.subsys.usb.product); hostdev->source.subsys.u.usb.product);
} else { } else {
ret = asprintf(&usbdev, "host:%.3d.%.3d", ret = asprintf(&usbdev, "host:%.3d.%.3d",
hostdev->source.subsys.usb.bus, hostdev->source.subsys.u.usb.bus,
hostdev->source.subsys.usb.device); hostdev->source.subsys.u.usb.device);
} }
if (ret < 0) { if (ret < 0) {
usbdev = NULL; usbdev = NULL;

View File

@ -3107,14 +3107,14 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
return -1; return -1;
} }
if (dev->data.hostdev->source.subsys.usb.vendor) { if (dev->data.hostdev->source.subsys.u.usb.vendor) {
ret = asprintf(&cmd, "usb_add host:%.4x:%.4x", ret = asprintf(&cmd, "usb_add host:%.4x:%.4x",
dev->data.hostdev->source.subsys.usb.vendor, dev->data.hostdev->source.subsys.u.usb.vendor,
dev->data.hostdev->source.subsys.usb.product); dev->data.hostdev->source.subsys.u.usb.product);
} else { } else {
ret = asprintf(&cmd, "usb_add host:%.3d.%.3d", ret = asprintf(&cmd, "usb_add host:%.3d.%.3d",
dev->data.hostdev->source.subsys.usb.bus, dev->data.hostdev->source.subsys.u.usb.bus,
dev->data.hostdev->source.subsys.usb.device); dev->data.hostdev->source.subsys.u.usb.device);
} }
if (ret == -1) { if (ret == -1) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL); qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);

View File

@ -649,7 +649,7 @@ doRemoteOpen (virConnectPtr conn,
if (username) nr_args += 2; /* For -l username */ if (username) nr_args += 2; /* For -l username */
if (no_tty) nr_args += 5; /* For -T -o BatchMode=yes -e none */ if (no_tty) nr_args += 5; /* For -T -o BatchMode=yes -e none */
command = command ? : strdup ("ssh"); command = command ? command : strdup ("ssh");
if (command == NULL) if (command == NULL)
goto out_of_memory; goto out_of_memory;