From 09ba59ebce471cb46dcd156224d6c18765f8c4d5 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 16 Jul 2023 10:25:57 +0200 Subject: Verschiedene Casts hinzugefügt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/csv.c b/csv.c index 0a41e9e..d36eb63 100644 --- a/csv.c +++ b/csv.c @@ -48,7 +48,7 @@ csv_mem_allocate(size_t n, size_t sz, void *cb_arg) { UNUSED(cb_arg); - size_t len; + size_t len = 0; if ( n == 0 || sz == 0 || mul_overflow(n, sz, &len) ) { return NULL; } @@ -60,7 +60,7 @@ csv_mem_reallocate(void *ptr, size_t n, size_t sz, void *cb_arg) { UNUSED(cb_arg); - size_t len; + size_t len = 0; if ( n == 0 || sz == 0 || mul_overflow(n, sz, &len) ) { return NULL; } @@ -96,7 +96,7 @@ csv_fatal_error(csv_err_t csv_err, const csv_options_t *const csv_options) if ( csv_options->cb_error != NULL ) { (*csv_options->cb_error)(csv_err, csv_options->cb_error_arg); } - fprintf(stderr, "fatal error: %s\n", csv_err_str(csv_err)); + (void) fprintf(stderr, "fatal error: %s\n", csv_err_str(csv_err)); abort(); } @@ -129,7 +129,7 @@ csv_string_isempty(csv_string_t *csv_string) } static inline void -csv_string_append(csv_string_t *csv_string, char ch, const csv_options_t *const csv_options) +csv_string_append(csv_string_t *csv_string, int ch, const csv_options_t *const csv_options) { assert(csv_string != NULL); assert(csv_options != NULL); @@ -146,7 +146,7 @@ csv_string_append(csv_string_t *csv_string, char ch, const csv_options_t *const } else { // subsequent call size_t cap = (csv_string->cap * 3) / 2; // *= 1.5 - char * str = csv_options->cb_reallocate(csv_string->str, cap, 1, csv_options->cb_memory_arg); + char *str = csv_options->cb_reallocate(csv_string->str, cap, 1, csv_options->cb_memory_arg); if ( str == NULL ) { csv_fatal_error(CSV_ERR_OUT_OF_MEMORY, csv_options); return; @@ -156,7 +156,7 @@ csv_string_append(csv_string_t *csv_string, char ch, const csv_options_t *const } } - csv_string->str[csv_string->pos++] = ch; // append char + csv_string->str[csv_string->pos++] = (char) ch; // append char } static inline void @@ -341,7 +341,7 @@ csv_read(csv_t *csv, FILE *in) else if ( ch == '\r' ) { // test for CR.. ch = getc(in); if ( ch != '\n' ) { // ..LF - ungetc(ch, in); + (void) ungetc(ch, in); } state = STATE_END_LINE; } @@ -382,7 +382,7 @@ csv_read(csv_t *csv, FILE *in) else if ( ch == '\r' ) { ch = getc(in); if ( ch != '\n' ) { - ungetc(ch, in); + (void) ungetc(ch, in); } state = STATE_END_LINE; } @@ -391,7 +391,7 @@ csv_read(csv_t *csv, FILE *in) } else { csv_string_append(&csv->csv_string, DELIM, csv->csv_options); - ungetc(ch, in); // we have read too far... Put the character back! + (void) ungetc(ch, in); // we have read too far... Put the character back! } } else { @@ -414,7 +414,7 @@ csv_read(csv_t *csv, FILE *in) else if ( ch == '\r' ) { ch = getc(in); if ( ch != '\n' ) { - ungetc(ch, in); + (void) ungetc(ch, in); } state = STATE_END_LINE; } -- cgit v1.3