From: sECuRE Date: Sun, 30 Nov 2008 11:15:08 +0000 (+0000) Subject: Check if read < 0 X-Git-Tag: rgb2rv6~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d73ed8261b68d51c185df199f943658a13122171;p=c128-kasse Check if read < 0 git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@89 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/src/kasse.c b/src/kasse.c index c82faa9..eb1cf18 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -59,7 +59,7 @@ static void log_file(const char *s) { lines, we don't need more than 100 * 64 bytes. */ char *buffer = malloc(sizeof(char) * 64 * 100); char filename[8]; - char read = 0; + int read = 0; unsigned int c; if (buffer == NULL) { cprintf("No memory available\n"); @@ -82,7 +82,10 @@ static void log_file(const char *s) { c128_perror(c, "cbm_open(log)"); sane_exit(); } - /* TODO: read < 0? */ + if (read < 0) { + cprintf("Could not read existing logfile (read returned %d)\n", read); + sane_exit(); + } strcpy(buffer+read, s); c = cbm_write((BYTE)8, buffer, read+strlen(s)); if (c != (read+strlen(s))) {