Skip to content

Commit

Permalink
Fix warnings due to unused fread result.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kestrel Gregorich-Trevor committed Jan 18, 2024
1 parent 76ea03b commit 12a50bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct cJSON* json_from_file(const char *fname) {
len = ftell(fp);
fseek(fp, 0, SEEK_SET);
buf = (char *) malloc(len + 1);
fread(buf, 1, len, fp);
(void) fread(buf, 1, len, fp);
buf[len] = '\0';
fclose(fp);
/* Parse the file into JSON. */
Expand Down
18 changes: 9 additions & 9 deletions src/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ void load_game(const char *fname) {
return;
}
/* Read the global struct */
fread(&g, sizeof(struct global), 1, fp);
(void) fread(&g, sizeof(struct global), 1, fp);
/* Clean up message pointers. We could save the message log fairly easily,
but it would take up a lot of space, so we don't. */
g.msg_list = NULL;
g.msg_last = NULL;
/* Read level map */
for (int y = 0; y < MAPH; y++) {
for (int x = 0; x < MAPW; x++) {
fread(&tile_id, sizeof(int), 1, fp);
(void) fread(&tile_id, sizeof(int), 1, fp);
g.levmap[x][y].pt = &permtiles[tile_id];
g.levmap[x][y].actor = NULL;
g.levmap[x][y].item_actor = NULL;
Expand All @@ -239,7 +239,7 @@ void load_game(const char *fname) {
g.items[i] = load_actor(fp, g.items[i]);
}
/* Read actors */
fread(&actor_count, sizeof(int), 1, fp);
(void) fread(&actor_count, sizeof(int), 1, fp);
cur_actor = g.player;
addr = &g.player;
for (int i = 0; i < actor_count; i++) {
Expand Down Expand Up @@ -273,23 +273,23 @@ struct actor *load_actor(FILE *fp, struct actor *actor) {
struct actor **addr;

actor = (struct actor *) malloc(sizeof(struct actor));
fread(actor, sizeof(struct actor), 1, fp);
(void) fread(actor, sizeof(struct actor), 1, fp);
if (actor->name) {
actor->name = (struct name *) malloc(sizeof(struct name));
fread(actor->name, sizeof(struct name), 1, fp);
(void) fread(actor->name, sizeof(struct name), 1, fp);
}
if (actor->ai) {
actor->ai = (struct ai *) malloc(sizeof(struct ai));
fread(actor->ai, sizeof(struct ai), 1, fp);
(void) fread(actor->ai, sizeof(struct ai), 1, fp);
actor->ai->parent = actor;
}
if (actor->equip) {
actor->equip = (struct equip *) malloc(sizeof(struct equip));
fread(actor->equip, sizeof(struct equip), 1, fp);
(void) fread(actor->equip, sizeof(struct equip), 1, fp);
actor->equip->parent = actor;
}
if (actor->invent) {
fread(&item_count, sizeof(int), 1, fp);
(void) fread(&item_count, sizeof(int), 1, fp);
cur_item = actor->invent;
addr = &(actor->invent);
for (int i = 0; i < item_count; i++) {
Expand All @@ -305,7 +305,7 @@ struct actor *load_actor(FILE *fp, struct actor *actor) {
}
if (actor->item) {
actor->item = (struct item *) malloc(sizeof(struct item));
fread(actor->item, sizeof(struct item), 1, fp);
(void) fread(actor->item, sizeof(struct item), 1, fp);
actor->item->parent = actor;
}
actor->saved = 0;
Expand Down

0 comments on commit 12a50bd

Please sign in to comment.