
On 03/07/2016 12:24 PM, Andrea Bolognani wrote:
This variable is only used internally by the macro, so it's better to move its definition inside the macro as well. --- tests/virhostdevtest.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index febb2c9..77b119b 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -37,13 +37,16 @@
VIR_LOG_INIT("tests.hostdevtest");
-# define CHECK_LIST_COUNT(list, cnt) \ - if ((count = virPCIDeviceListCount(list)) != cnt) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, \ - "Unexpected count of items in " #list ": %d, " \ - "expecting %zu", count, (size_t) cnt); \ - goto cleanup; \ - } +# define CHECK_LIST_COUNT(list, cnt) \ + do { \ + int count; \ + if ((count = virPCIDeviceListCount(list)) != cnt) { \ + virReportError(VIR_ERR_INTERNAL_ERROR, \ + "Unexpected count of items in " #list ": %d, " \ + "expecting %zu", count, (size_t) cnt); \ + goto cleanup; \ + } \ + } while (0)
The only suggestion I would have is to make "count" something less common, so that you're less likely to end up causing a compiler warning later if someone adds a variable called "count" to a function that uses this macro. Otherwise ACK.