We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3494 - SDL_test_fuzzer.c fails compile since r10604
Summary: SDL_test_fuzzer.c fails compile since r10604
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-16 19:26 UTC by Ozkan Sezer
Modified: 2016-11-21 05:24 UTC (History)
0 users

See Also:


Attachments
corrected patch (1.59 KB, patch)
2016-11-17 10:36 UTC, Ozkan Sezer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2016-11-16 19:26:22 UTC
As of hg rev. 10604 (http://hg.libsdl.org/SDL/rev/27d0fb08d755),
SDL_test_fuzzer.c fails to build again (cf. bug #2721):

/S2/src/test/SDL_test_fuzzer.c: In function 'SDLTest_RandomUint64BoundaryValue':
/S2/src/test/SDL_test_fuzzer.c:300: error: 'ULLONG_MAX' undeclared (first use in this function)
/S2/src/test/SDL_test_fuzzer.c:300: error: (Each undeclared identifier is reported only once
/S2/src/test/SDL_test_fuzzer.c:300: error: for each function it appears in.)
/S2/src/test/SDL_test_fuzzer.c: In function 'SDLTest_RandomSint64BoundaryValue':
/S2/src/test/SDL_test_fuzzer.c:436: error: 'LLONG_MAX' undeclared (first use in this function)
/S2/src/test/SDL_test_fuzzer.c:437: error: 'LLONG_MIN' undeclared (first use in this function)


Perhaps replacing ?LLONG_??? with ?INT64_??? would be a better fix:

diff -r d17dd08640a4 src/test/SDL_test_fuzzer.c
--- a/src/test/SDL_test_fuzzer.c	Tue Nov 15 01:30:08 2016 -0800
+++ b/src/test/SDL_test_fuzzer.c	Wed Nov 16 21:17:51 2016 +0200
@@ -297,7 +297,7 @@
 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
 {
     /* max value for Uint64 */
-    const Uint64 maxValue = ULLONG_MAX;
+    const Uint64 maxValue = UINT64_MAX;
     return SDLTest_GenerateUnsignedBoundaryValues(maxValue,
                 (Uint64) boundary1, (Uint64) boundary2,
                 validDomain);
@@ -433,8 +433,8 @@
 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
 {
     /* min & max values for Sint64 */
-    const Sint64 maxValue = LLONG_MAX;
-    const Sint64 minValue = LLONG_MIN;
+    const Sint64 maxValue = INT64_MAX;
+    const Sint64 minValue = INT64_MIN;
     return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
                 boundary1, boundary2,
                 validDomain);
Comment 1 Ozkan Sezer 2016-11-17 10:36:16 UTC
Created attachment 2635 [details]
corrected patch

Better patch, tested to build with MSVC too:

diff -r 3b93b7acc1b4 src/test/SDL_test_fuzzer.c
--- a/src/test/SDL_test_fuzzer.c	Thu Nov 17 01:41:56 2016 -0500
+++ b/src/test/SDL_test_fuzzer.c	Thu Nov 17 12:12:17 2016 +0200
@@ -27,18 +27,20 @@
 
 #include "SDL_config.h"
 
+#include <limits.h>
 /* Visual Studio 2008 doesn't have stdint.h */
 #if defined(_MSC_VER) && _MSC_VER <= 1500
-#define UINT8_MAX   ~(Uint8)0
-#define UINT16_MAX  ~(Uint16)0
-#define UINT32_MAX  ~(Uint32)0
-#define UINT64_MAX  ~(Uint64)0
+#define UINT8_MAX   _UI8_MAX
+#define UINT16_MAX  _UI16_MAX
+#define UINT32_MAX  _UI32_MAX
+#define INT64_MIN    _I64_MIN
+#define INT64_MAX    _I64_MAX
+#define UINT64_MAX  _UI64_MAX
 #else
 #include <stdint.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
-#include <limits.h>
 #include <float.h>
 
 #include "SDL_test.h"
@@ -297,7 +299,7 @@
 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
 {
     /* max value for Uint64 */
-    const Uint64 maxValue = ULLONG_MAX;
+    const Uint64 maxValue = UINT64_MAX;
     return SDLTest_GenerateUnsignedBoundaryValues(maxValue,
                 (Uint64) boundary1, (Uint64) boundary2,
                 validDomain);
@@ -433,8 +435,8 @@
 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
 {
     /* min & max values for Sint64 */
-    const Sint64 maxValue = LLONG_MAX;
-    const Sint64 minValue = LLONG_MIN;
+    const Sint64 maxValue = INT64_MAX;
+    const Sint64 minValue = INT64_MIN;
     return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
                 boundary1, boundary2,
                 validDomain);
Comment 2 Sam Lantinga 2016-11-21 05:24:42 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/49026b20848e