[bvanassche:configfs 6/6] fs/configfs/file.c:289:57: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int')

From: kernel test robot
Date: Fri Jul 23 2021 - 08:14:00 EST


tree: https://github.com/bvanassche/linux configfs
head: 7e2353f58cd57892a51ad80a600b481b22ef775a
commit: 7e2353f58cd57892a51ad80a600b481b22ef775a [6/6] wip2
config: mips-randconfig-r013-20210723 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9625ca5b602616b2f5584e8a49ba93c52c141e40)
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
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/bvanassche/linux/commit/7e2353f58cd57892a51ad80a600b481b22ef775a
git remote add bvanassche https://github.com/bvanassche/linux
git fetch --no-tags bvanassche configfs
git checkout 7e2353f58cd57892a51ad80a600b481b22ef775a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips

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

All warnings (new ones prefixed by >>):

>> fs/configfs/file.c:289:57: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
pr_info("%s: end_offset = %ld; len = %ld\n", __func__, end_offset, len);
~~~ ^~~~~~~~~~
%u
include/linux/printk.h:420:34: note: expanded from macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
>> fs/configfs/file.c:289:69: warning: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Wformat]
pr_info("%s: end_offset = %ld; len = %ld\n", __func__, end_offset, len);
~~~ ^~~
%d
include/linux/printk.h:420:34: note: expanded from macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
2 warnings generated.


vim +289 fs/configfs/file.c

240
241 static ssize_t configfs_bin_write_iter(struct kiocb *iocb,
242 struct iov_iter *from)
243 {
244 struct file *file = iocb->ki_filp;
245 struct configfs_buffer *buffer = file->private_data;
246 void *tbuf = NULL;
247 size_t end_offset;
248 ssize_t len;
249
250 mutex_lock(&buffer->mutex);
251
252 /* we don't support switching read/write modes */
253 if (buffer->read_in_progress) {
254 len = -ETXTBSY;
255 goto out;
256 }
257 buffer->write_in_progress = true;
258
259 /* buffer grows? */
260 end_offset = iocb->ki_pos + iov_iter_count(from);
261 if (end_offset > buffer->bin_buffer_size) {
262 if (buffer->cb_max_size && end_offset > buffer->cb_max_size) {
263 len = -EFBIG;
264 goto out;
265 }
266
267 tbuf = vmalloc(end_offset);
268 if (tbuf == NULL) {
269 len = -ENOMEM;
270 goto out;
271 }
272
273 /* copy old contents */
274 if (buffer->bin_buffer) {
275 memcpy(tbuf, buffer->bin_buffer,
276 buffer->bin_buffer_size);
277 vfree(buffer->bin_buffer);
278 }
279
280 /* clear the new area */
281 memset(tbuf + buffer->bin_buffer_size, 0,
282 end_offset - buffer->bin_buffer_size);
283 buffer->bin_buffer = tbuf;
284 buffer->bin_buffer_size = end_offset;
285 }
286
287 len = copy_from_iter(buffer->bin_buffer + iocb->ki_pos,
288 buffer->bin_buffer_size - iocb->ki_pos, from);
> 289 pr_info("%s: end_offset = %ld; len = %ld\n", __func__, end_offset, len);
290 iocb->ki_pos += len;
291 out:
292 mutex_unlock(&buffer->mutex);
293 return len ? : -EFAULT;
294 }
295

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

Attachment: .config.gz
Description: application/gzip