mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-23 06:23:10 +00:00
tests: hostdev: Move variable declaration inside CHECK_LIST_COUNT()
The 'actualCount' variable, formerly just 'count', is only used internally by the macro, so it's better to move its declaration inside the macro as well: this way, it doesn't have to be declared by every single user. The new name is less generic to make clashes less likely.
This commit is contained in:
parent
dd9f8e0292
commit
ff087d8dae
@ -38,12 +38,15 @@
|
|||||||
VIR_LOG_INIT("tests.hostdevtest");
|
VIR_LOG_INIT("tests.hostdevtest");
|
||||||
|
|
||||||
# define CHECK_LIST_COUNT(list, cnt) \
|
# define CHECK_LIST_COUNT(list, cnt) \
|
||||||
if ((count = virPCIDeviceListCount(list)) != cnt) { \
|
do { \
|
||||||
|
int actualCount; \
|
||||||
|
if ((actualCount = virPCIDeviceListCount(list)) != cnt) { \
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||||
"Unexpected count of items in " #list ": %d, " \
|
"Unexpected count of items in " #list ": %d, " \
|
||||||
"expecting %zu", count, (size_t) cnt); \
|
"expecting %zu", actualCount, (size_t) cnt); \
|
||||||
goto cleanup; \
|
goto cleanup; \
|
||||||
}
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
# define TEST_STATE_DIR abs_builddir "/hostdevmgr"
|
# define TEST_STATE_DIR abs_builddir "/hostdevmgr"
|
||||||
static const char *drv_name = "test_driver";
|
static const char *drv_name = "test_driver";
|
||||||
@ -161,7 +164,7 @@ testVirHostdevPreparePCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, active_count, inactive_count;
|
int active_count, inactive_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++)
|
for (i = 0; i < nhostdevs; i++)
|
||||||
hostdevs[i]->managed = false;
|
hostdevs[i]->managed = false;
|
||||||
@ -220,7 +223,7 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, active_count, inactive_count;
|
int active_count, inactive_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
if (hostdevs[i]->managed != false) {
|
if (hostdevs[i]->managed != false) {
|
||||||
@ -254,7 +257,7 @@ testVirHostdevPreparePCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, active_count;
|
int active_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++)
|
for (i = 0; i < nhostdevs; i++)
|
||||||
hostdevs[i]->managed = true;
|
hostdevs[i]->managed = true;
|
||||||
@ -300,7 +303,7 @@ testVirHostdevReAttachPCIHostdevs_managed(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, active_count;
|
int active_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
if (hostdevs[i]->managed != true) {
|
if (hostdevs[i]->managed != true) {
|
||||||
@ -332,7 +335,7 @@ testVirHostdevDetachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, inactive_count;
|
int inactive_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
||||||
@ -369,7 +372,7 @@ testVirHostdevReAttachPCINodeDevice(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count, inactive_count;
|
int inactive_count;
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
||||||
@ -389,7 +392,7 @@ static int
|
|||||||
testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED)
|
testVirHostdevUpdateActivePCIHostdevs(const void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int count, active_count;
|
int active_count;
|
||||||
|
|
||||||
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user