[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [osinfo PATCH] Mark the volume descriptor structs as packed



This tells gcc it shouldn't add some padding between the struct
members. which is important because we rely on this structure size
being exactly 2048. One of its members is guint8 ignored2[246]; (only
a 2 byte multiple) so all the fields of the struct won't be aligned
on a 8 byte boundary, so gcc could do some unexpected things on
some arch.
The 2 structs changed by this patch only use arrays whose elements have
the same size as chars so gcc will probably don't try to change their
alignment, but one never knows..
---
 osinfo/osinfo_media.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 2366993..15d6abe 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -44,14 +44,14 @@ struct _PrimaryVolumeDescriptor {
     guint8 ignored2[246];
     gchar  publisher[MAX_PUBLISHER]; /* Publisher ID */
     guint8 ignored3[1602];
-};
+} __attribute__ ((packed));
 
 typedef struct _SupplementaryVolumeDescriptor SupplementaryVolumeDescriptor;
 
 struct _SupplementaryVolumeDescriptor {
     guint8 ignored[7];
     gchar  system[MAX_SYSTEM]; /* System ID */
-};
+} __attribute__ ((packed));
 
 typedef struct _CreateFromLocationAsyncData CreateFromLocationAsyncData;
 struct _CreateFromLocationAsyncData {
-- 
1.7.7.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]