• Dave Chinner's avatar
    xfs: convert buffer flags to unsigned. · b9b3fe15
    Dave Chinner authored
    5.18 w/ std=gnu11 compiled with gcc-5 wants flags stored in unsigned
    fields to be unsigned. This manifests as a compiler error such as:
    
    /kisskb/src/fs/xfs/./xfs_trace.h:432:2: note: in expansion of macro 'TP_printk'
      TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
      ^
    /kisskb/src/fs/xfs/./xfs_trace.h:440:5: note: in expansion of macro '__print_flags'
         __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
         ^
    /kisskb/src/fs/xfs/xfs_buf.h:67:4: note: in expansion of macro 'XBF_UNMAPPED'
      { XBF_UNMAPPED,  "UNMAPPED" }
        ^
    /kisskb/src/fs/xfs/./xfs_trace.h:440:40: note: in expansion of macro 'XFS_BUF_FLAGS'
         __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
                                            ^
    /kisskb/src/fs/xfs/./xfs_trace.h: In function 'trace_raw_output_xfs_buf_flags_class':
    /kisskb/src/fs/xfs/xfs_buf.h:46:23: error: initializer element is not constant
     #define XBF_UNMAPPED  (1 << 31)/* do not map the buffer */
    
    as __print_flags assigns XFS_BUF_FLAGS to a structure that uses an
    unsigned long for the flag. Since this results in the value of
    XBF_UNMAPPED causing a signed integer overflow, the result is
    technically undefined behavior, which gcc-5 does not accept as an
    integer constant.
    
    This is based on a patch from Arnd Bergman <arnd@arndb.de>.
    Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarChandan Babu R <chandan.babu@oracle.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    b9b3fe15
xfs_buf.h 11.5 KB