format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’
size_t型の変数のフォーマットは%zdに統一することが望ましい
Full log
$ make
make -C /usr/src/linux-headers-`uname -r` M=`pwd` V=0 modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-1052-raspi2'
CC [M] /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.o
In file included from ./include/linux/printk.h:7:0,
from ./include/linux/kernel.h:14,
from ./include/linux/list.h:9,
from ./include/linux/kobject.h:20,
from ./include/linux/cdev.h:5,
from /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:25:
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c: In function ‘sw_read’:
./include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
./include/linux/kern_levels.h:14:19: note: in expansion of macro ‘KERN_SOH’
#define KERN_INFO KERN_SOH "6" /* informational */
^~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:586:10: note: in expansion of macro ‘KERN_INFO’
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
^~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:586:48: note: format string is defined here
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
~^
%ld
In file included from ./include/linux/printk.h:7:0,
from ./include/linux/kernel.h:14,
from ./include/linux/list.h:9,
from ./include/linux/kobject.h:20,
from ./include/linux/cdev.h:5,
from /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:25:
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c: In function ‘sensor_read’:
./include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
./include/linux/kern_levels.h:14:19: note: in expansion of macro ‘KERN_SOH’
#define KERN_INFO KERN_SOH "6" /* informational */
^~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:657:10: note: in expansion of macro ‘KERN_INFO’
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
^~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:657:48: note: format string is defined here
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
~^
%ld
In file included from ./include/linux/printk.h:7:0,
from ./include/linux/kernel.h:14,
from ./include/linux/list.h:9,
from ./include/linux/kobject.h:20,
from ./include/linux/cdev.h:5,
from /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:25:
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c: In function ‘rtcnt_read’:
./include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
./include/linux/kern_levels.h:14:19: note: in expansion of macro ‘KERN_SOH’
#define KERN_INFO KERN_SOH "6" /* informational */
^~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1188:10: note: in expansion of macro ‘KERN_INFO’
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
^~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1188:48: note: format string is defined here
printk(KERN_INFO "err sample_char_read size(%d)\n", count);
~^
%ld
Building modules, stage 2.
MODPOST 1 modules
CC /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.mod.o
LD [M] /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-1052-raspi2'
Describe the bug
rtmouse.c
をビルドするとフォーマットに関して以下の警告が出ているsize_t
型の変数のフォーマットは%zd
に統一することが望ましいFull log