]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super-intel: Use memcpy() to avoid confusing gcc
authorJes Sorensen <jsorensen@fb.com>
Tue, 29 May 2018 20:09:47 +0000 (16:09 -0400)
committerJes Sorensen <jsorensen@fb.com>
Tue, 29 May 2018 20:09:47 +0000 (16:09 -0400)
When added :0 to serial number and copying it back, use memcpy()
instead of strncpy() as we know the actual length. This stops gcc
from complaining with -Werror=stringop-truncation enabled

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

index 449da1dd83d876df0b42fe36f1864523faf0f082..ec7683d92ff1718390e43a1c6cf85ae1429e7e38 100644 (file)
@@ -8098,7 +8098,7 @@ static int mark_failure(struct intel_super *super,
        strcat(buf, ":0");
        if ((len = strlen(buf)) >= MAX_RAID_SERIAL_LEN)
                shift = len - MAX_RAID_SERIAL_LEN + 1;
-       strncpy((char *)disk->serial, &buf[shift], MAX_RAID_SERIAL_LEN);
+       memcpy(disk->serial, &buf[shift], len + 1 - shift);
 
        disk->status |= FAILED_DISK;
        set_imsm_ord_tbl_ent(map, slot, idx | IMSM_ORD_REBUILD);