• Nathan Chancellor's avatar
    bcachefs: Fix format specifier in bch2_btree_key_cache_to_text() · 5396e5af
    Nathan Chancellor authored
    When building for a 32-bit architecture, for which 'size_t' is
    'unsigned int', there is a compiler warning due to use of '%lu':
    
      In file included from fs/bcachefs/vstructs.h:5,
                       from fs/bcachefs/bcachefs_format.h:80,
                       from fs/bcachefs/bcachefs.h:207,
                       from fs/bcachefs/btree_key_cache.c:3:
      fs/bcachefs/btree_key_cache.c: In function 'bch2_btree_key_cache_to_text':
      fs/bcachefs/btree_key_cache.c:795:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
        795 |         prt_printf(out, "pending:\t%lu\r\n",            per_cpu_sum(bc->nr_pending));
            |                         ^~~~~~~~~~~~~~~~~~~
      fs/bcachefs/util.h:78:63: note: in definition of macro 'prt_printf'
         78 | #define prt_printf(_out, ...)           bch2_prt_printf(_out, __VA_ARGS__)
            |                                                               ^~~~~~~~~~~
      fs/bcachefs/btree_key_cache.c:795:38: note: format string is defined here
        795 |         prt_printf(out, "pending:\t%lu\r\n",            per_cpu_sum(bc->nr_pending));
            |                                    ~~^
            |                                      |
            |                                      long unsigned int
            |                                    %u
      cc1: all warnings being treated as errors
    
    Use the proper specifier, '%zu', to resolve the warning.
    
    Fixes: e447e49977b8 ("bcachefs: key cache can now allocate from pending")
    Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    5396e5af
btree_key_cache.c 21.6 KB