[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [6737] Sparse fixes: truncation by cast
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [6737] Sparse fixes: truncation by cast |
Date: |
Sun, 8 Mar 2009 09:26:12 +0200 |
On 3/7/09, Luca Tettamanti <address@hidden> wrote:
> On Sat, Mar 7, 2009 at 4:46 PM, Blue Swirl <address@hidden> wrote:
> > Revision: 6737
> > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6737
> > Author: blueswir1
> > Date: 2009-03-07 15:46:23 +0000 (Sat, 07 Mar 2009)
> > Log Message:
> > -----------
> > Sparse fixes: truncation by cast
> >
> > Fix Sparse warnings about constant truncation caused by cast
> >
>
> > Modified: trunk/bswap.h
> > ===================================================================
> > --- trunk/bswap.h 2009-03-07 15:32:56 UTC (rev 6736)
> > +++ trunk/bswap.h 2009-03-07 15:46:23 UTC (rev 6737)
> > @@ -151,7 +151,7 @@
> > {
> > uint8_t *p1 = (uint8_t *)p;
> >
> > - p1[0] = v;
> > + p1[0] = v & 0xff;
> > p1[1] = v >> 8;
>
>
> Hum, by the same principle the last line should be:
> p1[1] = (v >> 8) & 0xff;
> no?
Maybe and there would be other similar places, but there is no warning
from Sparse except for this. Instead of "fix" I should have used
something like "suppress" because the code wasn't broken, it's just
that now Sparse is much more silent and real warnings are more visible
from the noise.