[parted-devel] [PATCH 16/24] ext2: Fix gcc 10 warnings about cast alignment
Brian C. Lane
bcl at redhat.com
Sat Nov 14 00:11:59 GMT 2020
---
libparted/fs/ext2/ext2_fs.h | 2 +-
libparted/fs/ext2/interface.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libparted/fs/ext2/ext2_fs.h b/libparted/fs/ext2/ext2_fs.h
index ac1b6a0..362f8bc 100644
--- a/libparted/fs/ext2/ext2_fs.h
+++ b/libparted/fs/ext2/ext2_fs.h
@@ -173,7 +173,7 @@ struct ext2_inode
#define i_size_high i_dir_acl
-struct ext2_super_block
+struct __attribute__ ((packed)) ext2_super_block
{
uint32_t s_inodes_count; /* Inodes count */
uint32_t s_blocks_count; /* Blocks count */
diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c
index a49568b..01c224e 100644
--- a/libparted/fs/ext2/interface.c
+++ b/libparted/fs/ext2/interface.c
@@ -33,12 +33,13 @@ struct ext2_dev_handle* ext2_make_dev_handle_from_parted_geometry(PedGeometry* g
static PedGeometry*
_ext2_generic_probe (PedGeometry* geom, int expect_ext_ver)
{
+ struct ext2_super_block *sb;
const int sectors = (4096 + geom->dev->sector_size - 1) /
geom->dev->sector_size;
- char *sb_v = alloca (sectors * geom->dev->sector_size);
- if (!ped_geometry_read(geom, sb_v, 0, sectors))
+ uint8_t *buf = alloca (sectors * geom->dev->sector_size);
+ if (!ped_geometry_read(geom, buf, 0, sectors))
return NULL;
- struct ext2_super_block *sb = (struct ext2_super_block *)(sb_v + 1024);
+ sb = (struct ext2_super_block *)(buf+1024);
if (EXT2_SUPER_MAGIC(*sb) == EXT2_SUPER_MAGIC_CONST) {
PedSector block_size = (EXT2_MIN_BLOCK_SIZE << (EXT2_SUPER_LOG_BLOCK_SIZE(*sb))) / geom->dev->sector_size;
--
2.26.2
More information about the parted-devel
mailing list