For an allmodconfig build, I currently get this error when building with
W=1:
$ make W=1 drivers/md/dm-vdo/vdo.o
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC [M] drivers/md/dm-vdo/vdo.o
drivers/md/dm-vdo/vdo.c: In function ‘vdo_make’:
drivers/md/dm-vdo/vdo.c:564:5: error: ‘%s’ directive output may be truncated
writing up to 55 bytes into a region of size 16 [-Werror=format-truncation=]
"%s%u", MODULE_NAME, instance);
^~
drivers/md/dm-vdo/vdo.c:563:2: note: ‘snprintf’ output between 2 and 66 bytes
into a destination of size 16
snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s%u", MODULE_NAME, instance);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix by defining MAX_VDO_WORK_QUEUE_NAME_LEN to be sum of MODULE_NAME_LEN
plus 11 - 11 comes from number of characters required to print max unsigned
int plus NUL terminator.
Also relocate the include of sched.h to the only c file which it is
actually needed.
Signed-off-by: John Garry <[email protected]>
diff --git a/drivers/md/dm-vdo/funnel-workqueue.c
b/drivers/md/dm-vdo/funnel-workqueue.c
index ae11941c90a9..7e42342263ab 100644
--- a/drivers/md/dm-vdo/funnel-workqueue.c
+++ b/drivers/md/dm-vdo/funnel-workqueue.c
@@ -11,6 +11,7 @@
#include <linux/err.h>
#include <linux/kthread.h>
#include <linux/percpu.h>
+#include <linux/sched.h>
#include "funnel-queue.h"
#include "logger.h"
diff --git a/drivers/md/dm-vdo/funnel-workqueue.h
b/drivers/md/dm-vdo/funnel-workqueue.h
index b5be6e9e83bc..3447aac5b188 100644
--- a/drivers/md/dm-vdo/funnel-workqueue.h
+++ b/drivers/md/dm-vdo/funnel-workqueue.h
@@ -6,12 +6,10 @@
#ifndef VDO_WORK_QUEUE_H
#define VDO_WORK_QUEUE_H
-#include <linux/sched.h> /* for TASK_COMM_LEN */
-
#include "types.h"
enum {
- MAX_VDO_WORK_QUEUE_NAME_LEN = TASK_COMM_LEN,
+ MAX_VDO_WORK_QUEUE_NAME_LEN = MODULE_NAME_LEN + 11,
};
struct vdo_work_queue_type {
--
2.31.1