mm/ksm.c - Fix compile warnings (PS ignore my formatting in previous email)
PATCH 1/1 mm/ksm.c - Fix compile warnings (PS ignore my formatting in previous email)
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared here
fix for the above warning:
mm/ksm.c +1 -1
@@ -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;
Quoted 18 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared herefix for the above warning:
Signed-off-by Anil SB <[email protected]>mm/ksm.c +0
-0
mm/ksm.c static void stable_tree_append(struct rmap_item *rmap_item, · line 1086
Quoted 8 lines
mm/ksm.c +1
-1@@ -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 ?
re,
wh
Quoted 31 lines · walter harms
Quoted 18 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared herefix for the above warning:
Signed-off-by Anil SB <[email protected]>mm/ksm.c +0
-0mm/ksm.c static void stable_tree_append(struct rmap_item *rmap_item, · line 1086
Quoted 8 lines
mm/ksm.c +1
-1@@ -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 ?
Quoted 1 line
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.
Regards.
Quoted 30 lines · askb
Quoted 29 lines · walter harms
Quoted 18 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared herefix for the above warning:
Signed-off-by Anil SB <[email protected]>mm/ksm.c +0
-0mm/ksm.c static void stable_tree_append(struct rmap_item *rmap_item, · line 1086
Quoted 8 lines
mm/ksm.c +1
-1@@ -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 ?
Quoted 5 lines
Quoted 1 line
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.
1. sorry for delay.
2. there is no "right" direction. the result should be clear for the code, and this may change between releases, special circumstances may occur and so on.
You may try something like that:
struct page *dst ;
function ( &dst );
IMHO that would clarify the code and fix the naming (page,page2 is not very descriptiv).
re,
wh
Quoted 32 lines · askb
Quoted 31 lines · walter harms
Quoted 18 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared herefix for the above warning:
Signed-off-by Anil SB <[email protected]>mm/ksm.c +0
-0mm/ksm.c static void stable_tree_append(struct rmap_item *rmap_item, · line 1086
Quoted 8 lines
mm/ksm.c +1
-1@@ -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 ?
Quoted 4 lines
Quoted 1 line
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
Quoted 41 lines · Hugh Dickins
Quoted 32 lines · askb
Quoted 31 lines · walter harms
Quoted 18 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared herefix for the above warning:
Signed-off-by Anil SB <[email protected]>mm/ksm.c +0
-0mm/ksm.c static void stable_tree_append(struct rmap_item *rmap_item, · line 1086
Quoted 8 lines
mm/ksm.c +1
-1@@ -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 ?
Quoted 4 lines
Quoted 1 line
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.
Quoted 8 lines
mm/ksm.cis 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?
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
Quoted 4 lines
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.
I got the warning while doing "make randconfig". However, now after a cleanup and redoing the same, the warning is not seen.
Quoted 5 lines
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
Thanks.
Quoted 10 lines · askb
Quoted 9 lines · Hugh Dickins
Quoted 8 lines · askb
Quoted 7 lines · walter harms
Quoted 6 lines · askb
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 functionmm/ksm.c:1083: note: ‘page2[0u]’ was declared here
...
Quoted 3 lines
Quoted 1 line
Which version of the compiler gave you that uninitialized warning?
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
Thanks: funny, that's the one I've been using most too.
Quoted 7 lines
Quoted 5 lines
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.
I got the warning while doing "make randconfig". However, now after a cleanup and redoing the same, the warning is not seen.
I just tried the most obvious alternatives (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING, off and on), but still didn't see the warning.
Never mind, I've shoved a NULL in my tree, but no rush for this.
Hugh