From 90aec9de758dbb178dc19c146d3b0fb22b99342b Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 5 May 2015 12:11:25 +0200 Subject: warnings: fix "value computed is not used" warnings This fixes warnings that are caused by calling GET_LONG without using its return value, e.g.: sv_save.c: In function ‘StreamIn_player_t’: ../../src/i_swap.h:34:20: warning: value computed is not used [-Wunused-value] #define LONG(x) ((signed int) SDL_SwapLE32(x)) ^ sv_save.c:33:18: note: in expansion of macro ‘LONG’ #define GET_LONG LONG(*SavePtr.l++) ^ sv_save.c:349:5: note: in expansion of macro ‘GET_LONG’ GET_LONG; ^ Introducing a "long dummy" variable and calling "dummy = GET_LONG" does not help, because this provokes another warning, rightfully so: sv_save.c: In function ‘StreamIn_player_t’: sv_save.c:346:10: warning: variable ‘dummy’ set but not used [-Wunused-but-set-variable] long dummy; Assigning the return value directly to the struct field results in: sv_save.c: In function ‘StreamIn_player_t’: sv_save.c:349:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion] str->mo = GET_LONG; Adding the cast to "(void *)" results in: sv_save.c: In function ‘StreamIn_player_t’: sv_save.c:349:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] str->mo = (void *) GET_LONG; Adding the intermediate cast to "(intptr_t)" finally silences the compiler. Phew! --- src/hexen/sv_save.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hexen/sv_save.c b/src/hexen/sv_save.c index 7837b837..8fa211d8 100644 --- a/src/hexen/sv_save.c +++ b/src/hexen/sv_save.c @@ -346,7 +346,7 @@ static void StreamIn_player_t(player_t *str) // mobj_t *mo; // Pointer value is reset on load. - GET_LONG; + str->mo = (void *) (intptr_t) GET_LONG; str->mo = NULL; // playerstate_t playerstate; @@ -478,12 +478,12 @@ static void StreamIn_player_t(player_t *str) // mobj_t *poisoner; // Pointer value is reset. - GET_LONG; + str->poisoner = (void *) (intptr_t) GET_LONG; str->poisoner = NULL; // mobj_t *attacker; // Pointer value is reset. - GET_LONG; + str->attacker = (void *) (intptr_t) GET_LONG; str->attacker = NULL; // int extralight; @@ -685,14 +685,14 @@ static void StreamIn_thinker_t(thinker_t *str) { // struct thinker_s *prev, *next; // Pointers are discarded: - GET_LONG; + str->prev = (void *) (intptr_t) GET_LONG; str->prev = NULL; - GET_LONG; + str->next = (void *) (intptr_t) GET_LONG; str->next = NULL; // think_t function; // Function pointer is discarded: - GET_LONG; + str->function = (void *) (intptr_t) GET_LONG; str->function = NULL; } @@ -766,9 +766,9 @@ static void StreamIn_mobj_t(mobj_t *str) // struct mobj_s *snext, *sprev; // Pointer values are discarded: - GET_LONG; + str->snext = (void *) (intptr_t) GET_LONG; str->snext = NULL; - GET_LONG; + str->sprev = (void *) (intptr_t) GET_LONG; str->sprev = NULL; // angle_t angle; @@ -783,14 +783,14 @@ static void StreamIn_mobj_t(mobj_t *str) // struct mobj_s *bnext, *bprev; // Values are read but discarded; this will be restored when the thing's // position is set. - GET_LONG; + str->bnext = (void *) (intptr_t) GET_LONG; str->bnext = NULL; - GET_LONG; + str->bprev = (void *) (intptr_t) GET_LONG; str->bprev = NULL; // struct subsector_s *subsector; // Read but discard: pointer will be restored when thing position is set. - GET_LONG; + str->subsector = (void *) (intptr_t) GET_LONG; str->subsector = NULL; // fixed_t floorz, ceilingz; @@ -817,7 +817,7 @@ static void StreamIn_mobj_t(mobj_t *str) // mobjinfo_t *info; // Pointer value is read but discarded. - GET_LONG; + str->info = (void *) (intptr_t) GET_LONG; str->info = NULL; // int tics; -- cgit v1.2.3