Clean up hugemmap02 testcase
PATCH v2 1/1 Clean up hugemmap02 testcase
From: Shuang Qiu <[email protected]>
* Remove continue in the loop because it skips the cleanup
* munmap() addr2 for 32-bit
* close nfildes fd in the end of loop
--- testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +5 -10
@@ -155,24 +155,20 @@ int main(int ac, char **av) addr2 =mmap ((void *)low_addr2, map_sz,PROT_READ |PROT_WRITE ,MAP_SHARED , fildes,0 );#if __WORDSIZE ==64 /* 64-bit process */ -if (addr2 ==MAP_FAILED ) { +if (addr2 ==MAP_FAILED )tst_resm (TFAIL |TERRNO ,"huge mmap failed unexpectedly" " with %s (64-bit)" ,TEMPFILE ); -close (fildes); -continue ; - }else { +else {tst_resm (TPASS ,"huge mmap succeeded (64-bit)" ); }#else /* 32-bit process */ if (addr2 ==MAP_FAILED )tst_resm (TFAIL |TERRNO ,"huge mmap failed unexpectedly" " with %s (32-bit)" ,TEMPFILE ); -else if (addr2 >0 ) { +else if (addr2 >0 )tst_resm (TCONF ,"huge mmap failed to test the scenario" ); -close (fildes); -continue ; - }else if (addr ==0 ) +else if (addr ==0 )tst_resm (TPASS ,"huge mmap succeeded (32-bit)" );#endif
@@ -183,13 +179,12 @@ int main(int ac, char **av) "munmap of addrlist[%d] failed", i); } -#if __WORDSIZE ==64 if (munmap (addr2, map_sz) ==-1 )tst_brkm (TFAIL |TERRNO ,NULL ,"huge munmap failed" ); -#endif if (munmap (addr, page_sz) ==-1 )tst_brkm (TFAIL |TERRNO ,NULL ,"munmap failed" ); +close (nfildes);close (fildes); }
Signature · 1 line
1.7.9.5
PATCH v2 1/1 Clean up hugemmap02 testcase
Hi!
Quoted 14 lines
#if
__WORDSIZE== 64 /* 64-bit process */testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +2
-4-if (addr2 ==MAP_FAILED ) { +if (addr2 ==MAP_FAILED )tst_resm (TFAIL |TERRNO ,"huge mmap failed unexpectedly" " with %s (64-bit)" ,TEMPFILE ); -close (fildes); -continue ; - }else { +else {tst_resm (TPASS ,"huge mmap succeeded (64-bit)" ); }#else /* 32-bit process */ if (addr2 ==MAP_FAILED ) tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c int main(int ac, char **av) · line 172
Quoted 10 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +2
-4" with %s (32-bit)", TEMPFILE); - else if (addr2 > 0) { + else if (addr2 > 0) tst_resm(TCONF, "huge mmap failed to test the scenario"); -close (fildes); -continue ; - } else if (addr == 0) + else if (addr == 0) tst_resm(TPASS, "huge mmap succeeded (32-bit)");
The LKML coding style says that we should add curly braces to both else branches if they are around one of them. Or if the function call after if spans across more lines. So please do not remove them.
Otherwise the change looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 Clean up hugemmap02 testcase
Quoted 20 lines · Cyril Hrubis
Hi!
Quoted 19 lines
#if __WORDSIZE == 64 /* 64-bit process */testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +3
-5-if (addr2 ==MAP_FAILED ) { +if (addr2 ==MAP_FAILED )tst_resm (TFAIL |TERRNO ,"huge mmap failed unexpectedly" " with %s (64-bit)" ,TEMPFILE ); -close (fildes); -continue ; - }else { +else {tst_resm (TPASS ,"huge mmap succeeded (64-bit)" ); }#else /* 32-bit process */ if (addr2 ==MAP_FAILED )tst_resm (TFAIL |TERRNO ,"huge mmap failed unexpectedly" " with %s (32-bit)" ,TEMPFILE ); -else if (addr2 >0 ) { +else if (addr2 >0 )tst_resm (TCONF ,"huge mmap failed to test the scenario" );
Quoted 8 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c int main(int ac, char **av) · line 172
Quoted 5 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +1
-3-close (fildes); -continue ; - }else if (addr ==0 ) +else if (addr ==0 )tst_resm (TPASS ,"huge mmap succeeded (32-bit)" );The LKML coding style says that we should add curly braces to both else branches if they are around one of them. Or if the function call after if spans across more lines. So please do not remove them.
Thanks for review and correct me it.
Will send a new one.
Thanks
Shuang
Quoted 3 lines
Otherwise the change looks good.