summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>2019-08-14 10:59:19 +0900
committerBrian C. Lane <bcl@redhat.com>2020-11-05 16:32:07 -0800
commitd51921b05c32287238b1b0447d7e952884f63eb5 (patch)
tree24082abf6de76776a6745f4aa2f0db599857253f
parentf75af2cfbbd1a2d82ed3df4955014f73737ae13e (diff)
downloadparted-d51921b05c32287238b1b0447d7e952884f63eb5.tar.gz
libparted: Fix warnings from GCC 8 -Wunused-variable and -Warray-bounds
GCC 8 reports two warnings as follows. r/fat/bootsector.c: In function 'fat_boot_sector_set_boot_code': r/fat/bootsector.c:274:15: warning: unused variable 'fs_info' [-Wunused-variable] FatSpecific* fs_info = FAT_SPECIFIC (fs); ^~~~~~~ In function 'memcpy', inlined from 'fat_boot_sector_set_boot_code' at r/fat/bootsector.c:283:2: /usr/include/bits/string_fortified.h:34:10: warning: '__builtin_memcpy' forming offset [126, 128] is out of the bounds [0, 125] [-Warray-bounds] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To avoid the warnings, remove the unused variable. Use strcpy in place of memcpy checking copy length. Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp> Signed-off-by: Brian C. Lane <bcl@redhat.com>
-rw-r--r--libparted/fs/r/fat/bootsector.c5
-rw-r--r--libparted/fs/r/fat/bootsector.h2
2 files changed, 2 insertions, 5 deletions
diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c
index 46d5926..9130900 100644
--- a/libparted/fs/r/fat/bootsector.c
+++ b/libparted/fs/r/fat/bootsector.c
@@ -271,8 +271,6 @@ fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs)
int
fat_boot_sector_set_boot_code (FatBootSector** bsp, const PedFileSystem* fs)
{
- FatSpecific* fs_info = FAT_SPECIFIC (fs);
-
PED_ASSERT (bsp != NULL);
*bsp = ped_malloc (fs->geom->dev->sector_size);
FatBootSector *bs = *bsp;
@@ -280,7 +278,8 @@ fat_boot_sector_set_boot_code (FatBootSector** bsp, const PedFileSystem* fs)
memset (bs, 0, 512);
memcpy (bs->boot_jump, FAT_BOOT_JUMP, 3);
- memcpy (bs->u.fat32.boot_code, FAT_BOOT_CODE, FAT_BOOT_CODE_LENGTH);
+ PED_ASSERT (sizeof(FAT_BOOT_CODE) < sizeof(bs->u.fat32.boot_code));
+ strcpy (bs->u.fat32.boot_code, FAT_BOOT_CODE);
return 1;
}
diff --git a/libparted/fs/r/fat/bootsector.h b/libparted/fs/r/fat/bootsector.h
index 6b0363f..42fc3f2 100644
--- a/libparted/fs/r/fat/bootsector.h
+++ b/libparted/fs/r/fat/bootsector.h
@@ -57,8 +57,6 @@ typedef struct _FatInfoSector FatInfoSector;
/* message: */ \
FAT_BOOT_MESSAGE
-#define FAT_BOOT_CODE_LENGTH 128
-
struct __attribute__ ((packed)) _FatBootSector {
uint8_t boot_jump[3]; /* 00: Boot strap short or near jump */
uint8_t system_id[8]; /* 03: system name */