linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] workqueue: fix -Wformat-truncation in create_worker
@ 2023-10-09 17:09 Lucy Mielke
  2023-10-12 19:53 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Lucy Mielke @ 2023-10-09 17:09 UTC (permalink / raw)
  To: tj, jiangshanlai; +Cc: linux-kernel

Compiling with W=1 emitted the following warning
(Compiler: gcc (x86-64, ver. 13.2.1, .config: result of make allyesconfig,
"Treat warnings as errors" turned off):

kernel/workqueue.c:2188:54: warning: ‘%d’ directive output may be
	truncated writing between 1 and 10 bytes into a region of size
	between 5 and 14 [-Wformat-truncation=]
kernel/workqueue.c:2188:50: note: directive argument in the range
	[0, 2147483647]
kernel/workqueue.c:2188:17: note: ‘snprintf’ output between 4 and 23 bytes
	into a destination of size 16

setting "id_buf" to size 23 will silence the warning, since GCC
determines snprintf's output to be max. 23 bytes in line 2188.

Please let me know if there are any mistakes in my patch!

Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ebe24a5e1435..d14fddd76f49 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2166,7 +2166,7 @@ static struct worker *create_worker(struct worker_pool *pool)
 {
 	struct worker *worker;
 	int id;
-	char id_buf[16];
+	char id_buf[23];
 
 	/* ID is needed to determine kthread name */
 	id = ida_alloc(&pool->worker_ida, GFP_KERNEL);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] workqueue: fix -Wformat-truncation in create_worker
  2023-10-09 17:09 [PATCH] workqueue: fix -Wformat-truncation in create_worker Lucy Mielke
@ 2023-10-12 19:53 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2023-10-12 19:53 UTC (permalink / raw)
  To: Lucy Mielke; +Cc: jiangshanlai, linux-kernel

On Mon, Oct 09, 2023 at 07:09:46PM +0200, Lucy Mielke wrote:
> Compiling with W=1 emitted the following warning
> (Compiler: gcc (x86-64, ver. 13.2.1, .config: result of make allyesconfig,
> "Treat warnings as errors" turned off):
> 
> kernel/workqueue.c:2188:54: warning: ‘%d’ directive output may be
> 	truncated writing between 1 and 10 bytes into a region of size
> 	between 5 and 14 [-Wformat-truncation=]
> kernel/workqueue.c:2188:50: note: directive argument in the range
> 	[0, 2147483647]
> kernel/workqueue.c:2188:17: note: ‘snprintf’ output between 4 and 23 bytes
> 	into a destination of size 16
> 
> setting "id_buf" to size 23 will silence the warning, since GCC
> determines snprintf's output to be max. 23 bytes in line 2188.
> 
> Please let me know if there are any mistakes in my patch!
> 
> Signed-off-by: Lucy Mielke <lucymielke@icloud.com>

Applied to wq/for-6.6-fixes.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-12 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-09 17:09 [PATCH] workqueue: fix -Wformat-truncation in create_worker Lucy Mielke
2023-10-12 19:53 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).