hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Thu Mar 13 10:41:19 PDT 2008
partutil/partutil.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
New commits:
commit 0e0938e87a16791322561897ad2ca2459fc3983e
Author: Guillem Jover <guillem.jover at nokia.com>
Date: Thu Mar 13 18:41:14 2008 +0100
partutil: make the get endian functions alignment aware
On architectures where unaligned access is not supported, it might have
to be fixed at runtime which can cause slow downs or make the code abort
(like generating SIGBUS).
diff --git a/partutil/partutil.c b/partutil/partutil.c
index 35fc82d..c623ca2 100644
--- a/partutil/partutil.c
+++ b/partutil/partutil.c
@@ -146,27 +146,39 @@ part_table_find (PartitionTable *p, guint64 offset,
static guint16
get_le16 (const void *buf)
{
- return GUINT16_FROM_LE ( * ((guint16 *) buf) );
+ guint16 i;
+
+ memcpy (&i, buf, sizeof (i));
+ return GUINT16_FROM_LE (i);
}
static guint32
get_le32 (const void *buf)
{
- return GUINT32_FROM_LE ( * ((guint32 *) buf) );
+ guint32 i;
+
+ memcpy (&i, buf, sizeof (i));
+ return GUINT32_FROM_LE (i);
}
static guint64
get_le64 (const void *buf)
{
- return GUINT64_FROM_LE ( * ((guint64 *) buf) );
+ guint64 i;
+
+ memcpy (&i, buf, sizeof (i));
+ return GUINT64_FROM_LE (i);
}
static guint32
get_be32 (const void *buf)
{
- return GUINT32_FROM_BE ( * ((guint32 *) buf) );
+ guint32 i;
+
+ memcpy (&i, buf, sizeof (i));
+ return GUINT32_FROM_BE (i);
}
/* see http://en.wikipedia.org/wiki/Globally_Unique_Identifier - excerpt
More information about the hal-commit
mailing list