lkml.org 
[lkml]   [2008]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] x86: sparse errors from string_32.h
    From
    Date
    On Fri, 2008-02-01 at 10:06 -0800, H. Peter Anvin wrote:
    > Ingo Molnar wrote:
    > > * Harvey Harrison <harvey.harrison@gmail.com> wrote:
    > >
    > >> case 1:
    > >> - *(unsigned char *)s = pattern;
    > >> + *(unsigned char *)s = pattern & 0xff;
    > >
    > > i've applied your fix - but wouldnt it be cleaner to just cast the
    > > pattern variable to unsigned char instead?
    > >
    >
    > Even better, since we're talking about fixed bytes, I suggest writing it as:
    >
    > *(u8 *)s = (u8)pattern;
    >
    > Much more compact and the intent is a little bit more obvious.
    >

    While I agree that is cleaner, that will still produce sparse warnings
    about a cast truncating bits from a constant value. I think that
    explicit & is necessary (unless the cure is worse than the disease).

    Harvey



    \
     
     \ /
      Last update: 2008-02-02 01:43    [W:0.021 / U:0.496 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site