Skip to content

Commit

Permalink
Improve 'LogError'
Browse files Browse the repository at this point in the history
- `REvprintf()` returns void unlike `vfprintf()`; thus we cannot check
for EOF
  • Loading branch information
dschlaep committed Dec 7, 2017
1 parent bfb4897 commit 6c1ae9f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void LogError(FILE *fp, const int mode, const char *fmt, ...) {

char outfmt[50 + strlen(fmt)]; /* to prepend err type str */
va_list args;
int check_eof;
int check_eof = 0;

va_start(args, fmt);

Expand All @@ -214,22 +214,19 @@ void LogError(FILE *fp, const int mode, const char *fmt, ...) {
strcat(outfmt, "\n");

#ifdef RSOILWAT
check_eof = TRUE;
if (!isNull(fp) {
REvprintf(outfmt, args);
}

#else
check_eof = (EOF == vfprintf(fp, outfmt, args));
#endif

if (check_eof)
sw_error(0, "SYSTEM: Cannot write to FILE *fp in LogError()\n");

#ifndef RSOILWAT
if (check_eof)
sw_error(0, "SYSTEM: Cannot write to FILE *fp in LogError()\n");
fflush(fp);
#endif


logged = TRUE;
va_end(args);

Expand Down

0 comments on commit 6c1ae9f

Please sign in to comment.