提交 cc7da958 编写于 作者: O Osier Yang

Cleanup: Change datatype of origstate's members to boolean

Members of struct virPCIDevice are changed together.
上级 9fda2f5c
...@@ -3482,11 +3482,11 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node, ...@@ -3482,11 +3482,11 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node,
while (cur != NULL) { while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) { if (cur->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(cur->name, BAD_CAST "unbind")) { if (xmlStrEqual(cur->name, BAD_CAST "unbind")) {
def->states.pci.unbind_from_stub = 1; def->states.pci.unbind_from_stub = true;
} else if (xmlStrEqual(cur->name, BAD_CAST "removeslot")) { } else if (xmlStrEqual(cur->name, BAD_CAST "removeslot")) {
def->states.pci.remove_slot = 1; def->states.pci.remove_slot = true;
} else if (xmlStrEqual(cur->name, BAD_CAST "reprobe")) { } else if (xmlStrEqual(cur->name, BAD_CAST "reprobe")) {
def->states.pci.reprobe = 1; def->states.pci.reprobe = true;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported element '%s' of 'origstates'"), _("unsupported element '%s' of 'origstates'"),
......
...@@ -345,17 +345,17 @@ struct _virDomainHostdevOrigStates { ...@@ -345,17 +345,17 @@ struct _virDomainHostdevOrigStates {
/* Does the device need to unbind from stub when /* Does the device need to unbind from stub when
* reattaching to host? * reattaching to host?
*/ */
unsigned int unbind_from_stub : 1; bool unbind_from_stub;
/* Does it need to use remove_slot when reattaching /* Does it need to use remove_slot when reattaching
* the device to host? * the device to host?
*/ */
unsigned int remove_slot : 1; bool remove_slot;
/* Does it need to reprobe driver for the device when /* Does it need to reprobe driver for the device when
* reattaching to host? * reattaching to host?
*/ */
unsigned int reprobe :1; bool reprobe;
} pci; } pci;
/* Perhaps 'usb' in future */ /* Perhaps 'usb' in future */
......
...@@ -63,14 +63,14 @@ struct _virPCIDevice { ...@@ -63,14 +63,14 @@ struct _virPCIDevice {
unsigned pcie_cap_pos; unsigned pcie_cap_pos;
unsigned pci_pm_cap_pos; unsigned pci_pm_cap_pos;
unsigned has_flr : 1; bool has_flr;
unsigned has_pm_reset : 1; bool has_pm_reset;
bool managed; bool managed;
/* used by reattach function */ /* used by reattach function */
unsigned unbind_from_stub : 1; bool unbind_from_stub;
unsigned remove_slot : 1; bool remove_slot;
unsigned reprobe : 1; bool reprobe;
}; };
struct _virPCIDeviceList { struct _virPCIDeviceList {
...@@ -776,8 +776,8 @@ virPCIDeviceInit(virPCIDevicePtr dev, int cfgfd) ...@@ -776,8 +776,8 @@ virPCIDeviceInit(virPCIDevicePtr dev, int cfgfd)
flr = virPCIDeviceDetectFunctionLevelReset(dev, cfgfd); flr = virPCIDeviceDetectFunctionLevelReset(dev, cfgfd);
if (flr < 0) if (flr < 0)
return flr; return flr;
dev->has_flr = flr; dev->has_flr = !!flr;
dev->has_pm_reset = virPCIDeviceDetectPowerManagementReset(dev, cfgfd); dev->has_pm_reset = !!virPCIDeviceDetectPowerManagementReset(dev, cfgfd);
return 0; return 0;
} }
...@@ -935,7 +935,7 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev, const char *driver) ...@@ -935,7 +935,7 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev, const char *driver)
goto cleanup; goto cleanup;
} }
} }
dev->unbind_from_stub = 0; dev->unbind_from_stub = false;
remove_slot: remove_slot:
if (!dev->remove_slot) if (!dev->remove_slot)
...@@ -952,7 +952,7 @@ remove_slot: ...@@ -952,7 +952,7 @@ remove_slot:
dev->name, driver); dev->name, driver);
goto cleanup; goto cleanup;
} }
dev->remove_slot = 0; dev->remove_slot = false;
reprobe: reprobe:
if (!dev->reprobe) { if (!dev->reprobe) {
...@@ -982,9 +982,9 @@ reprobe: ...@@ -982,9 +982,9 @@ reprobe:
cleanup: cleanup:
/* do not do it again */ /* do not do it again */
dev->unbind_from_stub = 0; dev->unbind_from_stub = false;
dev->remove_slot = 0; dev->remove_slot = false;
dev->reprobe = 0; dev->reprobe = false;
VIR_FREE(drvdir); VIR_FREE(drvdir);
VIR_FREE(path); VIR_FREE(path);
...@@ -999,7 +999,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) ...@@ -999,7 +999,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver)
int result = -1; int result = -1;
char *drvdir = NULL; char *drvdir = NULL;
char *path = NULL; char *path = NULL;
int reprobe = 0; int reprobe = false;
/* check whether the device is already bound to a driver */ /* check whether the device is already bound to a driver */
if (virPCIDriverDir(&drvdir, driver) < 0 || if (virPCIDriverDir(&drvdir, driver) < 0 ||
...@@ -1013,7 +1013,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) ...@@ -1013,7 +1013,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver)
result = 0; result = 0;
goto cleanup; goto cleanup;
} }
reprobe = 1; reprobe = true;
} }
/* Add the PCI device ID to the stub's dynamic ID table; /* Add the PCI device ID to the stub's dynamic ID table;
...@@ -1044,8 +1044,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) ...@@ -1044,8 +1044,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver)
} }
if (virFileLinkPointsTo(path, drvdir)) { if (virFileLinkPointsTo(path, drvdir)) {
dev->unbind_from_stub = 1; dev->unbind_from_stub = true;
dev->remove_slot = 1; dev->remove_slot = true;
goto remove_id; goto remove_id;
} }
...@@ -1087,7 +1087,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) ...@@ -1087,7 +1087,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver)
dev->name, driver); dev->name, driver);
goto remove_id; goto remove_id;
} }
dev->remove_slot = 1; dev->remove_slot = true;
if (virPCIDriverFile(&path, driver, "bind") < 0) { if (virPCIDriverFile(&path, driver, "bind") < 0) {
goto remove_id; goto remove_id;
...@@ -1099,7 +1099,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) ...@@ -1099,7 +1099,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver)
dev->name, driver); dev->name, driver);
goto remove_id; goto remove_id;
} }
dev->unbind_from_stub = 1; dev->unbind_from_stub = true;
} }
remove_id: remove_id:
...@@ -1112,7 +1112,7 @@ remove_id: ...@@ -1112,7 +1112,7 @@ remove_id:
VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " VIR_WARN("Could not remove PCI ID '%s' from %s, and the device "
"cannot be probed again.", dev->id, driver); "cannot be probed again.", dev->id, driver);
} }
dev->reprobe = 0; dev->reprobe = false;
goto cleanup; goto cleanup;
} }
...@@ -1126,7 +1126,7 @@ remove_id: ...@@ -1126,7 +1126,7 @@ remove_id:
VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device "
"cannot be probed again.", dev->id, driver); "cannot be probed again.", dev->id, driver);
} }
dev->reprobe = 0; dev->reprobe = false;
goto cleanup; goto cleanup;
} }
...@@ -1470,9 +1470,9 @@ virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev) ...@@ -1470,9 +1470,9 @@ virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev)
} }
void void
virPCIDeviceSetUnbindFromStub(virPCIDevicePtr dev, unsigned unbind) virPCIDeviceSetUnbindFromStub(virPCIDevicePtr dev, bool unbind)
{ {
dev->unbind_from_stub = !!unbind; dev->unbind_from_stub = unbind;
} }
unsigned unsigned
...@@ -1482,9 +1482,9 @@ virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev) ...@@ -1482,9 +1482,9 @@ virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev)
} }
void void
virPCIDeviceSetRemoveSlot(virPCIDevicePtr dev, unsigned remove_slot) virPCIDeviceSetRemoveSlot(virPCIDevicePtr dev, bool remove_slot)
{ {
dev->remove_slot = !!remove_slot; dev->remove_slot = remove_slot;
} }
unsigned unsigned
...@@ -1494,9 +1494,9 @@ virPCIDeviceGetReprobe(virPCIDevicePtr dev) ...@@ -1494,9 +1494,9 @@ virPCIDeviceGetReprobe(virPCIDevicePtr dev)
} }
void void
virPCIDeviceSetReprobe(virPCIDevicePtr dev, unsigned reprobe) virPCIDeviceSetReprobe(virPCIDevicePtr dev, bool reprobe)
{ {
dev->reprobe = !!reprobe; dev->reprobe = reprobe;
} }
void void
...@@ -1513,9 +1513,9 @@ virPCIDeviceGetUsedBy(virPCIDevicePtr dev) ...@@ -1513,9 +1513,9 @@ virPCIDeviceGetUsedBy(virPCIDevicePtr dev)
void virPCIDeviceReattachInit(virPCIDevicePtr pci) void virPCIDeviceReattachInit(virPCIDevicePtr pci)
{ {
pci->unbind_from_stub = 1; pci->unbind_from_stub = true;
pci->remove_slot = 1; pci->remove_slot = true;
pci->reprobe = 1; pci->reprobe = true;
} }
......
...@@ -68,13 +68,13 @@ void virPCIDeviceSetUsedBy(virPCIDevice *dev, ...@@ -68,13 +68,13 @@ void virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *virPCIDeviceGetUsedBy(virPCIDevice *dev); const char *virPCIDeviceGetUsedBy(virPCIDevice *dev);
unsigned virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev); unsigned virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev);
void virPCIDeviceSetUnbindFromStub(virPCIDevice *dev, void virPCIDeviceSetUnbindFromStub(virPCIDevice *dev,
unsigned unbind); bool unbind);
unsigned virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev); unsigned virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev);
void virPCIDeviceSetRemoveSlot(virPCIDevice *dev, void virPCIDeviceSetRemoveSlot(virPCIDevice *dev,
unsigned remove_slot); bool remove_slot);
unsigned virPCIDeviceGetReprobe(virPCIDevicePtr dev); unsigned virPCIDeviceGetReprobe(virPCIDevicePtr dev);
void virPCIDeviceSetReprobe(virPCIDevice *dev, void virPCIDeviceSetReprobe(virPCIDevice *dev,
unsigned reprobe); bool reprobe);
void virPCIDeviceReattachInit(virPCIDevice *dev); void virPCIDeviceReattachInit(virPCIDevice *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册