Re: [PATCH] mm/ksm.c - Fix compile warnings (PS ignore my formatting in previous email)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 4 Nov 2009, askb wrote:
> On Wed, 2009-11-04 at 10:57 +0100, walter harms wrote:
> > 
> > askb schrieb:
> > > Found the compiler warning on linux-next: 	
> > > 
> > > mm/ksm.c: In function ‘ksm_scan_thread’:
> > > mm/ksm.c:1083: warning: ‘page2[0u]’ may be used uninitialized in this
> > > function
> > > mm/ksm.c:1083: note: ‘page2[0u]’ was declared here
> > > 
> > > fix for the above warning:
> > > 
> > > Signed-off-by: Anil SB <askb23@xxxxxxxxx>
> > > 
> > > diff --git a/mm/ksm.c b/mm/ksm.c
> > > index bef1af4..2ea0fd3 100644
> > > --- a/mm/ksm.c
> > > +++ b/mm/ksm.c
> > > @@ -1080,7 +1080,7 @@ static void stable_tree_append(struct rmap_item *rmap_item,
> > >   */
> > >  static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
> > >  {
> > > -	struct page *page2[1];
> > > +	struct page *page2[1] = {NULL};
> > >  	struct rmap_item *tree_rmap_item;
> > >  	unsigned int checksum;
> > >  	int err;
> > > 
> > > 
> > 
> > a 1 element array looks strange, did you look what kind of magic is here used ?
> > 
> >From my understanding, it is used for place holder to check and return
> an identical page from stable_tree_search(). Can we do with a double
> indirection to struct page instead of the above? 
> PS point me in the right direction.

I don't particularly like things like page2[1] myself, but there's
nothing actually wrong with it, so no urgency to change it.

mm/ksm.c is under active development (better Cc the people involved
with a sourcefile when considering changes to it), and I have a
collection of patches under testing, which do change some names
around here (along with more serious changes).  So, thanks for looking
at this, but I'd prefer to avoid the interference of a trivial patch
at the moment - sorry.

Which version of the compiler gave you that uninitialized warning?
A version which lots of people are using, or just some snapshot?
I've never seen a warning there myself, but they do keep "refining"
that logic.

Hugh's hypothesis: for every variable x initialized by a subfunction,
there exists at least one version V of gcc, such that V reports that
x may be used uninitialized.

Hugh

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux