Re: [PATCH] lib/bch:using swap() instead of tmp variable

From: kernel test robot
Date: Wed Nov 10 2021 - 06:32:46 EST


Hi Yihao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.15 next-20211110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Yihao-Han/lib-bch-using-swap-instead-of-tmp-variable/20211109-143502
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d2f38a3c6507b2520101f9a3807ed98f1bdc545a
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/67120a42a5dc4e4a08d998ae4dc41d9bf31946b5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yihao-Han/lib-bch-using-swap-instead-of-tmp-variable/20211109-143502
git checkout 67120a42a5dc4e4a08d998ae4dc41d9bf31946b5
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

lib/bch.c: In function 'solve_linear_system':
>> lib/bch.c:525:25: error: 'tmp' undeclared (first use in this function); did you mean 'tm'?
525 | tmp = rows[p];
| ^~~
| tm
lib/bch.c:525:25: note: each undeclared identifier is reported only once for each function it appears in


vim +525 lib/bch.c

437aa565e265677 Ivan Djelic 2011-03-11 494
437aa565e265677 Ivan Djelic 2011-03-11 495 /*
437aa565e265677 Ivan Djelic 2011-03-11 496 * solve a m x m linear system in GF(2) with an expected number of solutions,
437aa565e265677 Ivan Djelic 2011-03-11 497 * and return the number of found solutions
437aa565e265677 Ivan Djelic 2011-03-11 498 */
437aa565e265677 Ivan Djelic 2011-03-11 499 static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
437aa565e265677 Ivan Djelic 2011-03-11 500 unsigned int *sol, int nsol)
437aa565e265677 Ivan Djelic 2011-03-11 501 {
437aa565e265677 Ivan Djelic 2011-03-11 502 const int m = GF_M(bch);
67120a42a5dc4e4 Yihao Han 2021-11-08 503 unsigned int mask;
02361bc7788852f Kees Cook 2018-05-31 504 int rem, c, r, p, k, param[BCH_MAX_M];
437aa565e265677 Ivan Djelic 2011-03-11 505
437aa565e265677 Ivan Djelic 2011-03-11 506 k = 0;
437aa565e265677 Ivan Djelic 2011-03-11 507 mask = 1 << m;
437aa565e265677 Ivan Djelic 2011-03-11 508
437aa565e265677 Ivan Djelic 2011-03-11 509 /* Gaussian elimination */
437aa565e265677 Ivan Djelic 2011-03-11 510 for (c = 0; c < m; c++) {
437aa565e265677 Ivan Djelic 2011-03-11 511 rem = 0;
437aa565e265677 Ivan Djelic 2011-03-11 512 p = c-k;
437aa565e265677 Ivan Djelic 2011-03-11 513 /* find suitable row for elimination */
437aa565e265677 Ivan Djelic 2011-03-11 514 for (r = p; r < m; r++) {
437aa565e265677 Ivan Djelic 2011-03-11 515 if (rows[r] & mask) {
437aa565e265677 Ivan Djelic 2011-03-11 516 if (r != p) {
67120a42a5dc4e4 Yihao Han 2021-11-08 517 swap(rows[r], rows[p]);
437aa565e265677 Ivan Djelic 2011-03-11 518 }
437aa565e265677 Ivan Djelic 2011-03-11 519 rem = r+1;
437aa565e265677 Ivan Djelic 2011-03-11 520 break;
437aa565e265677 Ivan Djelic 2011-03-11 521 }
437aa565e265677 Ivan Djelic 2011-03-11 522 }
437aa565e265677 Ivan Djelic 2011-03-11 523 if (rem) {
437aa565e265677 Ivan Djelic 2011-03-11 524 /* perform elimination on remaining rows */
437aa565e265677 Ivan Djelic 2011-03-11 @525 tmp = rows[p];
437aa565e265677 Ivan Djelic 2011-03-11 526 for (r = rem; r < m; r++) {
437aa565e265677 Ivan Djelic 2011-03-11 527 if (rows[r] & mask)
437aa565e265677 Ivan Djelic 2011-03-11 528 rows[r] ^= tmp;
437aa565e265677 Ivan Djelic 2011-03-11 529 }
437aa565e265677 Ivan Djelic 2011-03-11 530 } else {
437aa565e265677 Ivan Djelic 2011-03-11 531 /* elimination not needed, store defective row index */
437aa565e265677 Ivan Djelic 2011-03-11 532 param[k++] = c;
437aa565e265677 Ivan Djelic 2011-03-11 533 }
437aa565e265677 Ivan Djelic 2011-03-11 534 mask >>= 1;
437aa565e265677 Ivan Djelic 2011-03-11 535 }
437aa565e265677 Ivan Djelic 2011-03-11 536 /* rewrite system, inserting fake parameter rows */
437aa565e265677 Ivan Djelic 2011-03-11 537 if (k > 0) {
437aa565e265677 Ivan Djelic 2011-03-11 538 p = k;
437aa565e265677 Ivan Djelic 2011-03-11 539 for (r = m-1; r >= 0; r--) {
437aa565e265677 Ivan Djelic 2011-03-11 540 if ((r > m-1-k) && rows[r])
437aa565e265677 Ivan Djelic 2011-03-11 541 /* system has no solution */
437aa565e265677 Ivan Djelic 2011-03-11 542 return 0;
437aa565e265677 Ivan Djelic 2011-03-11 543
437aa565e265677 Ivan Djelic 2011-03-11 544 rows[r] = (p && (r == param[p-1])) ?
437aa565e265677 Ivan Djelic 2011-03-11 545 p--, 1u << (m-r) : rows[r-p];
437aa565e265677 Ivan Djelic 2011-03-11 546 }
437aa565e265677 Ivan Djelic 2011-03-11 547 }
437aa565e265677 Ivan Djelic 2011-03-11 548
437aa565e265677 Ivan Djelic 2011-03-11 549 if (nsol != (1 << k))
437aa565e265677 Ivan Djelic 2011-03-11 550 /* unexpected number of solutions */
437aa565e265677 Ivan Djelic 2011-03-11 551 return 0;
437aa565e265677 Ivan Djelic 2011-03-11 552
437aa565e265677 Ivan Djelic 2011-03-11 553 for (p = 0; p < nsol; p++) {
437aa565e265677 Ivan Djelic 2011-03-11 554 /* set parameters for p-th solution */
437aa565e265677 Ivan Djelic 2011-03-11 555 for (c = 0; c < k; c++)
437aa565e265677 Ivan Djelic 2011-03-11 556 rows[param[c]] = (rows[param[c]] & ~1)|((p >> c) & 1);
437aa565e265677 Ivan Djelic 2011-03-11 557
437aa565e265677 Ivan Djelic 2011-03-11 558 /* compute unique solution */
437aa565e265677 Ivan Djelic 2011-03-11 559 tmp = 0;
437aa565e265677 Ivan Djelic 2011-03-11 560 for (r = m-1; r >= 0; r--) {
437aa565e265677 Ivan Djelic 2011-03-11 561 mask = rows[r] & (tmp|1);
437aa565e265677 Ivan Djelic 2011-03-11 562 tmp |= parity(mask) << (m-r);
437aa565e265677 Ivan Djelic 2011-03-11 563 }
437aa565e265677 Ivan Djelic 2011-03-11 564 sol[p] = tmp >> 1;
437aa565e265677 Ivan Djelic 2011-03-11 565 }
437aa565e265677 Ivan Djelic 2011-03-11 566 return nsol;
437aa565e265677 Ivan Djelic 2011-03-11 567 }
437aa565e265677 Ivan Djelic 2011-03-11 568

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip