diff options
author | yenatch <yenatch@gmail.com> | 2017-12-28 01:25:25 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2017-12-28 01:25:25 -0500 |
commit | 40305f205e75f1d6d7ad1ee11d57b5d72a783270 (patch) | |
tree | b36dc0c971cce4ab4f487949a4e02bf19db9f229 /tools/palette.c | |
parent | bad9e33530af8cdc29ce5629df682fc7915bfff0 (diff) |
fix unused fread return value warnings
Diffstat (limited to 'tools/palette.c')
-rw-r--r-- | tools/palette.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/palette.c b/tools/palette.c index 397c62651..9b575efdc 100644 --- a/tools/palette.c +++ b/tools/palette.c @@ -29,7 +29,11 @@ void print_pokemon_palette(char* palette_filename) { } fseek(f, 2, SEEK_SET); - fread(bytes, 1, 4, f); + size_t size = 4; + if (size != fread(bytes, 1, size, f)) { + fprintf(stderr, "failed to read file %s\n", palette_filename); + exit(1); + } fclose(f); print_rgb((bytes[1] << 8) | bytes[0]); @@ -39,7 +43,7 @@ void print_pokemon_palette(char* palette_filename) { void print_palette(char* palette_filename) { FILE* f; uint8_t* bytes; - long size; + size_t size; int i; f = fopen(palette_filename, "rb"); @@ -63,10 +67,13 @@ void print_palette(char* palette_filename) { } fseek(f, 0, SEEK_SET); - fread(bytes, 1, size, f); + if (size != fread(bytes, 1, size, f)) { + fprintf(stderr, "failed to read file %s\n", palette_filename); + exit(1); + } fclose(f); - for (i = 0; i + 1 < size; i += 2) { + for (i = 0; i + 1 < (int)size; i += 2) { print_rgb((bytes[i + 1] << 8) | bytes[i]); } } |