* [PATCH] ext4: use min() to make code cleaner
@ 2021-12-16 9:10 cgel.zte
2021-12-17 2:11 ` kernel test robot
2021-12-18 22:31 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2021-12-16 9:10 UTC (permalink / raw)
To: tytso; +Cc: adilger.kernel, linux-ext4, linux-kernel, Changcheng Deng,
Zeal Robot
From: Changcheng Deng <deng.changcheng@zte.com.cn>
Use min() in order to make code cleaner.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
fs/ext4/super.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 5ec5a1c3b364..d0c50e0e787d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6922,8 +6922,7 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
len = i_size-off;
toread = len;
while (toread > 0) {
- tocopy = sb->s_blocksize - offset < toread ?
- sb->s_blocksize - offset : toread;
+ tocopy = min(sb->s_blocksize - offset, toread);
bh = ext4_bread(NULL, inode, blk, 0);
if (IS_ERR(bh))
return PTR_ERR(bh);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use min() to make code cleaner
2021-12-16 9:10 [PATCH] ext4: use min() to make code cleaner cgel.zte
@ 2021-12-17 2:11 ` kernel test robot
2021-12-18 22:31 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-12-17 2:11 UTC (permalink / raw)
To: cgel.zte, tytso
Cc: llvm, kbuild-all, adilger.kernel, linux-ext4, linux-kernel,
Changcheng Deng, Zeal Robot
Hi,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tytso-ext4/dev]
[also build test WARNING on v5.16-rc5 next-20211215]
[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/cgel-zte-gmail-com/ext4-use-min-to-make-code-cleaner/20211216-171213
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: hexagon-randconfig-r026-20211216 (https://download.01.org/0day-ci/archive/20211217/202112171003.SXtQAHHE-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dd245bab9fbb364faa1581e4f92ba3119a872fba)
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/ff519f2d7d41c154cb0d31a9aebe16ce1f6af7ed
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/ext4-use-min-to-make-code-cleaner/20211216-171213
git checkout ff519f2d7d41c154cb0d31a9aebe16ce1f6af7ed
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash fs/ext4/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> fs/ext4/super.c:6926:12: warning: comparison of distinct pointer types ('typeof (sb->s_blocksize - offset) *' (aka 'unsigned long *') and 'typeof (toread) *' (aka 'unsigned int *')) [-Wcompare-distinct-pointer-types]
tocopy = min(sb->s_blocksize - offset, toread);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
fs/ext4/super.c:2173:1: warning: unused function 'ctx_test_flags' [-Wunused-function]
EXT4_SET_CTX(flags);
^
fs/ext4/super.c:2168:20: note: expanded from macro 'EXT4_SET_CTX'
static inline bool ctx_test_##name(struct ext4_fs_context *ctx, int flag)\
^
<scratch space>:148:1: note: expanded from here
ctx_test_flags
^
fs/ext4/super.c:2176:1: warning: unused function 'ctx_clear_mount_flags' [-Wunused-function]
EXT4_SET_CTX(mount_flags);
^
fs/ext4/super.c:2163:20: note: expanded from macro 'EXT4_SET_CTX'
static inline void ctx_clear_##name(struct ext4_fs_context *ctx, int flag)\
^
<scratch space>:169:1: note: expanded from here
ctx_clear_mount_flags
^
fs/ext4/super.c:2176:1: warning: unused function 'ctx_test_mount_flags' [-Wunused-function]
fs/ext4/super.c:2168:20: note: expanded from macro 'EXT4_SET_CTX'
static inline bool ctx_test_##name(struct ext4_fs_context *ctx, int flag)\
^
<scratch space>:172:1: note: expanded from here
ctx_test_mount_flags
^
4 warnings generated.
vim +6926 fs/ext4/super.c
6904
6905 /* Read data from quotafile - avoid pagecache and such because we cannot afford
6906 * acquiring the locks... As quota files are never truncated and quota code
6907 * itself serializes the operations (and no one else should touch the files)
6908 * we don't have to be afraid of races */
6909 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
6910 size_t len, loff_t off)
6911 {
6912 struct inode *inode = sb_dqopt(sb)->files[type];
6913 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
6914 int offset = off & (sb->s_blocksize - 1);
6915 int tocopy;
6916 size_t toread;
6917 struct buffer_head *bh;
6918 loff_t i_size = i_size_read(inode);
6919
6920 if (off > i_size)
6921 return 0;
6922 if (off+len > i_size)
6923 len = i_size-off;
6924 toread = len;
6925 while (toread > 0) {
> 6926 tocopy = min(sb->s_blocksize - offset, toread);
6927 bh = ext4_bread(NULL, inode, blk, 0);
6928 if (IS_ERR(bh))
6929 return PTR_ERR(bh);
6930 if (!bh) /* A hole? */
6931 memset(data, 0, tocopy);
6932 else
6933 memcpy(data, bh->b_data+offset, tocopy);
6934 brelse(bh);
6935 offset = 0;
6936 toread -= tocopy;
6937 data += tocopy;
6938 blk++;
6939 }
6940 return len;
6941 }
6942
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use min() to make code cleaner
2021-12-16 9:10 [PATCH] ext4: use min() to make code cleaner cgel.zte
2021-12-17 2:11 ` kernel test robot
@ 2021-12-18 22:31 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-12-18 22:31 UTC (permalink / raw)
To: cgel.zte, tytso
Cc: kbuild-all, adilger.kernel, linux-ext4, linux-kernel,
Changcheng Deng, Zeal Robot
Hi,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tytso-ext4/dev]
[also build test WARNING on v5.16-rc5 next-20211217]
[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/cgel-zte-gmail-com/ext4-use-min-to-make-code-cleaner/20211216-171213
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: arc-randconfig-s032-20211218 (https://download.01.org/0day-ci/archive/20211219/202112190602.FX1i96n9-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/ff519f2d7d41c154cb0d31a9aebe16ce1f6af7ed
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/ext4-use-min-to-make-code-cleaner/20211216-171213
git checkout ff519f2d7d41c154cb0d31a9aebe16ce1f6af7ed
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash drivers/iio/accel/ fs/ext4/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> fs/ext4/super.c:6926:26: sparse: sparse: incompatible types in comparison expression (different type sizes):
>> fs/ext4/super.c:6926:26: sparse: unsigned long *
>> fs/ext4/super.c:6926:26: sparse: unsigned int *
fs/ext4/super.c:2643:46: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const *objp @@ got char [noderef] __rcu * @@
fs/ext4/super.c:2643:46: sparse: expected void const *objp
fs/ext4/super.c:2643:46: sparse: got char [noderef] __rcu *
fs/ext4/super.c:2698:51: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *cs @@ got char [noderef] __rcu * @@
fs/ext4/super.c:2698:51: sparse: expected char const *cs
fs/ext4/super.c:2698:51: sparse: got char [noderef] __rcu *
fs/ext4/super.c:993:6: sparse: sparse: context imbalance in '__ext4_grp_locked_error' - different lock contexts for basic block
fs/ext4/super.c:3321:9: sparse: sparse: context imbalance in 'ext4_check_descriptors' - different lock contexts for basic block
vim +6926 fs/ext4/super.c
6904
6905 /* Read data from quotafile - avoid pagecache and such because we cannot afford
6906 * acquiring the locks... As quota files are never truncated and quota code
6907 * itself serializes the operations (and no one else should touch the files)
6908 * we don't have to be afraid of races */
6909 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
6910 size_t len, loff_t off)
6911 {
6912 struct inode *inode = sb_dqopt(sb)->files[type];
6913 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
6914 int offset = off & (sb->s_blocksize - 1);
6915 int tocopy;
6916 size_t toread;
6917 struct buffer_head *bh;
6918 loff_t i_size = i_size_read(inode);
6919
6920 if (off > i_size)
6921 return 0;
6922 if (off+len > i_size)
6923 len = i_size-off;
6924 toread = len;
6925 while (toread > 0) {
> 6926 tocopy = min(sb->s_blocksize - offset, toread);
6927 bh = ext4_bread(NULL, inode, blk, 0);
6928 if (IS_ERR(bh))
6929 return PTR_ERR(bh);
6930 if (!bh) /* A hole? */
6931 memset(data, 0, tocopy);
6932 else
6933 memcpy(data, bh->b_data+offset, tocopy);
6934 brelse(bh);
6935 offset = 0;
6936 toread -= tocopy;
6937 data += tocopy;
6938 blk++;
6939 }
6940 return len;
6941 }
6942
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-18 22:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-16 9:10 [PATCH] ext4: use min() to make code cleaner cgel.zte
2021-12-17 2:11 ` kernel test robot
2021-12-18 22:31 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox