megasas: Fix MinGW compiler warning caused by illegal type cast
PATCH 1/1 megasas: Fix MinGW compiler warning caused by illegal type cast
Type casts from pointer to integer values must use uintptr_t instead of unsigned long. Otherwise the compiler complains on hosts with sizeof(pointer) != sizeof(long).
The patch also replace magic number 32 by sizeof(info.serial_number) which has the same value but is better for code reviews.
--- hw/megasas.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/megasas.c +2 -2
@@ -698,8 +698,8 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) }memcpy (info.product_name,"MegaRAID SAS 8708EM2" ,20 ); -snprintf (info.serial_number,32 ,"QEMU%08lx" , - (unsigned long )s &0xFFFFFFFF ); +snprintf (info.serial_number,sizeof (info.serial_number), +"QEMU%08" PRIxPTR, (uintptr_t )s &0xFFFFFFFF );snprintf (info.package_version,0x60 ,"%s-QEMU" ,QEMU_VERSION );memcpy (info.image_component[0 ].name,"APP" ,3 );memcpy (info.image_component[0 ].version,MEGASAS_VERSION "-QEMU" ,9 );
Signature · 1 line
1.7.10
Quoted 8 lines · Stefan Weil
Type casts from pointer to integer values must use
uintptr_tinstead of unsigned long. Otherwise the compiler complains on hosts with sizeof(pointer) != sizeof(long).The patch also replace magic number 32 by
sizeof(info.serial_number)which has the same value but is better for code reviews.Signed-off-by Stefan Weil <[email protected]>
Sigh. I never seem to get the hang of typecasting.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg)
Il 24/08/2012 10:31, Hannes Reinecke ha scritto:
Quoted 5 lines
Quoted 5 lines
Type casts from pointer to integer values must use
uintptr_tinstead of unsigned long. Otherwise the compiler complains on hosts with sizeof(pointer) != sizeof(long).
Quoted 8 lines
Quoted 4 lines
The patch also replace magic number 32 by
sizeof(info.serial_number)which has the same value but is better for code reviews.Signed-off-by Stefan Weil <[email protected]>Sigh. I never seem to get the hang of typecasting.
Acked-by Hannes Reinecke <[email protected]>
Nope, this needs to be fixed using the same scheme that you used for SAS addresses. Quick before Anthony notices and disables MEGASAS. :)
Paolo
Quoted 9 lines · Paolo Bonzini
Il 24/08/2012 10:31, Hannes Reinecke ha scritto:
Quoted 8 lines
Quoted 8 lines
Type casts from pointer to integer values must use
uintptr_tinstead of unsigned long. Otherwise the compiler complains on hosts with sizeof(pointer) != sizeof(long).The patch also replace magic number 32 by
sizeof(info.serial_number)which has the same value but is better for code reviews.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Stefan Weil <[email protected]>Sigh. I never seem to get the hang of typecasting.
Acked-by Hannes Reinecke <[email protected]>Nope, this needs to be fixed using the same scheme that you used for SAS addresses. Quick before Anthony notices and disables MEGASAS. :)
Ok, done.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)