mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Remove use of anonymous unions for non-GCC (John Levon)
This commit is contained in:
parent
6ded3ebad5
commit
7e58aaa7ae
@ -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>
|
||||
|
||||
portability: don't include <endian.h> or <byteswap.h>
|
||||
|
@ -1479,7 +1479,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
|
||||
|
||||
if (vendor) {
|
||||
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,
|
||||
_("cannot parse vendor id %s"), vendor);
|
||||
VIR_FREE(vendor);
|
||||
@ -1496,7 +1496,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
|
||||
|
||||
if (product) {
|
||||
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,
|
||||
_("cannot parse product %s"), product);
|
||||
VIR_FREE(product);
|
||||
@ -1514,7 +1514,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
|
||||
bus = virXMLPropString(cur, "bus");
|
||||
if (bus) {
|
||||
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,
|
||||
_("cannot parse bus %s"), bus);
|
||||
VIR_FREE(bus);
|
||||
@ -1530,7 +1530,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
|
||||
device = virXMLPropString(cur, "device");
|
||||
if (device) {
|
||||
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,
|
||||
_("cannot parse device %s"),
|
||||
device);
|
||||
@ -1552,14 +1552,14 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
if (def->source.subsys.usb.vendor == 0 &&
|
||||
def->source.subsys.usb.product != 0) {
|
||||
if (def->source.subsys.u.usb.vendor == 0 &&
|
||||
def->source.subsys.u.usb.product != 0) {
|
||||
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("missing vendor"));
|
||||
goto out;
|
||||
}
|
||||
if (def->source.subsys.usb.vendor != 0 &&
|
||||
def->source.subsys.usb.product == 0) {
|
||||
if (def->source.subsys.u.usb.vendor != 0 &&
|
||||
def->source.subsys.u.usb.product == 0) {
|
||||
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("missing product"));
|
||||
goto out;
|
||||
@ -3004,15 +3004,15 @@ virDomainHostdevDefFormat(virConnectPtr conn,
|
||||
virBufferVSprintf(buf, " <hostdev mode='%s' type='%s'>\n", mode, type);
|
||||
virBufferAddLit(buf, " <source>\n");
|
||||
|
||||
if (def->source.subsys.usb.vendor) {
|
||||
if (def->source.subsys.u.usb.vendor) {
|
||||
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",
|
||||
def->source.subsys.usb.product);
|
||||
def->source.subsys.u.usb.product);
|
||||
} else {
|
||||
virBufferVSprintf(buf, " <address bus='%d' device='%d'/>\n",
|
||||
def->source.subsys.usb.bus,
|
||||
def->source.subsys.usb.device);
|
||||
def->source.subsys.u.usb.bus,
|
||||
def->source.subsys.u.usb.device);
|
||||
}
|
||||
|
||||
virBufferAddLit(buf, " </source>\n");
|
||||
|
@ -308,12 +308,13 @@ struct _virDomainHostdevDef {
|
||||
unsigned slot;
|
||||
unsigned function;
|
||||
} pci;
|
||||
};
|
||||
} u;
|
||||
} subsys;
|
||||
struct {
|
||||
/* TBD: struct capabilities see:
|
||||
* https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
|
||||
*/
|
||||
int dummy;
|
||||
} caps;
|
||||
} source;
|
||||
char* target;
|
||||
|
@ -1263,15 +1263,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
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",
|
||||
hostdev->source.subsys.usb.vendor,
|
||||
hostdev->source.subsys.usb.product);
|
||||
hostdev->source.subsys.u.usb.vendor,
|
||||
hostdev->source.subsys.u.usb.product);
|
||||
|
||||
} else {
|
||||
ret = asprintf(&usbdev, "host:%.3d.%.3d",
|
||||
hostdev->source.subsys.usb.bus,
|
||||
hostdev->source.subsys.usb.device);
|
||||
hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device);
|
||||
}
|
||||
if (ret < 0) {
|
||||
usbdev = NULL;
|
||||
|
@ -3107,14 +3107,14 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
|
||||
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",
|
||||
dev->data.hostdev->source.subsys.usb.vendor,
|
||||
dev->data.hostdev->source.subsys.usb.product);
|
||||
dev->data.hostdev->source.subsys.u.usb.vendor,
|
||||
dev->data.hostdev->source.subsys.u.usb.product);
|
||||
} else {
|
||||
ret = asprintf(&cmd, "usb_add host:%.3d.%.3d",
|
||||
dev->data.hostdev->source.subsys.usb.bus,
|
||||
dev->data.hostdev->source.subsys.usb.device);
|
||||
dev->data.hostdev->source.subsys.u.usb.bus,
|
||||
dev->data.hostdev->source.subsys.u.usb.device);
|
||||
}
|
||||
if (ret == -1) {
|
||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||
|
@ -649,7 +649,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
if (username) nr_args += 2; /* For -l username */
|
||||
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)
|
||||
goto out_of_memory;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user