[Libguestfs] [PATCH] lib: avoid pragma usage in inspect-fs-windows

Olaf Hering olaf at aepfle.de
Mon Feb 25 09:56:47 UTC 2013


pragma GCC diagnostic is a gcc 4.6+ feature, compilation fails with
older compilers:

inspect-fs-windows.c: In function 'map_registry_disk_blob':
inspect-fs-windows.c:502: error: #pragma GCC diagnostic not allowed inside functions
inspect-fs-windows.c:503: error: #pragma GCC diagnostic not allowed inside functions
inspect-fs-windows.c:505: error: #pragma GCC diagnostic not allowed inside functions
make[3]: *** [libguestfs_la-inspect-fs-windows.lo] Error 1

Use memcpy instead of pragma to fix compile error.

Signed-off-by: Olaf Hering <olaf at aepfle.de>
---
Not compile tested!

 src/inspect-fs-windows.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c
index 346cc55..68ae97c 100644
--- a/src/inspect-fs-windows.c
+++ b/src/inspect-fs-windows.c
@@ -499,10 +499,8 @@ map_registry_disk_blob (guestfs_h *g, const void *blob)
    * Note deliberate cast-align violation here since the data is in a
    * very odd place within the blob.  Thanks Microsoft!
    */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-align"
-  part_offset = le64toh (* (uint64_t *) ((char *) blob + 4));
-#pragma GCC diagnostic pop
+  memcpy(&part_offset, (char *) blob + 4, sizeof(part_offset));
+  part_offset = le64toh (part_offset);
 
   partitions = guestfs_part_list (g, devices[i]);
   if (partitions == NULL)




More information about the Libguestfs mailing list