parted/0017-libparted-Fix-warnings-from-GCC-8-Wunused-variable-a.patch

68 lines
2.6 KiB
Diff
Raw Normal View History

From d51921b05c32287238b1b0447d7e952884f63eb5 Mon Sep 17 00:00:00 2001
From: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
Date: Wed, 14 Aug 2019 10:59:19 +0900
Subject: [PATCH 17/42] 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>
---
libparted/fs/r/fat/bootsector.c | 5 ++---
libparted/fs/r/fat/bootsector.h | 2 --
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 */
--
2.26.2