From 772da5c161b6952d1ecf2ab07ed9d6b06817956e Mon Sep 17 00:00:00 2001 From: avan989 Date: Tue, 10 Sep 2019 09:54:42 -0400 Subject: [PATCH] Table CRC Tool Fails To Close File Descriptor, # 1 (#5) Fix #1, Close file descriptor --- cfe_ts_crc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cfe_ts_crc.c b/cfe_ts_crc.c index 4fb5b87..1ef3561 100644 --- a/cfe_ts_crc.c +++ b/cfe_ts_crc.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include "cfe_tbl_filedef.h" #include "cfe_fs.h" @@ -175,7 +177,14 @@ int main( int argc, char **argv ) if (readSize != 100) done=1; } /* print the size/CRC results */ - printf("\nTable File Name: %s\nTable Size: %d Bytes\nExpected TS Validation CRC: 0x%08X\n\n", argv[1], fileSize, fileCRC); + printf("\nTable File Name: %s\nTable Size: %d Bytes\nExpected TS Validation CRC: 0x%08X\n\n", argv[1], fileSize, fileCRC); - return(fileCRC); + /* Close file and check*/ + if( close(fd) != 0 ) + { + printf("\nerror: Cannot close file!\n"); + exit(0); + } + + return(fileCRC); }