From: Eric S. Raymond Date: Sat, 1 Jul 2017 12:35:05 +0000 (-0400) Subject: Without IGNORE, -Wunused-result throws a warning on fread(2). X-Git-Tag: takebird~165 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=58b44313d33a39285d394b7704d80823f4d15763;p=open-adventure.git Without IGNORE, -Wunused-result throws a warning on fread(2). I've seen it happen on fwrite(2) as well; wrapping that as well in case some compiler decides to be finicky. --- diff --git a/saveresume.c b/saveresume.c index e6c0b0a..3ec4ebd 100644 --- a/saveresume.c +++ b/saveresume.c @@ -26,6 +26,8 @@ struct save_t { }; struct save_t save; +#define IGNORE(r) do{if (r){}}while(0) + int savefile(FILE *fp, long version) /* Save game to file. No input or output from user. */ { @@ -38,7 +40,7 @@ int savefile(FILE *fp, long version) save.version = (version == 0) ? VRSION : version; memcpy(&save.game, &game, sizeof(struct game_t)); - fwrite(&save, sizeof(struct save_t), 1, fp); + IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp)); return (0); } @@ -114,7 +116,7 @@ int restore(FILE* fp) return GO_UNKNOWN; #endif - fread(&save, sizeof(struct save_t), 1, fp); + IGNORE(fread(&save, sizeof(struct save_t), 1, fp)); fclose(fp); if (save.version != VRSION) { rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10));