[Libosinfo] [libosinfo PATCH v2 3/6] media: Use G_STATIC_ASSERT()

Fabiano Fidêncio fidencio at redhat.com
Thu Dec 20 07:46:44 UTC 2018


Let's use G_STATIC_ASSERT() instead of creating a dummy array to check
the size of the _PrimaryVolumeDescriptor struct.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/osinfo_media.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 1ee1fa5..cf1cf91 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -59,10 +59,9 @@ struct _PrimaryVolumeDescriptor {
 
 /* the PrimaryVolumeDescriptor struct must exactly 2048 bytes long
  * since we expect the supplementary volume descriptor to be right
- * after it. The magic declaration below ensures we get a compilatin
- * error if its size is not correct
+ * after it.
  */
-char dummy[sizeof(struct _PrimaryVolumeDescriptor) == 2048 ? 1 : -1];
+G_STATIC_ASSERT(sizeof(struct _PrimaryVolumeDescriptor) == 2048);
 
 typedef struct _SupplementaryVolumeDescriptor SupplementaryVolumeDescriptor;
 
-- 
2.19.1




More information about the Libosinfo mailing list