qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast
@ 2012-08-23 21:02 Stefan Weil
  2012-08-24  8:31 ` Hannes Reinecke
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2012-08-23 21:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil, Hannes Reinecke

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.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/megasas.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/megasas.c b/hw/megasas.c
index c35a15d..f2d6783 100644
--- a/hw/megasas.c
+++ b/hw/megasas.c
@@ -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);
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast
  2012-08-24  8:31 ` Hannes Reinecke
@ 2012-08-24  8:16   ` Paolo Bonzini
  2012-08-24 10:37     ` Hannes Reinecke
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2012-08-24  8:16 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Stefan Weil, qemu-devel

Il 24/08/2012 10:31, Hannes Reinecke ha scritto:
> 
>> 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.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> 
> Sigh. I never seem to get the hang of typecasting.
> 
> Acked-by: Hannes Reinecke <hare@suse.de>

Nope, this needs to be fixed using the same scheme that you used for SAS
addresses.  Quick before Anthony notices and disables MEGASAS. :)

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast
  2012-08-23 21:02 [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast Stefan Weil
@ 2012-08-24  8:31 ` Hannes Reinecke
  2012-08-24  8:16   ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2012-08-24  8:31 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-devel

On 08/23/2012 11:02 PM, Stefan Weil wrote:
> 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.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Sigh. I never seem to get the hang of typecasting.

Acked-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast
  2012-08-24  8:16   ` Paolo Bonzini
@ 2012-08-24 10:37     ` Hannes Reinecke
  0 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2012-08-24 10:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Stefan Weil, qemu-devel

On 08/24/2012 10:16 AM, Paolo Bonzini wrote:
> Il 24/08/2012 10:31, Hannes Reinecke ha scritto:
>>
>>> 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.
>>>
>>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>>
>> Sigh. I never seem to get the hang of typecasting.
>>
>> Acked-by: Hannes Reinecke <hare@suse.de>
> 
> 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
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-24 10:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-23 21:02 [Qemu-devel] [PATCH for 1.2] megasas: Fix MinGW compiler warning caused by illegal type cast Stefan Weil
2012-08-24  8:31 ` Hannes Reinecke
2012-08-24  8:16   ` Paolo Bonzini
2012-08-24 10:37     ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).