From: Kevin Day Date: Fri, 13 May 2022 23:26:19 +0000 (-0500) Subject: Update: Improvements exposed when writing unit tests. X-Git-Tag: 0.5.10~143 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=fa6f3ed4b263dfe524305a79d55ea9c8de9be5fc;p=fll Update: Improvements exposed when writing unit tests. Make sure to call memset on structure. Minor style clean ups. --- 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.