Message ID | b48e27a46567a6870e3bedfea1fd74f3f3177004.1545126272.git.vilhelm.gray@gmail.com |
---|---|
State | New |
Headers | show |
Series | Introduce the for_each_set_clump8 macro | expand |
Hi William, I love your patch! Yet something to improve: [auto build test ERROR on gpio/for-next] [also build test ERROR on v4.20-rc7 next-20181218] [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/William-Breathitt-Gray/Introduce-the-for_each_set_clump8-macro/20181219-004325 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: x86_64-randconfig-x011-201850 (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 error/warnings (new ones prefixed by >>): In file included from include/linux/printk.h:7:0, from include/linux/kernel.h:14, from include/asm-generic/bug.h:18, from arch/x86/include/asm/bug.h:47, from include/linux/bug.h:5, from include/linux/jump_label.h:251, from arch/x86/include/asm/string_64.h:6, from arch/x86/include/asm/string.h:5, from include/linux/string.h:20, from include/linux/bitmap.h:9, from lib/test_bitmap.c:7: lib/test_bitmap.c: In function '__check_eq_clump8': >> include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=] #define KERN_SOH "\001" /* ASCII Start Of Header */ ^ include/linux/kern_levels.h:12:22: note: in expansion of macro 'KERN_SOH' #define KERN_WARNING KERN_SOH "4" /* warning conditions */ ^~~~~~~~ include/linux/printk.h:310:9: note: in expansion of macro 'KERN_WARNING' printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~ include/linux/printk.h:311:17: note: in expansion of macro 'pr_warning' #define pr_warn pr_warning ^~~~~~~~~~ >> lib/test_bitmap.c:100:3: note: in expansion of macro 'pr_warn' pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %zu, got %zu\n", ^~~~~~~ include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=] #define KERN_SOH "\001" /* ASCII Start Of Header */ ^ include/linux/kern_levels.h:12:22: note: in expansion of macro 'KERN_SOH' #define KERN_WARNING KERN_SOH "4" /* warning conditions */ ^~~~~~~~ include/linux/printk.h:310:9: note: in expansion of macro 'KERN_WARNING' printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~ include/linux/printk.h:311:17: note: in expansion of macro 'pr_warning' #define pr_warn pr_warning ^~~~~~~~~~ >> lib/test_bitmap.c:100:3: note: in expansion of macro 'pr_warn' pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %zu, got %zu\n", ^~~~~~~ >> include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=] #define KERN_SOH "\001" /* ASCII Start Of Header */ ^ include/linux/kern_levels.h:12:22: note: in expansion of macro 'KERN_SOH' #define KERN_WARNING KERN_SOH "4" /* warning conditions */ ^~~~~~~~ include/linux/printk.h:310:9: note: in expansion of macro 'KERN_WARNING' printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~ include/linux/printk.h:311:17: note: in expansion of macro 'pr_warning' #define pr_warn pr_warning ^~~~~~~~~~ lib/test_bitmap.c:107:3: note: in expansion of macro 'pr_warn' pr_warn("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %zu with clump value 0", ^~~~~~~ In file included from include/linux/bitmap.h:8:0, from lib/test_bitmap.c:7: lib/test_bitmap.c: In function 'test_for_each_set_clump8': >> include/linux/bitops.h:46:53: error: 'offset' undeclared (first use in this function); did you mean 'off_t'? (start) = find_next_clump8(&(clump), (bits), (offset) + 1, (size))) ^ >> lib/test_bitmap.c:426:2: note: in expansion of macro 'for_each_set_clump8' for_each_set_clump8(start, clump, bits, size) ^~~~~~~~~~~~~~~~~~~ include/linux/bitops.h:46:53: note: each undeclared identifier is reported only once for each function it appears in (start) = find_next_clump8(&(clump), (bits), (offset) + 1, (size))) ^ >> lib/test_bitmap.c:426:2: note: in expansion of macro 'for_each_set_clump8' for_each_set_clump8(start, clump, bits, size) ^~~~~~~~~~~~~~~~~~~ >> lib/test_bitmap.c:125:8: error: implicit declaration of function '__check_eq_clump'; did you mean '__check_eq_clump8'? [-Werror=implicit-function-declaration] if (!__check_eq_ ## suffix(__FILE__, __LINE__, \ ^ >> lib/test_bitmap.c:137:32: note: in expansion of macro '__expect_eq' #define expect_eq_clump8(...) __expect_eq(clump, ##__VA_ARGS__) ^~~~~~~~~~~ >> lib/test_bitmap.c:427:3: note: in expansion of macro 'expect_eq_clump8' expect_eq_clump8(offset, size, clump_exp, clump); ^~~~~~~~~~~~~~~~ At top level: lib/test_bitmap.c:91:20: warning: '__check_eq_clump8' defined but not used [-Wunused-function] static bool __init __check_eq_clump8(const char *srcfile, unsigned int line, ^~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +125 lib/test_bitmap.c 5fd003f5 David Decotigny 2016-02-19 90 7b161d18 William Breathitt Gray 2018-12-18 91 static bool __init __check_eq_clump8(const char *srcfile, unsigned int line, 7b161d18 William Breathitt Gray 2018-12-18 92 const unsigned int offset, 7b161d18 William Breathitt Gray 2018-12-18 93 const unsigned int size, 7b161d18 William Breathitt Gray 2018-12-18 94 const unsigned char *const clump_exp, 7b161d18 William Breathitt Gray 2018-12-18 95 const unsigned long *const clump) 7b161d18 William Breathitt Gray 2018-12-18 96 { 7b161d18 William Breathitt Gray 2018-12-18 97 unsigned long exp; 7b161d18 William Breathitt Gray 2018-12-18 98 7b161d18 William Breathitt Gray 2018-12-18 99 if (offset >= size) { 7b161d18 William Breathitt Gray 2018-12-18 @100 pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %zu, got %zu\n", 7b161d18 William Breathitt Gray 2018-12-18 101 srcfile, line, size, offset); 7b161d18 William Breathitt Gray 2018-12-18 102 return false; 7b161d18 William Breathitt Gray 2018-12-18 103 } 7b161d18 William Breathitt Gray 2018-12-18 104 7b161d18 William Breathitt Gray 2018-12-18 105 exp = clump_exp[offset / 8]; 7b161d18 William Breathitt Gray 2018-12-18 106 if (!exp) { 7b161d18 William Breathitt Gray 2018-12-18 @107 pr_warn("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %zu with clump value 0", 7b161d18 William Breathitt Gray 2018-12-18 108 srcfile, line, offset); 7b161d18 William Breathitt Gray 2018-12-18 109 return false; 7b161d18 William Breathitt Gray 2018-12-18 110 } 7b161d18 William Breathitt Gray 2018-12-18 111 7b161d18 William Breathitt Gray 2018-12-18 112 if (*clump != exp) { 7b161d18 William Breathitt Gray 2018-12-18 113 pr_warn("[%s:%u] expected clump value of 0x%lX, got clump value of 0x%lX", 7b161d18 William Breathitt Gray 2018-12-18 114 srcfile, line, exp, *clump); 7b161d18 William Breathitt Gray 2018-12-18 115 return false; 7b161d18 William Breathitt Gray 2018-12-18 116 } 7b161d18 William Breathitt Gray 2018-12-18 117 7b161d18 William Breathitt Gray 2018-12-18 118 return true; 7b161d18 William Breathitt Gray 2018-12-18 119 } 7b161d18 William Breathitt Gray 2018-12-18 120 5fd003f5 David Decotigny 2016-02-19 121 #define __expect_eq(suffix, ...) \ 5fd003f5 David Decotigny 2016-02-19 122 ({ \ 5fd003f5 David Decotigny 2016-02-19 123 int result = 0; \ 5fd003f5 David Decotigny 2016-02-19 124 total_tests++; \ 5fd003f5 David Decotigny 2016-02-19 @125 if (!__check_eq_ ## suffix(__FILE__, __LINE__, \ 5fd003f5 David Decotigny 2016-02-19 126 ##__VA_ARGS__)) { \ 5fd003f5 David Decotigny 2016-02-19 127 failed_tests++; \ 5fd003f5 David Decotigny 2016-02-19 128 result = 1; \ 5fd003f5 David Decotigny 2016-02-19 129 } \ 5fd003f5 David Decotigny 2016-02-19 130 result; \ 5fd003f5 David Decotigny 2016-02-19 131 }) 5fd003f5 David Decotigny 2016-02-19 132 5fd003f5 David Decotigny 2016-02-19 133 #define expect_eq_uint(...) __expect_eq(uint, ##__VA_ARGS__) 5fd003f5 David Decotigny 2016-02-19 134 #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) 5fd003f5 David Decotigny 2016-02-19 135 #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) 5fd003f5 David Decotigny 2016-02-19 136 #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) 7b161d18 William Breathitt Gray 2018-12-18 @137 #define expect_eq_clump8(...) __expect_eq(clump, ##__VA_ARGS__) 5fd003f5 David Decotigny 2016-02-19 138 :::::: The code at line 125 was first introduced by commit :::::: 5fd003f56c2c584b62a0486ad25bbd4be02b8b6c test_bitmap: unit tests for lib/bitmap.c :::::: TO: David Decotigny <decot@googlers.com> :::::: CC: David S. Miller <davem@davemloft.net> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 6cd7d0740005..8a8dbe513ab4 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -88,6 +88,36 @@ __check_eq_u32_array(const char *srcfile, unsigned int line, return true; } +static bool __init __check_eq_clump8(const char *srcfile, unsigned int line, + const unsigned int offset, + const unsigned int size, + const unsigned char *const clump_exp, + const unsigned long *const clump) +{ + unsigned long exp; + + if (offset >= size) { + pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %zu, got %zu\n", + srcfile, line, size, offset); + return false; + } + + exp = clump_exp[offset / 8]; + if (!exp) { + pr_warn("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %zu with clump value 0", + srcfile, line, offset); + return false; + } + + if (*clump != exp) { + pr_warn("[%s:%u] expected clump value of 0x%lX, got clump value of 0x%lX", + srcfile, line, exp, *clump); + return false; + } + + return true; +} + #define __expect_eq(suffix, ...) \ ({ \ int result = 0; \ @@ -104,6 +134,7 @@ __check_eq_u32_array(const char *srcfile, unsigned int line, #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) +#define expect_eq_clump8(...) __expect_eq(clump, ##__VA_ARGS__) static void __init test_zero_clear(void) { @@ -361,6 +392,41 @@ static void noinline __init test_mem_optimisations(void) } } +static const unsigned char clump_exp[] __initconst = { + 0x01, /* 1 bit set */ + 0x02, /* non-edge 1 bit set */ + 0x00, /* zero bits set */ + 0x28, /* 3 bits set across 4-bit boundary */ + 0x28, /* Repeated clump */ + 0x0F, /* 4 bits set */ + 0xFF, /* all bits set */ + 0x05, /* non-adjacent 2 bits set */ +}; + +static void __init test_for_each_set_clump8(void) +{ + unsigned int start; + unsigned long clump; +#define CLUMP_BITMAP_NUMBITS 64 + DECLARE_BITMAP(bits, CLUMP_BITMAP_NUMBITS); +#define CLUMP_SIZE 8 + const size_t size = DIV_ROUND_UP(CLUMP_BITMAP_NUMBITS, CLUMP_SIZE); + + /* set bitmap to test case */ + bitmap_zero(bits, CLUMP_BITMAP_NUMBITS); + bitmap_set(bits, 0, 1); /* 0x01 */ + bitmap_set(bits, 8, 1); /* 0x02 */ + bitmap_set(bits, 27, 3); /* 0x28 */ + bitmap_set(bits, 35, 3); /* 0x28 */ + bitmap_set(bits, 40, 4); /* 0x0F */ + bitmap_set(bits, 48, 8); /* 0xFF */ + bitmap_set(bits, 56, 1); /* 0x05 - part 1 */ + bitmap_set(bits, 58, 1); /* 0x05 - part 2 */ + + for_each_set_clump8(start, clump, bits, size) + expect_eq_clump8(offset, size, clump_exp, clump); +} + static int __init test_bitmap_init(void) { test_zero_clear(); @@ -369,6 +435,7 @@ static int __init test_bitmap_init(void) test_bitmap_arr32(); test_bitmap_parselist(); test_mem_optimisations(); + test_for_each_set_clump8(); if (failed_tests == 0) pr_info("all %u tests passed\n", total_tests);
The introduction of the for_each_set_clump8 macro warrants test cases to verify the implementation. This patch adds test case checks for whether an out-of-bounds clump index is returned, a zero clump is returned, or the returned clump value differs from the expected clump value. Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> --- lib/test_bitmap.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)