ac75513 btrfs-progs: convert: fix the pointer sign warning for ext2 label

1 file Authored by Qu Wenruo 3 years ago, Committed by David Sterba 3 years ago,
    btrfs-progs: convert: fix the pointer sign warning for ext2 label
    
    [WARNING]
    When compiling btrfs-progs, there is one warning from convert ext2 code:
      convert/source-ext2.c: In function 'ext2_open_fs':
      convert/source-ext2.c:91:44: warning: pointer targets in passing argument 1 of 'strndup' differ in signedness [-Wpointer-sign]
         91 |  cctx->volume_name = strndup(ext2_fs->super->s_volume_name, 16);
            |                              ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
            |                                            |
            |                                            __u8 * {aka unsigned char *}
      In file included from ./kerncompat.h:25,
                       from convert/source-ext2.c:19:
      /usr/include/string.h:175:35: note: expected 'const char *' but argument is of type '__u8 *' {aka 'unsigned char *'}
        175 | extern char *strndup (const char *__string, size_t __n)
            |                       ~~~~~~~~~~~~^~~~~~~~
    
    The toolchain involved is:
    - GCC 10.1.0
    - e2fsprogs 1.45.6
    
    [CAUSE]
    Obviously, in the offending e2fsprogs, the volume label is using u8,
    which is unsigned char, not char.
    
      /*078*/	__u8	s_volume_name[EXT2_LABEL_LEN];	/* volume name, no NUL? */
    
    [FIX]
    Just do a forced conversion to suppress the warning is enough.
    I don't think we need to apply -Wnopointer-sign yet.
    
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    
        
file modified
+1 -1