summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2018-05-31 16:07:33 -0400
committerJes Sorensen <jsorensen@fb.com>2018-05-31 16:07:33 -0400
commit002a5978f015a77ecc48487006b1030f9dbe1394 (patch)
treed7b471a9fc509fea6a6051968fc55b6c69e147eb
parent4d061b02b61d5e6d4186e0118166fdd40ea8b55f (diff)
downloadmdadm-002a5978f015a77ecc48487006b1030f9dbe1394.tar.gz
super-ddf: Fix gcc-8.1 overflow warnings
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>
-rw-r--r--super-ddf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/super-ddf.c b/super-ddf.c
index d02a19a..618542c 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -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();