Clean-up: tests: unchecked closedir value in test_fd_tracker
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 25 Nov 2019 22:01:19 +0000 (17:01 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 25 Nov 2019 22:06:17 +0000 (17:06 -0500)
closedir's return value is not checked in a utility function
of the test_fd_tracker unit test.

1407702 Unchecked return value
If the function returns an error value, the error value may be mistaken for a normal value.
In fd_count: Value returned from a function is not checked for errors before being used (CWE-252)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/unit/test_fd_tracker.c

index 8c0fc5ffe90a4dcc8b5052adf0dd99c7743122af..fe14e9c5cf26417972a964c2747c9d9c9fb10d9d 100644 (file)
@@ -83,7 +83,9 @@ int fd_count(void)
        }
        /* Don't account for the file descriptor opened by opendir(). */
         count--;
-       closedir(dir);
+       if (closedir(dir)) {
+               perror("# Failed to close test program's self/fd directory file descriptor");
+       }
 end:
        return count;
 }
This page took 0.025603 seconds and 4 git commands to generate.