Re: [PATCH 4/4] test_bitmap: add testcases for bitmap_parselist

2018-12-23 Thread kbuild test robot
Hi Yuri,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.20-rc7 next-20181221]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Yuri-Norov/rework-bitmap_parselist/20181223-175529
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

>> lib//bitmap.c:519:24: warning: incorrect type in argument 1 (different 
>> address spaces)
   lib//bitmap.c:519:24:expected void const volatile [noderef]  *
   lib//bitmap.c:519:24:got char const *str
   lib//bitmap.c:735:53: warning: incorrect type in argument 2 (different 
address spaces)
   lib//bitmap.c:735:53:expected char const *const end
   lib//bitmap.c:735:53:got char const [noderef]  *
   include/linux/slab.h:332:43: warning: dubious: x & !y

vim +519 lib//bitmap.c

87ac23b8 Yuri Norov 2018-12-23  515  
32eb0e6b Yuri Norov 2018-12-23  516  static long get_char(char *c, const char 
*str, int is_user)
32eb0e6b Yuri Norov 2018-12-23  517  {
32eb0e6b Yuri Norov 2018-12-23  518 if (unlikely(is_user))
32eb0e6b Yuri Norov 2018-12-23 @519 return __get_user(*c, str);
32eb0e6b Yuri Norov 2018-12-23  520  
32eb0e6b Yuri Norov 2018-12-23  521 *c = *str;
32eb0e6b Yuri Norov 2018-12-23  522 return 0;
32eb0e6b Yuri Norov 2018-12-23  523  }
32eb0e6b Yuri Norov 2018-12-23  524  

:: The code at line 519 was first introduced by commit
:: 32eb0e6b5e705132d4efef268c65730a2f2b9c41 bitmap_parselist: rework input 
string parser

:: TO: Yuri Norov 
:: CC: 0day robot 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 4/4] test_bitmap: add testcases for bitmap_parselist

2018-12-23 Thread Yuri Norov
Add tests for non-number character, empty regions, integer overflow.

Signed-off-by: Yury Norov 
---
 lib/test_bitmap.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 6cd7d0740005..7580dd6ac599 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -224,7 +224,8 @@ static const unsigned long exp[] __initconst = {
BITMAP_FROM_U64(0x),
BITMAP_FROM_U64(0xfffe),
BITMAP_FROM_U64(0xULL),
-   BITMAP_FROM_U64(0xULL)
+   BITMAP_FROM_U64(0xULL),
+   BITMAP_FROM_U64(0),
 };
 
 static const unsigned long exp2[] __initconst = {
@@ -247,19 +248,34 @@ static const struct test_bitmap_parselist 
parselist_tests[] __initconst = {
{0, "1-31:4/4", [9 * step], 32, 0},
{0, "0-31:1/4,32-63:2/4",   [10 * step], 64, 0},
{0, "0-31:3/4,32-63:4/4",   [11 * step], 64, 0},
+   {0, "  ,,  0-31:3/4  ,, 32-63:4/4  ,,  ",   [11 * step], 64, 0},
 
{0, "0-31:1/4,32-63:2/4,64-95:3/4,96-127:4/4",  exp2, 128, 0},
 
{0, "0-2047:128/256", NULL, 2048, PARSE_TIME},
 
+   {0, "", [12], 8, 0},
+   {0, "\n",   [12], 8, 0},
+   {0, ",,  ,,  , ,  ,",   [12], 8, 0},
+   {0, " ,  ,,  , ,   ",   [12], 8, 0},
+   {0, " ,  ,,  , ,   \n", [12], 8, 0},
+
{-EINVAL, "-1", NULL, 8, 0},
{-EINVAL, "-0", NULL, 8, 0},
{-EINVAL, "10-1", NULL, 8, 0},
{-EINVAL, "0-31:", NULL, 8, 0},
{-EINVAL, "0-31:0", NULL, 8, 0},
+   {-EINVAL, "0-31:0/", NULL, 8, 0},
{-EINVAL, "0-31:0/0", NULL, 8, 0},
{-EINVAL, "0-31:1/0", NULL, 8, 0},
{-EINVAL, "0-31:10/1", NULL, 8, 0},
+   {-EOVERFLOW, "0-98765432123456789:10/1", NULL, 8, 0},
+
+   {-EINVAL, "a-31", NULL, 8, 0},
+   {-EINVAL, "0-a1", NULL, 8, 0},
+   {-EINVAL, "a-31:10/1", NULL, 8, 0},
+   {-EINVAL, "0-31:a/1", NULL, 8, 0},
+   {-EINVAL, "0-\n", NULL, 8, 0},
 };
 
 static void __init test_bitmap_parselist(void)
-- 
2.17.1