From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iy6t9-0002y4-Vr for qemu-devel@nongnu.org; Fri, 30 Nov 2007 09:30:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iy6t9-0002xs-9M for qemu-devel@nongnu.org; Fri, 30 Nov 2007 09:30:43 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iy6t9-0002xp-3t for qemu-devel@nongnu.org; Fri, 30 Nov 2007 09:30:43 -0500 Received: from ug-out-1314.google.com ([66.249.92.169]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iy6t8-0005uF-EA for qemu-devel@nongnu.org; Fri, 30 Nov 2007 09:30:42 -0500 Received: by ug-out-1314.google.com with SMTP id m2so1946498uge for ; Fri, 30 Nov 2007 06:30:40 -0800 (PST) Message-ID: Date: Fri, 30 Nov 2007 15:30:40 +0100 From: "andrzej zaborowski" Subject: Re: [Qemu-devel] [PATCH] fix gcc4 compile warnings In-Reply-To: <475019BF.4040906@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <474F5223.1000202@andrep.de> <475019BF.4040906@amd.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 30/11/2007, Andre Przywara wrote: > > These casts are not the right way to get rid of the warnings, as are > > some of the casts in other files in qemu_put_* and qemu_get_* > > arguments. In this case the warnings are true positives and the bugs > > causing the warnings have to be addressed instead of just the > > warnings. > > Are you sure of that? Most of the fixes are like this: > >> - qemu_put_be32s(f, &s->count_shift); > >> + qemu_put_be32s(f, (uint32_t *)&s->count_shift); > qemu_put_be32s is (QEMUFile *f, const uint32_t *pv), but after all the > 2nd argument is only a _pointer_ to an unsigned variable, the size is > the same (thanks to the C99 explicit types). count_shift is an int so it is the machine word size, not necesarily 32-bit AFAIK. Otherwise I guess gcc wouldn't warn. You can possibly use: qemu_put_be32(f, s->count_shift); Or point qemu_put_be32_s() to a int32_t/uint32_t variable. > > What solution do you prefer for the opaque types? I have used the simple: > >> - void *args[MAX_ARGS]; > >> + intptr_t args[MAX_ARGS]; > A more portable and clean solution would be this: > - void *args[MAX_ARGS]; > + union > + { > + void* ptr; > + int i; > + } args[MAX_ARGS]; > If you prefer this, I can change the patch accordingly. I'm not sure why you get a warning here and I'm unable to run a build at the moment. A void * should be able to store some (unknown size) integer regardless of the platform. Regards