• Alexander Aring's avatar
    fs: dlm: cast resource pointer to uintptr_t · e425ac99
    Alexander Aring authored
    This patch fixes the following warning when doing a 32 bit kernel build
    when pointers are 4 byte long:
    
    In file included from ./include/linux/byteorder/little_endian.h:5,
                     from ./arch/x86/include/uapi/asm/byteorder.h:5,
                     from ./include/asm-generic/qrwlock_types.h:6,
                     from ./arch/x86/include/asm/spinlock_types.h:7,
                     from ./include/linux/spinlock_types_raw.h:7,
                     from ./include/linux/ratelimit_types.h:7,
                     from ./include/linux/printk.h:10,
                     from ./include/asm-generic/bug.h:22,
                     from ./arch/x86/include/asm/bug.h:87,
                     from ./include/linux/bug.h:5,
                     from ./include/linux/mmdebug.h:5,
                     from ./include/linux/gfp.h:5,
                     from ./include/linux/slab.h:15,
                     from fs/dlm/dlm_internal.h:19,
                     from fs/dlm/rcom.c:12:
    fs/dlm/rcom.c: In function ‘dlm_send_rcom_lock’:
    ./include/uapi/linux/byteorder/little_endian.h:32:43: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     #define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
                                               ^
    ./include/linux/byteorder/generic.h:86:21: note: in expansion of macro ‘__cpu_to_le64’
     #define cpu_to_le64 __cpu_to_le64
                         ^~~~~~~~~~~~~
    fs/dlm/rcom.c:457:14: note: in expansion of macro ‘cpu_to_le64’
      rc->rc_id = cpu_to_le64(r);
    
    The rc_id value in dlm rcom is handled as u64. The rcom implementation
    uses for an unique number generation the pointer value of the used
    dlm_rsb instance. However if the pointer value is 4 bytes long
    -Wpointer-to-int-cast will print a warning. We get rid of that warning
    to cast the pointer to uintptr_t which is either 4 or 8 bytes. There
    might be a very unlikely case where this number isn't unique anymore if
    using dlm in a mixed cluster of nodes and sizeof(uintptr_t) returns 4 and
    8.
    
    However this problem was already been there and this patch should get
    rid of the warning.
    
    Fixes: 2f9dbeda ("dlm: use __le types for rcom messages")
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
    Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
    e425ac99
rcom.c 17 KB