shithub: choc

Download patch

ref: 90aec9de758dbb178dc19c146d3b0fb22b99342b
parent: 25d920925361c1e70dbd73afd08a0b836080f2f1
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue May 5 08:11:25 EDT 2015

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!

--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -346,7 +346,7 @@
 
     // 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 @@
 
     // 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 @@
 {
     // 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 @@
 
     // 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 @@
     // 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 @@
 
     // mobjinfo_t *info;
     // Pointer value is read but discarded.
-    GET_LONG;
+    str->info = (void *) (intptr_t) GET_LONG;
     str->info = NULL;
 
     // int tics;