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 3787

Summary: bug added to testautomation_sdltest.c by changeset 11416:7e7d8a125d6a
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   

Description Ozkan Sezer 2017-08-29 22:01:47 UTC
http://hg.libsdl.org/SDL/rev/7e7d8a125d6a changed type of local i from
int to size_t in sdltest_generateRunSeed(), but i is used with negative
numbers in the second for loop: optimizers will just discard that loop.
Suggest something like the following:

--- SDL2/test/testautomation_sdltest.c~
+++ SDL2/test/testautomation_sdltest.c
@@ -35,6 +35,7 @@ sdltest_generateRunSeed(void *arg)
 {
   char* result;
   size_t i, l;
+  int j;
   
   for (i = 1; i <= 10; i += 3) {   
      result = SDLTest_GenerateRunSeed((const int)i);
@@ -48,8 +49,8 @@ sdltest_generateRunSeed(void *arg)
   }
 
   /* Negative cases */
-  for (i = -2; i <= 0; i++) {   
-     result = SDLTest_GenerateRunSeed((const int)i);
+  for (j = -2; j <= 0; i++) {   
+     result = SDLTest_GenerateRunSeed((const int)j);
      SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
      SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL");
   }
Comment 1 Ryan C. Gordon 2017-08-29 22:14:57 UTC
Sigh, fixing.
Comment 2 Ryan C. Gordon 2017-08-29 22:26:49 UTC
Your patch is https://hg.libsdl.org/SDL/rev/07dd7e0cbd02 and I caught one more in https://hg.libsdl.org/SDL/rev/f1dcaee3479b, thanks!

--ryan.
Comment 3 Ozkan Sezer 2017-08-29 22:31:33 UTC
> I caught one more in https://hg.libsdl.org/SDL/rev/f1dcaee3479b

Apologies that I missed that. Thanks.