[lxc-devel] [PATCH 7/7] coverity: Check return value from open

Stéphane Graber stgraber at ubuntu.com
Wed Feb 12 21:45:56 UTC 2014


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/tests/concurrent.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/tests/concurrent.c b/src/tests/concurrent.c
index bcb5f2c..6d89990 100644
--- a/src/tests/concurrent.c
+++ b/src/tests/concurrent.c
@@ -190,6 +190,11 @@ int main(int argc, char *argv[]) {
     for (iter = 1; iter <= iterations; iter++) {
         int fd;
         fd = open("/", O_RDONLY);
+        if (fd < 0) {
+            fprintf(stderr, "Failed to open /\n");
+            continue;
+        }
+
         if (!quiet)
             printf("\nIteration %d/%d maxfd:%d\n", iter, iterations, fd);
         close(fd);
-- 
1.9.rc1



More information about the lxc-devel mailing list