Re: [spice-server PATCH v1 2/12] migration_protocol: fix alignment warnings on _MAGIC

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

 



> 
> from clang:
> inputs_channel.c:274:36: error: cast from 'const char *' to 'uint32_t *'
> (aka 'unsigned int *') increases required alignment from 1 to 4
> [-Werror,-Wcast-align]
>     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_INPUTS_MAGIC);
>                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
>  server/migration_protocol.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/server/migration_protocol.h b/server/migration_protocol.h
> index fa17c7c..8c5a9bf 100644
> --- a/server/migration_protocol.h
> +++ b/server/migration_protocol.h
> @@ -60,7 +60,7 @@ typedef struct __attribute__ ((__packed__))
> SpiceMigrateDataCharDevice {
>  
>  #define SPICE_MIGRATE_DATA_SPICEVMC_VERSION 1 /* NOTE: increase version when
>  CHAR_DEVICE_VERSION
>                                                   is increased */
> -#define SPICE_MIGRATE_DATA_SPICEVMC_MAGIC (*(uint32_t *)"SVMD")
> +#define SPICE_MIGRATE_DATA_SPICEVMC_MAGIC (*(uint32_t *)(void *)"SVMD")

Why don't define something like

#define SPICE_MAGIC(s) ((uint32_t)(s[0]+s[1]*0x100u+s[2]*0x10000u+s[3]*0x1000000u))

#define SPICE_MIGRATE_DATA_SPICEVMC_MAGIC SPICE_MAGIC("SVMD")

the compiler is able to remove all these pointers magic and produce a good constant.
Of course SPICE_MAGIC should be defined differently for big endian or a call to put
the constant in the right order should be fine.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]