[libvirt] [PATCH RFC 6/8] fdstreamtest: switch from boolean array to @flags

Michal Privoznik mprivozn at redhat.com
Fri Jan 29 13:26:57 UTC 2016


This is no functional change, it just merely prepares
environment for next patch.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tests/fdstreamtest.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c
index 56ba5d9..f9caebf 100644
--- a/tests/fdstreamtest.c
+++ b/tests/fdstreamtest.c
@@ -40,7 +40,8 @@ VIR_LOG_INIT("tests.fdstreamtest");
 
 #define PATTERN_LEN 256
 
-static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
+static int
+testFDStreamReadCommon(const char *scratchdir, const unsigned int flags)
 {
     int fd = -1;
     char *file = NULL;
@@ -50,10 +51,9 @@ static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
     virStreamPtr st = NULL;
     size_t i;
     virConnectPtr conn = NULL;
-    int flags = 0;
+    bool blocking = !(flags & VIR_STREAM_NONBLOCK);
 
-    if (!blocking)
-        flags |= VIR_STREAM_NONBLOCK;
+    virCheckFlags(VIR_STREAM_NONBLOCK, -1);
 
     if (!(conn = virConnectOpen("test:///default")))
         goto cleanup;
@@ -164,15 +164,15 @@ static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
 
 static int testFDStreamReadBlock(const void *data)
 {
-    return testFDStreamReadCommon(data, true);
+    return testFDStreamReadCommon(data, 0);
 }
 static int testFDStreamReadNonblock(const void *data)
 {
-    return testFDStreamReadCommon(data, false);
+    return testFDStreamReadCommon(data, VIR_STREAM_NONBLOCK);
 }
 
 
-static int testFDStreamWriteCommon(const char *scratchdir, bool blocking)
+static int testFDStreamWriteCommon(const char *scratchdir, const unsigned int flags)
 {
     int fd = -1;
     char *file = NULL;
@@ -182,10 +182,9 @@ static int testFDStreamWriteCommon(const char *scratchdir, bool blocking)
     virStreamPtr st = NULL;
     size_t i;
     virConnectPtr conn = NULL;
-    int flags = 0;
+    bool blocking = !(flags & VIR_STREAM_NONBLOCK);
 
-    if (!blocking)
-        flags |= VIR_STREAM_NONBLOCK;
+    virCheckFlags(VIR_STREAM_NONBLOCK, -1);
 
     if (!(conn = virConnectOpen("test:///default")))
         goto cleanup;
-- 
2.4.10




More information about the libvir-list mailing list