SDL_test_fuzzer.c: fix strict aliasing warnings by using a union.
authorOzkan Sezer <sezero@users.sourceforge.net>
Sun, 25 Feb 2018 10:15:00 +0300
changeset 11903732b6ef4aae7
parent 11902 ce4bc0462ae5
child 11904 43dbca2813e1
SDL_test_fuzzer.c: fix strict aliasing warnings by using a union.
src/test/SDL_test_fuzzer.c
     1.1 --- a/src/test/SDL_test_fuzzer.c	Sat Feb 24 09:09:20 2018 -0800
     1.2 +++ b/src/test/SDL_test_fuzzer.c	Sun Feb 25 10:15:00 2018 +0300
     1.3 @@ -126,29 +126,35 @@
     1.4  Uint64
     1.5  SDLTest_RandomUint64()
     1.6  {
     1.7 -    Uint64 value = 0;
     1.8 -    Uint32 *vp = (void *)&value;
     1.9 +    union {
    1.10 +        Uint64 v64;
    1.11 +        Uint32 v32[2];
    1.12 +    } value;
    1.13 +    value.v64 = 0;
    1.14  
    1.15      fuzzerInvocationCounter++;
    1.16  
    1.17 -    vp[0] = SDLTest_RandomSint32();
    1.18 -    vp[1] = SDLTest_RandomSint32();
    1.19 +    value.v32[0] = SDLTest_RandomSint32();
    1.20 +    value.v32[1] = SDLTest_RandomSint32();
    1.21  
    1.22 -    return value;
    1.23 +    return value.v64;
    1.24  }
    1.25  
    1.26  Sint64
    1.27  SDLTest_RandomSint64()
    1.28  {
    1.29 -    Uint64 value = 0;
    1.30 -    Uint32 *vp = (void *)&value;
    1.31 +    union {
    1.32 +        Uint64 v64;
    1.33 +        Uint32 v32[2];
    1.34 +    } value;
    1.35 +    value.v64 = 0;
    1.36  
    1.37      fuzzerInvocationCounter++;
    1.38  
    1.39 -    vp[0] = SDLTest_RandomSint32();
    1.40 -    vp[1] = SDLTest_RandomSint32();
    1.41 +    value.v32[0] = SDLTest_RandomSint32();
    1.42 +    value.v32[1] = SDLTest_RandomSint32();
    1.43  
    1.44 -    return value;
    1.45 +    return (Sint64)value.v64;
    1.46  }
    1.47  
    1.48