Skip to content

Commit

Permalink
SDL_test_fuzzer.c: fix strict aliasing warnings by using a union.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Feb 25, 2018
1 parent cbfee82 commit 3ea093c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/test/SDL_test_fuzzer.c
Expand Up @@ -126,29 +126,35 @@ SDLTest_RandomUint32()
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;
}


Expand Down

0 comments on commit 3ea093c

Please sign in to comment.