[parted-devel] [PATCH 18/24] ntfs: Fix gcc 10 warnings about cast alignment

Brian C. Lane bcl at redhat.com
Sat Nov 14 00:12:01 GMT 2020


---
 libparted/fs/ntfs/ntfs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libparted/fs/ntfs/ntfs.c b/libparted/fs/ntfs/ntfs.c
index 3bfb28e..a3a6550 100644
--- a/libparted/fs/ntfs/ntfs.c
+++ b/libparted/fs/ntfs/ntfs.c
@@ -35,16 +35,17 @@
 PedGeometry*
 ntfs_probe (PedGeometry* geom)
 {
-	char	*buf = alloca (geom->dev->sector_size);
+	uint8_t *buf = alloca(geom->dev->sector_size);
 	PedGeometry *newg = NULL;
 
 	if (!ped_geometry_read(geom, buf, 0, 1))
 		return 0;
 
-	if (strncmp (NTFS_SIGNATURE, buf + 3, strlen (NTFS_SIGNATURE)) == 0)
-		newg = ped_geometry_new (geom->dev, geom->start,
-					 PED_LE64_TO_CPU (*(uint64_t*)
-						 	  (buf + 0x28)));
+	if (strncmp (NTFS_SIGNATURE, ((char *)buf + 3), strlen (NTFS_SIGNATURE)) == 0) {
+		uint64_t length;
+		memcpy(&length, buf + 0x28, sizeof(uint64_t));
+		newg = ped_geometry_new (geom->dev, geom->start, length);
+	}
 	return newg;
 }
 
-- 
2.26.2




More information about the parted-devel mailing list