From fa6f3ed4b263dfe524305a79d55ea9c8de9be5fc Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 13 May 2022 18:26:19 -0500 Subject: [PATCH] Update: Improvements exposed when writing unit tests. Make sure to call memset on structure. Minor style clean ups. --- level_0/f_pipe/c/pipe.c | 12 ++++++++++++ level_0/f_pipe/c/pipe.h | 1 + 2 files changed, 13 insertions(+) diff --git a/level_0/f_pipe/c/pipe.c b/level_0/f_pipe/c/pipe.c index dba59d9..d74c002 100644 --- a/level_0/f_pipe/c/pipe.c +++ b/level_0/f_pipe/c/pipe.c @@ -6,8 +6,11 @@ extern "C" { #ifndef _di_f_pipe_input_exists_ f_status_t f_pipe_input_exists(void) { + struct stat st_info; + memset(&st_info, 0, sizeof(struct stat)); + if (fstat(F_type_descriptor_input_d, &st_info) != 0) { return F_status_set_error(F_file_stat); } @@ -22,8 +25,11 @@ extern "C" { #ifndef _di_f_pipe_warning_exists_ f_status_t f_pipe_warning_exists(void) { + struct stat st_info; + memset(&st_info, 0, sizeof(struct stat)); + if (fstat(F_type_descriptor_warning_d, &st_info) != 0) { return F_status_set_error(F_file_stat); } @@ -38,8 +44,11 @@ extern "C" { #ifndef _di_f_pipe_error_exists_ f_status_t f_pipe_error_exists(void) { + struct stat st_info; + memset(&st_info, 0, sizeof(struct stat)); + if (fstat(F_type_descriptor_error_d, &st_info) != 0) { return F_status_set_error(F_file_stat); } @@ -54,8 +63,11 @@ extern "C" { #ifndef _di_f_pipe_debug_exists_ f_status_t f_pipe_debug_exists(void) { + struct stat st_info; + memset(&st_info, 0, sizeof(struct stat)); + if (fstat(F_type_descriptor_debug_d, &st_info) != 0) { return F_status_set_error(F_file_stat); } diff --git a/level_0/f_pipe/c/pipe.h b/level_0/f_pipe/c/pipe.h index 21312e2..ca932e5 100644 --- a/level_0/f_pipe/c/pipe.h +++ b/level_0/f_pipe/c/pipe.h @@ -14,6 +14,7 @@ // Libc includes. #include +#include #include // FLL-0 includes. -- 1.8.3.1