|
|
59ea72 |
From 760365f94409ccccbcb54d55070f0f422bee44a1 Mon Sep 17 00:00:00 2001
|
|
|
59ea72 |
From: Jes Sorensen <jsorensen@fb.com>
|
|
|
59ea72 |
Date: Tue, 29 May 2018 15:52:48 -0400
|
|
|
59ea72 |
Subject: [RHEL7.5 PATCH 11/26] Do not confuse gcc
|
|
|
59ea72 |
|
|
|
59ea72 |
gcc-8.1's -Werror=stringop-truncation is easily confused. Rather than
|
|
|
59ea72 |
disabling the check, make it explicit we are OK truncating here.
|
|
|
59ea72 |
|
|
|
59ea72 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
59ea72 |
---
|
|
|
59ea72 |
super-intel.c | 8 +++++++-
|
|
|
59ea72 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
59ea72 |
|
|
|
59ea72 |
diff --git a/super-intel.c b/super-intel.c
|
|
|
59ea72 |
index ce08af4..449da1d 100644
|
|
|
59ea72 |
--- a/super-intel.c
|
|
|
59ea72 |
+++ b/super-intel.c
|
|
|
59ea72 |
@@ -5323,6 +5323,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
|
|
|
59ea72 |
struct imsm_map *map;
|
|
|
59ea72 |
int idx = mpb->num_raid_devs;
|
|
|
59ea72 |
int i;
|
|
|
59ea72 |
+ int namelen;
|
|
|
59ea72 |
unsigned long long array_blocks;
|
|
|
59ea72 |
size_t size_old, size_new;
|
|
|
59ea72 |
unsigned long long num_data_stripes;
|
|
|
59ea72 |
@@ -5402,7 +5403,12 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
|
|
|
59ea72 |
return 0;
|
|
|
59ea72 |
dv = xmalloc(sizeof(*dv));
|
|
|
59ea72 |
dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1));
|
|
|
59ea72 |
- strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN);
|
|
|
59ea72 |
+ /*
|
|
|
59ea72 |
+ * Explicitly allow truncating to not confuse gcc's
|
|
|
59ea72 |
+ * -Werror=stringop-truncation
|
|
|
59ea72 |
+ */
|
|
|
59ea72 |
+ namelen = min((int) strlen(name), MAX_RAID_SERIAL_LEN);
|
|
|
59ea72 |
+ memcpy(dev->volume, name, namelen);
|
|
|
59ea72 |
array_blocks = calc_array_size(info->level, info->raid_disks,
|
|
|
59ea72 |
info->layout, info->chunk_size,
|
|
|
59ea72 |
s->size * BLOCKS_PER_KB);
|
|
|
59ea72 |
--
|
|
|
59ea72 |
2.7.4
|
|
|
59ea72 |
|