[PATCH v8 5/5] include: Replace BUILD_BUG_ON with static_assert in 'set_task_comm()'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace BUILD_BUG_ON() with static_assert() inside
'set_task_comm()', to benefit from the error message available
with static_assert().

Signed-off-by: Bhupesh <bhupesh@xxxxxxxxxx>
---
 include/linux/sched.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index d26d1dfb9904..2603a674ee22 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1972,7 +1972,8 @@ extern void kick_process(struct task_struct *tsk);
 
 extern void __set_task_comm(struct task_struct *tsk, const char *from, bool exec);
 #define set_task_comm(tsk, from) ({			\
-	BUILD_BUG_ON(sizeof(from) < TASK_COMM_LEN);	\
+	static_assert(sizeof(from) >= TASK_COMM_LEN,	\
+		"tsk->comm size being set should be >= TASK_COMM_LEN");	\
 	__set_task_comm(tsk, from, false);		\
 })
 
-- 
2.38.1





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux