lkml.org 
[lkml]   [2008]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] fix sparse warning from include/linux/mmzone.h
    From
    Date
    On Fri, 2008-02-08 at 14:04 -0800, Linus Torvalds wrote:
    >
    > On Fri, 8 Feb 2008, Andrew Morton wrote:
    > > > #ifdef CONFIG_HIGHMEM
    > > > - int zone_idx = zone - zone->zone_pgdat->node_zones;
    > > > - return zone_idx == ZONE_HIGHMEM ||
    > > > - (zone_idx == ZONE_MOVABLE && zone_movable_is_highmem());
    > > > + const int highmem_off = ZONE_HIGHMEM * sizeof(*zone);
    > > > + const int movable_off = ZONE_MOVABLE * sizeof(*zone);
    > > > +
    > > > + int zone_off = (unsigned long)zone - (unsigned long)zone->zone_pgdat->node_zones;
    > > > + return zone_off == highmem_off ||
    > > > + (zone_off == movable_off && zone_movable_is_highmem());
    > >
    > > hrm. For my i386 build (and that's where CONFIG_HIGHMEM really matters)
    > > this patch makes mm/page_alloc.o six bytes larger, and I don't think the
    > > change did much for readability.
    >
    > Heh, yeah. That's a very odd way to write it.

    As long as you read 'odd' as 'rather dumb'

    >
    > It would probably make more sense to just write it as something like
    >
    > struct zone *base = zone->zone_pgdat->node_zones;
    >
    > if (zone == base + ZONE_HIGHMEM ||
    > (zone == base + ZONE_MOVABLE && zone_movable_is_highmem());

    s/if/return/ I think. And missing a closing brace. Unless I'm (again)
    missing something.

    Harvey




    \
     
     \ /
      Last update: 2008-02-08 23:21    [W:0.021 / U:1.328 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site