[commit: ghc] master: rts: fix format arguments for debugBelch calls on 32-bit systems (48b8842)

git at git.haskell.org git at git.haskell.org
Thu Apr 19 16:24:16 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/48b88421995b121b62d5b6a1890e61252d49ce90/ghc

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

commit 48b88421995b121b62d5b6a1890e61252d49ce90
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Thu Apr 19 11:28:46 2018 -0400

    rts: fix format arguments for debugBelch calls on 32-bit systems
    
    This change fixes build failure like this:
    ```
      rts/Stats.c:1467:14: error:
         error: format '%u' expects argument of type 'unsigned int',
             but argument 4 has type 'long unsigned int' [-Werror=format=]
           debugBelch("%51s%9" FMT_Word " %9" FMT_Word "\n",
                      ^~~~~~~~
                      "",tot_live*sizeof(W_),tot_slop*sizeof(W_));
                                             ~~~~~~~~~~~~~~~~~~~
    ```
    
    The fix is to cast sizeof() result to Word (W_).
    
    Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
    
    Test Plan: build for 32-bit target
    
    Reviewers: bgamari, erikd, simonmar
    
    Reviewed By: simonmar
    
    Subscribers: thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4608


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

48b88421995b121b62d5b6a1890e61252d49ce90
 rts/Printer.c   | 2 +-
 rts/Stats.c     | 2 +-
 rts/sm/Sanity.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/rts/Printer.c b/rts/Printer.c
index 702e490..87a2cb1 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -409,7 +409,7 @@ printClosure( const StgClosure *obj )
 
     case COMPACT_NFDATA:
         debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n",
-                   (W_)((StgCompactNFData *)obj)->totalW * sizeof(W_));
+                   (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_));
         break;
 
 
diff --git a/rts/Stats.c b/rts/Stats.c
index 44b6e2d..3d03d49 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -1465,7 +1465,7 @@ statDescribeGens(void)
   }
   debugBelch("----------------------------------------------------------------------\n");
   debugBelch("%51s%9" FMT_Word " %9" FMT_Word "\n",
-             "",tot_live*sizeof(W_),tot_slop*sizeof(W_));
+             "",tot_live*(W_)sizeof(W_),tot_slop*(W_)sizeof(W_));
   debugBelch("----------------------------------------------------------------------\n");
   debugBelch("\n");
 }
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 53b1010..7a0ad16 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -859,7 +859,7 @@ void findSlop(bdescr *bd)
         slop = (bd->blocks * BLOCK_SIZE_W) - (bd->free - bd->start);
         if (slop > (1024/sizeof(W_))) {
             debugBelch("block at %p (bdescr %p) has %" FMT_Word "KB slop\n",
-                       bd->start, bd, slop / (1024/sizeof(W_)));
+                       bd->start, bd, slop / (1024/(W_)sizeof(W_)));
         }
     }
 }



More information about the ghc-commits mailing list