summaryrefslogtreecommitdiff
path: root/tools/palette.c
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2017-12-28 01:31:00 -0500
committerGitHub <noreply@github.com>2017-12-28 01:31:00 -0500
commite2b378f5e32ea1416fbc9ac5e96d23be244e4a6b (patch)
tree70fd1d4709150af457258763be04960931acd95b /tools/palette.c
parentda28d1a84b0499bead314e17ae2ff0d13eb03196 (diff)
parent9af2aee640b555f9f52503233bc06d299b99974d (diff)
Merge pull request #442 from yenatch/fix-fread
fix fread warnings
Diffstat (limited to 'tools/palette.c')
-rw-r--r--tools/palette.c15
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]);
}
}