[Commits] SDL: SDL_test_fuzzer.c: fix strict aliasing warnings by using a ...

libsdl.org revision control commits-owner at libsdl.org
Sun Feb 25 09:45:46 PST 2018


details:   https://hg.libsdl.org/SDL/rev/732b6ef4aae7
changeset: 11903:732b6ef4aae7
user:      Ozkan Sezer <sezero at users.sourceforge.net>
date:      Sun Feb 25 10:15:00 2018 +0300
description:
SDL_test_fuzzer.c: fix strict aliasing warnings by using a union.

diffstat:

 src/test/SDL_test_fuzzer.c |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r ce4bc0462ae5 -r 732b6ef4aae7 src/test/SDL_test_fuzzer.c
--- a/src/test/SDL_test_fuzzer.c	Sat Feb 24 09:09:20 2018 -0800
+++ b/src/test/SDL_test_fuzzer.c	Sun Feb 25 10:15:00 2018 +0300
@@ -126,29 +126,35 @@
 Uint64
 SDLTest_RandomUint64()
 {
-    Uint64 value = 0;
-    Uint32 *vp = (void *)&value;
+    union {
+        Uint64 v64;
+        Uint32 v32[2];
+    } value;
+    value.v64 = 0;
 
     fuzzerInvocationCounter++;
 
-    vp[0] = SDLTest_RandomSint32();
-    vp[1] = SDLTest_RandomSint32();
+    value.v32[0] = SDLTest_RandomSint32();
+    value.v32[1] = SDLTest_RandomSint32();
 
-    return value;
+    return value.v64;
 }
 
 Sint64
 SDLTest_RandomSint64()
 {
-    Uint64 value = 0;
-    Uint32 *vp = (void *)&value;
+    union {
+        Uint64 v64;
+        Uint32 v32[2];
+    } value;
+    value.v64 = 0;
 
     fuzzerInvocationCounter++;
 
-    vp[0] = SDLTest_RandomSint32();
-    vp[1] = SDLTest_RandomSint32();
+    value.v32[0] = SDLTest_RandomSint32();
+    value.v32[1] = SDLTest_RandomSint32();
 
-    return value;
+    return (Sint64)value.v64;
 }
 
 


More information about the commits mailing list