From: Jérémie Galarneau Date: Mon, 25 Nov 2019 22:01:19 +0000 (-0500) Subject: Clean-up: tests: unchecked closedir value in test_fd_tracker X-Git-Tag: v2.12.0-rc1~216 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e0efb2c893443a33b724cf79afb963cfb4ac87f7;p=lttng-tools.git Clean-up: tests: unchecked closedir value in test_fd_tracker 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 --- diff --git a/tests/unit/test_fd_tracker.c b/tests/unit/test_fd_tracker.c index 8c0fc5ffe..fe14e9c5c 100644 --- a/tests/unit/test_fd_tracker.c +++ b/tests/unit/test_fd_tracker.c @@ -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; }