From d05bb49f5d41c713cefdcfd2496a5e207cf5e1df Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Fri, 23 Mar 2018 21:25:55 +0100 Subject: [PATCH] Add more assertions. Change prototype of fputs to return the error / success status. --- m-string.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/m-string.h b/m-string.h index e9ac64eb..2743084c 100644 --- a/m-string.h +++ b/m-string.h @@ -616,6 +616,7 @@ static inline bool string_fgets(string_t v, FILE *f, string_fgets_t arg) { STRINGI_CONTRACT(v); + assert (f != NULL); stringi_fit2size (v, 100); M_ASSUME(v->ptr != NULL); v->size = 0; @@ -648,6 +649,7 @@ string_fget_word (string_t v, const char separator[], FILE *f) char buffer[128]; char c = 0; STRINGI_CONTRACT(v); + assert (f != NULL); assert (1+20+2+strlen(separator)+3 < sizeof buffer); stringi_fit2size (v, 10); v->size = 0; @@ -678,11 +680,12 @@ string_fget_word (string_t v, const char separator[], FILE *f) return retcode; } -static inline void +static inline bool string_fputs(FILE *f, const string_t v) { STRINGI_CONTRACT (v); - fputs(string_get_cstr(v), f); + assert (f != NULL); + return fputs(string_get_cstr(v), f) >= 0; } static inline bool