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

Matthew Booth mbooth at redhat.com
Mon Feb 25 11:25:41 UTC 2013


On Mon, 2013-02-25 at 10:56 +0100, Olaf Hering wrote:
> 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)
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs

I updated the preceding comment and added spaces before function
arguments.

ACK (and pushed).

Thanks,

Matt




More information about the Libguestfs mailing list