[mdadm PATCH 2/3] Fix one building error related with memcpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I encounter one building error, such as:
In file included from /usr/include/string.h:494,
                 from mdadm.h:46,
                 from super0.c:26:
In function 'memcpy',
    inlined from 'update_super0' at super0.c:523:3:
/usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' accessing 3936 bytes at offsets 156 and 160 overlaps 3932 bytes at offset 160 [-Werror=restrict]
   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This patch adds a temporary to fix this problem.

Signed-off-by: Xiao Ni <xni@xxxxxxxxxx>
---
 super0.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/super0.c b/super0.c
index 756cab5..fd56cce 100644
--- a/super0.c
+++ b/super0.c
@@ -519,9 +519,11 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
 		 * So we copy the tail of the superblock
 		 * up 4 bytes before continuing
 		 */
+		__u32 sbuf[(MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4];
 		__u32 *sb32 = (__u32*)sb;
-		memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7,
-		       sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1,
+		memcpy(sbuf, sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1,
+			(MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4);
+		memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7, sbuf,
 		       (MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4);
 		if (verbose >= 0)
 			pr_err("adjusting superblock of %s for 2.2/sparc compatibility.\n",
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux