From 791b1ad7bd2bd836668f95b9ba897866d65138f3 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Apr 2019 15:50:08 +0200 Subject: [PATCH] [FASTFAT] Copy an entire field, instead of half-copying it with RtlCopyMemory Fixes GCC 8 warning: sdk/include/crt/mingw32/intrin_x86.h:76:12: error: 'memmove' offset [21, 40] from the object at 'DirContext' is out of the bounds of referenced subobject 'Attrib' with type 'unsigned char' at offset 19 [-Werror=array-bounds] return memmove(dest, source, num); ^~~~~~~~~~~~~~~~~~~~~~~~~~ --- drivers/filesystems/fastfat/dirwr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/filesystems/fastfat/dirwr.c b/drivers/filesystems/fastfat/dirwr.c index db059e86cf4..2aec457057d 100644 --- a/drivers/filesystems/fastfat/dirwr.c +++ b/drivers/filesystems/fastfat/dirwr.c @@ -806,11 +806,9 @@ FATAddEntry( { RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster); /* create '.' and '..' */ - RtlCopyMemory(&pFatEntry[0].Attrib, &DirContext.DirEntry.Fat.Attrib, - sizeof(FAT_DIR_ENTRY) - FIELD_OFFSET(FAT_DIR_ENTRY, Attrib)); + pFatEntry[0] = DirContext.DirEntry.Fat; RtlCopyMemory(pFatEntry[0].ShortName, ". ", 11); - RtlCopyMemory(&pFatEntry[1].Attrib, &DirContext.DirEntry.Fat.Attrib, - sizeof(FAT_DIR_ENTRY) - FIELD_OFFSET(FAT_DIR_ENTRY, Attrib)); + pFatEntry[1] = DirContext.DirEntry.Fat; RtlCopyMemory(pFatEntry[1].ShortName, ".. ", 11); }