[commit: ghc] master: Fix cppcheck warnings (3681c88)

git at git.haskell.org git at git.haskell.org
Tue Sep 16 12:59:31 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3681c885ad6f1103333aaa508a1cd26078914ef0/ghc

>---------------------------------------------------------------

commit 3681c885ad6f1103333aaa508a1cd26078914ef0
Author: Boris Egorov <egorov at linux.com>
Date:   Tue Sep 16 07:55:06 2014 -0500

    Fix cppcheck warnings
    
    Summary:
    Cppcheck found a few defects in win32 IOManager and a typo in rts
    testsuite. This commit fixes them.
    
    Cppcheck 1.54 founds three possible null pointer dereferences of ioMan
    pointer. It is dereferenced and checked for NULL after that.
    
    testheapalloced.c contains typo in printf statement, which should print
    percent sign but treated as parameter placement by compiler. To properly
    print percent sign one need to use "%%" string.
    
    FYI: Cppcheck 1.66 cannot find possible null pointer dereferences in
    mentioned places, mistakenly thinking that some memory leaking instead.
    I probably fill a regression bug to Cppcheck.
    
    Test Plan:
    Build project, run 'make fulltest'. It finished with 28 unexpected
    failures. I don't know if they are related to my fix.
    
        Unexpected results from:
        TEST="T3500b T7891 tc124 T7653 T5321FD T5030 T4801 T6048 T5631 T5837 T5642 T9020 T3064 parsing001 T1969 T5321Fun T783 T3294"
    
        OVERALL SUMMARY for test run started at Tue Sep  9 16:46:27 2014 NOVT
         4:23:24 spent to go through
            4101 total tests, which gave rise to
           16075 test cases, of which
            3430 were skipped
    
             315 had missing libraries
           12154 expected passes
             145 expected failures
    
               3 caused framework failures
               0 unexpected passes
              28 unexpected failures
    
        Unexpected failures:
           ../../libraries/base/tests  T7653 [bad exit code] (ghci,threaded1,threaded2)
           perf/compiler               T1969 [stat not good enough] (normal)
           perf/compiler               T3064 [stat not good enough] (normal)
           perf/compiler               T3294 [stat not good enough] (normal)
           perf/compiler               T4801 [stat not good enough] (normal)
           perf/compiler               T5030 [stat not good enough] (normal)
           perf/compiler               T5321FD [stat not good enough] (normal)
           perf/compiler               T5321Fun [stat not good enough] (normal)
           perf/compiler               T5631 [stat not good enough] (normal)
           perf/compiler               T5642 [stat not good enough] (normal)
           perf/compiler               T5837 [stat not good enough] (normal)
           perf/compiler               T6048 [stat not good enough] (optasm)
           perf/compiler               T783 [stat not good enough] (normal)
           perf/compiler               T9020 [stat not good enough] (optasm)
           perf/compiler               parsing001 [stat not good enough] (normal)
           typecheck/should_compile    T7891 [exit code non-0] (hpc,optasm,optllvm)
           typecheck/should_compile    tc124 [exit code non-0] (hpc,optasm,optllvm)
           typecheck/should_run        T3500b [exit code non-0] (hpc,optasm,threaded2,dyn,optllvm)
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: simonmar, ezyang, carter
    
    Differential Revision: https://phabricator.haskell.org/D203


>---------------------------------------------------------------

3681c885ad6f1103333aaa508a1cd26078914ef0
 rts/win32/IOManager.c                 | 9 ++++++---
 testsuite/tests/rts/testheapalloced.c | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/rts/win32/IOManager.c b/rts/win32/IOManager.c
index 2427687..7eaf489 100644
--- a/rts/win32/IOManager.c
+++ b/rts/win32/IOManager.c
@@ -436,8 +436,9 @@ AddIORequest ( int   fd,
                CompletionProc onCompletion)
 {
     WorkItem* wItem    = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID = ioMan->requestID++;
+    unsigned int reqID;
     if (!ioMan || !wItem) return 0;
+    reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = ( isSocket   ? WORKER_FOR_SOCKET : 0 ) |
@@ -464,8 +465,9 @@ AddDelayRequest ( unsigned int   usecs,
                   CompletionProc onCompletion)
 {
     WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID = ioMan->requestID++;
+    unsigned int reqID;
     if (!ioMan || !wItem) return FALSE;
+    reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = WORKER_DELAY;
@@ -488,8 +490,9 @@ AddProcRequest ( void* proc,
                  CompletionProc onCompletion)
 {
     WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID = ioMan->requestID++;
+    unsigned int reqID;
     if (!ioMan || !wItem) return FALSE;
+    reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = WORKER_DO_PROC;
diff --git a/testsuite/tests/rts/testheapalloced.c b/testsuite/tests/rts/testheapalloced.c
index cc4dad4..3d8fa05 100644
--- a/testsuite/tests/rts/testheapalloced.c
+++ b/testsuite/tests/rts/testheapalloced.c
@@ -85,7 +85,7 @@ int main (int argc, char *argv[])
         printf("%d\n", j);
     }
 
-    printf("misses: %ld, %ld%\n", mpc_misses, mpc_misses / (LOOPS*20));
+    printf("misses: %ld, %ld%%\n", mpc_misses, mpc_misses / (LOOPS*20));
 
     for (i=0; i < ARRSIZE; i++)
     {



More information about the ghc-commits mailing list