Blame SOURCES/e2fsprogs-1.45.6-Fix-clang-warnings.patch

e427d2
From 1466a142efe5b20ddda2ce96c0d409dc294fd1b2 Mon Sep 17 00:00:00 2001
e427d2
From: Theodore Ts'o <tytso@mit.edu>
e427d2
Date: Sat, 23 Jan 2021 00:57:18 -0500
e427d2
Subject: [PATCH 17/46] Fix clang warnings
e427d2
Content-Type: text/plain
e427d2
e427d2
Clang gets unhappy when passing an unsigned char to string functions.
e427d2
For better or for worse we use __u8[] in the definition of the
e427d2
superblock.  So cast them these to "char *" to prevent clang
e427d2
build-time warnings.
e427d2
e427d2
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e427d2
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
e427d2
---
e427d2
 e2fsck/unix.c    | 2 +-
e427d2
 lib/ext2fs/mmp.c | 8 ++++----
e427d2
 misc/e2fuzz.c    | 3 ++-
e427d2
 misc/mke2fs.c    | 4 ++--
e427d2
 4 files changed, 9 insertions(+), 8 deletions(-)
e427d2
e427d2
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
e427d2
index e71d7833..15a73e7c 100644
e427d2
--- a/e2fsck/unix.c
e427d2
+++ b/e2fsck/unix.c
e427d2
@@ -1693,7 +1693,7 @@ failure:
e427d2
 	 * or informational messages to the user.
e427d2
 	 */
e427d2
 	if (ctx->device_name == 0 && sb->s_volume_name[0])
e427d2
-		ctx->device_name = string_copy(ctx, sb->s_volume_name,
e427d2
+		ctx->device_name = string_copy(ctx, (char *) sb->s_volume_name,
e427d2
 					       sizeof(sb->s_volume_name));
e427d2
 
e427d2
 	if (ctx->device_name == 0)
e427d2
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
e427d2
index e96a2273..973b9ecd 100644
e427d2
--- a/lib/ext2fs/mmp.c
e427d2
+++ b/lib/ext2fs/mmp.c
e427d2
@@ -210,11 +210,11 @@ static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
e427d2
 	mmp_s->mmp_seq = EXT4_MMP_SEQ_CLEAN;
e427d2
 	mmp_s->mmp_time = 0;
e427d2
 #ifdef HAVE_GETHOSTNAME
e427d2
-	gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
e427d2
+	gethostname((char *) mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
e427d2
 #else
e427d2
 	mmp_s->mmp_nodename[0] = '\0';
e427d2
 #endif
e427d2
-	strncpy(mmp_s->mmp_bdevname, fs->device_name,
e427d2
+	strncpy((char *) mmp_s->mmp_bdevname, fs->device_name,
e427d2
 		sizeof(mmp_s->mmp_bdevname));
e427d2
 
e427d2
 	mmp_s->mmp_check_interval = fs->super->s_mmp_update_interval;
e427d2
@@ -352,11 +352,11 @@ clean_seq:
e427d2
 
e427d2
 	mmp_s->mmp_seq = seq = ext2fs_mmp_new_seq();
e427d2
 #ifdef HAVE_GETHOSTNAME
e427d2
-	gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
e427d2
+	gethostname((char *) mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
e427d2
 #else
e427d2
 	strcpy(mmp_s->mmp_nodename, "unknown host");
e427d2
 #endif
e427d2
-	strncpy(mmp_s->mmp_bdevname, fs->device_name,
e427d2
+	strncpy((char *) mmp_s->mmp_bdevname, fs->device_name,
e427d2
 		sizeof(mmp_s->mmp_bdevname));
e427d2
 
e427d2
 	retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
e427d2
diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c
e427d2
index 7c0f776f..65b6ae73 100644
e427d2
--- a/misc/e2fuzz.c
e427d2
+++ b/misc/e2fuzz.c
e427d2
@@ -172,7 +172,8 @@ static uint64_t rand_num(uint64_t min, uint64_t max)
e427d2
 	for (i = 0; i < sizeof(x); i++)
e427d2
 		px[i] = random();
e427d2
 
e427d2
-	return min + (uint64_t)((double)(max - min) * (x / (UINT64_MAX + 1.0)));
e427d2
+	return min + (uint64_t)((double)(max - min) *
e427d2
+				(x / ((double) UINT64_MAX + 1.0)));
e427d2
 }
e427d2
 
e427d2
 static int process_fs(const char *fsname)
e427d2
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
e427d2
index 27e7d174..0184a3a8 100644
e427d2
--- a/misc/mke2fs.c
e427d2
+++ b/misc/mke2fs.c
e427d2
@@ -3151,7 +3151,7 @@ int main (int argc, char *argv[])
e427d2
 	if (volume_label) {
e427d2
 		memset(fs->super->s_volume_name, 0,
e427d2
 		       sizeof(fs->super->s_volume_name));
e427d2
-		strncpy(fs->super->s_volume_name, volume_label,
e427d2
+		strncpy((char *) fs->super->s_volume_name, volume_label,
e427d2
 			sizeof(fs->super->s_volume_name));
e427d2
 	}
e427d2
 
e427d2
@@ -3161,7 +3161,7 @@ int main (int argc, char *argv[])
e427d2
 	if (mount_dir) {
e427d2
 		memset(fs->super->s_last_mounted, 0,
e427d2
 		       sizeof(fs->super->s_last_mounted));
e427d2
-		strncpy(fs->super->s_last_mounted, mount_dir,
e427d2
+		strncpy((char *) fs->super->s_last_mounted, mount_dir,
e427d2
 			sizeof(fs->super->s_last_mounted));
e427d2
 	}
e427d2
 
e427d2
-- 
e427d2
2.35.1
e427d2