From a3157f3c75e22240231eb285ad35507647bdaf2c Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Tue, 11 Nov 2014 07:14:20 +0530 Subject: [PATCH] [master] close() fd when done (Coverity report) --- lib/isc/tests/file_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/isc/tests/file_test.c b/lib/isc/tests/file_test.c index a6f55ef455..b252b50580 100644 --- a/lib/isc/tests/file_test.c +++ b/lib/isc/tests/file_test.c @@ -46,6 +46,7 @@ ATF_TC_HEAD(isc_file_sanitize, tc) { ATF_TC_BODY(isc_file_sanitize, tc) { isc_result_t result; char buf[1024]; + int fd; ATF_CHECK(chdir(TESTS) != -1); @@ -56,15 +57,19 @@ ATF_TC_BODY(isc_file_sanitize, tc) { ATF_CHECK_EQ(result, ISC_R_SUCCESS); ATF_CHECK(strcmp(buf, F(NAME)) == 0); - ATF_CHECK(creat(F(TRUNC_SHA), 0644) != -1); + fd = creat(F(TRUNC_SHA), 0644); + ATF_CHECK(fd != -1); result = isc_file_sanitize("testdata/file", NAME, "test", buf, 1024); ATF_CHECK_EQ(result, ISC_R_SUCCESS); ATF_CHECK(strcmp(buf, F(TRUNC_SHA)) == 0); + close(fd); - ATF_CHECK(creat(F(SHA), 0644) != -1); + fd = creat(F(SHA), 0644); + ATF_CHECK(fd != -1); result = isc_file_sanitize("testdata/file", NAME, "test", buf, 1024); ATF_CHECK_EQ(result, ISC_R_SUCCESS); ATF_CHECK(strcmp(buf, F(SHA)) == 0); + close(fd); result = isc_file_sanitize("testdata/file", BAD1, "test", buf, 1024); ATF_CHECK_EQ(result, ISC_R_SUCCESS);