]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super-ddf: Fix gcc-8.1 overflow warnings
authorJes Sorensen <jsorensen@fb.com>
Thu, 31 May 2018 20:07:33 +0000 (16:07 -0400)
committerJes Sorensen <jsorensen@fb.com>
Thu, 31 May 2018 20:07:33 +0000 (16:07 -0400)
Cast to types that are big enough to hold the values, but also guarantee
no overflow of the buffer keepts gcc happy.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
super-ddf.c

index d02a19a21010aae12cd4d76f5b1708e221e6664a..618542c4b7dd5bc037b434317ea365bf7b753df9 100644 (file)
@@ -2881,8 +2881,9 @@ static int add_to_super_ddf(struct supertype *st,
        dd->disk.magic = DDF_PHYS_DATA_MAGIC;
        now = time(0);
        tm = localtime(&now);
-       sprintf(dd->disk.guid, "%8s%04d%02d%02d",
-               T10, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
+       sprintf(dd->disk.guid, "%8s%04d%02d%02d", T10,
+               (__u16)tm->tm_year+1900,
+               (__u8)tm->tm_mon+1, (__u8)tm->tm_mday);
        tptr = (__u32 *)(dd->disk.guid + 16);
        *tptr++ = random32();
        *tptr = random32();