Skip to contentSkip to conversation

Fix some type comparison problems

PATCH In review Xiao Ni 2 participants 2 messages Feb 4, 2016 MD RAID

lore
Share & tools
lore

Xiao Ni

author
#0 lore raw

PATCH 1/1 Fix some type comparison problems

It complains when building on s390 and i686 platform.

---
 Monitor.c | 2 +-
 util.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Monitor.c +1 -1
index f19c2e5..9a6cf7e 100644
@@ -542,7 +542,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
 		alert("NewArray", st->devname, NULL, ainfo);
 	}
 
-	if (st->utime == array.utime &&
+	if ((unsigned int)st->utime == array.utime &&
 	    st->failed == array.failed_disks &&
 	    st->working == array.working_disks &&
 	    st->spare == array.spare_disks &&
util.c +1 -1
index 970d484..6e7d3fb 100644
@@ -1267,7 +1267,7 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type)
 	 */
 	struct superswitch  *ss;
 	struct supertype *st;
-	time_t besttime = 0;
+	unsigned int besttime = 0;
 	int bestsuper = -1;
 	int i;
 
Signature · 1 line
2.4.3
#1 lore raw
Quoted 3 lines · Xiao Ni

It complains when building on s390 and i686 platform.

Hi Xiao,

The description needs to be a little clearer - something more like "Change utime to unsigned int to be able to hold times until 2106."

Quoted 10 lines
---
 Monitor.c | 2 +-
 util.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Monitor.c +0 -0
index f19c2e5..9a6cf7e 100644

Monitor.c static int check_array(struct state *st, struct mdstat_ent *mdstat, · line 548

Quoted 8 lines
Monitor.c +1 -1
@@ -542,7 +542,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
 		alert("NewArray", st->devname, NULL, ainfo);
 	}
 
-	if (st->utime == array.utime &&
+	if ((unsigned int)st->utime == array.utime &&
 	    st->failed == array.failed_disks &&
 	    st->working == array.working_disks &&
 	    st->spare == array.spare_disks &&

Instead of the cast, please change the type in struct state.

util.c struct supertype *guess_super_type(int fd, enum guess_types guess_type) · line 1272

Quoted 12 lines
util.c +1 -1
index 970d484..6e7d3fb 100644
@@ -1267,7 +1267,7 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type)
 	 */
 	struct superswitch  *ss;
 	struct supertype *st;
-	time_t besttime = 0;
+	unsigned int besttime = 0;
 	int bestsuper = -1;
 	int i;

This one is fine.

Thanks,
Jes