[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 lable 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@xxxxxxxx>
---
convert/source-ext2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index f248249f..f11ef651 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -88,7 +88,7 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name)
cctx->blocksize = ext2_fs->blocksize;
cctx->block_count = ext2_fs->super->s_blocks_count;
cctx->total_bytes = ext2_fs->blocksize * ext2_fs->super->s_blocks_count;
- cctx->volume_name = strndup(ext2_fs->super->s_volume_name, 16);
+ cctx->volume_name = strndup((char *)ext2_fs->super->s_volume_name, 16);
cctx->first_data_block = ext2_fs->super->s_first_data_block;
cctx->inodes_count = ext2_fs->super->s_inodes_count;
cctx->free_inodes_count = ext2_fs->super->s_free_inodes_count;
--
2.27.0