Re: [PATCH] blk: avoid divide-by-zero with zero granularity

From: kernel test robot
Date: Tue Jan 12 2021 - 13:44:53 EST


Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v5.11-rc3 next-20210112]
[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/Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: x86_64-randconfig-c002-20210112 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/796e67f6b22f94f155669688e5e08281621b3ee6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Li-Feng/blk-avoid-divide-by-zero-with-zero-granularity/20210112-233454
git checkout 796e67f6b22f94f155669688e5e08281621b3ee6
# save the attached .config to linux build tree
make W=1 ARCH=x86_64

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

All errors (new ones prefixed by >>):

In file included from include/linux/blk-cgroup.h:23,
from include/linux/writeback.h:14,
from include/linux/memcontrol.h:22,
from include/linux/swap.h:9,
from include/linux/shmem_fs.h:6,
from drivers/gpu/drm/i915/i915_drv.h:49,
from <command-line>:
include/linux/blkdev.h: In function 'queue_limit_alignment_offset':
>> include/linux/blkdev.h:1492:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
1492 | unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
| ^~~~~~~~
cc1: all warnings being treated as errors


vim +1492 include/linux/blkdev.h

c72758f33784e5e2 Martin K. Petersen 2009-05-22 1484
e03a72e13648ac62 Martin K. Petersen 2010-01-11 1485 static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
81744ee44ab2845c Martin K. Petersen 2009-12-29 1486 {
81744ee44ab2845c Martin K. Petersen 2009-12-29 1487 unsigned int granularity = max(lim->physical_block_size, lim->io_min);
796e67f6b22f94f1 Li Feng 2021-01-12 1488 granularity = granularity >> SECTOR_SHIFT;
796e67f6b22f94f1 Li Feng 2021-01-12 1489 if (!granularity)
796e67f6b22f94f1 Li Feng 2021-01-12 1490 return 0;
796e67f6b22f94f1 Li Feng 2021-01-12 1491
233bde21aa43516b Bart Van Assche 2018-03-14 @1492 unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
233bde21aa43516b Bart Van Assche 2018-03-14 1493 << SECTOR_SHIFT;
81744ee44ab2845c Martin K. Petersen 2009-12-29 1494
b8839b8c55f3fdd6 Mike Snitzer 2014-10-08 1495 return (granularity + lim->alignment_offset - alignment) % granularity;
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1496 }
c72758f33784e5e2 Martin K. Petersen 2009-05-22 1497

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

Attachment: .config.gz
Description: application/gzip