From 50bd7f0f89374ddc096e70e3d6e6b4486061d5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=82=A3=E5=87=A0?= <2078634206@qq.com> Date: Sat, 22 Aug 2026 01:00:23 +0800 Subject: [PATCH] tkernel: netatop: fix W=1 warnings and add SPDX identifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building kernel/tkernel/netatop/ with W=1 reports eight -Wold-style-definition warnings: six garbage collector and cleanup helpers plus init_module()/cleanup_module() define their parameter list as () while the forward declarations in the same file already use (void). Replace the eight definitions with (void) parameter lists, convert the strncpy() in gettaskinfo() to strscpy() to drop the -Wstringop-truncation pattern, and add SPDX license identifiers to netatop.c, netatop.h and netatopversion.h. Upstream status: downstream-only Signed-off-by: 陈那几 <2078634206@qq.com> --- kernel/tkernel/netatop/netatop.c | 20 +++++++++++--------- kernel/tkernel/netatop/netatop.h | 1 + kernel/tkernel/netatop/netatopversion.h | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel/tkernel/netatop/netatop.c b/kernel/tkernel/netatop/netatop.c index db88ea947466..1221b96f1327 100644 --- a/kernel/tkernel/netatop/netatop.c +++ b/kernel/tkernel/netatop/netatop.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* ** This module uses the netfilter interface to maintain statistics ** about the network traffic per task, on level of thread group @@ -81,6 +82,7 @@ ** it under the terms of the GNU General Public License version 2 as ** published by the Free Software Foundation. */ + #include #include #include @@ -970,7 +972,7 @@ get_taskinfo(pid_t id, char type) tip->btime++; #endif - strncpy(tip->command, current->comm, COMLEN); + strscpy(tip->command, current->comm, sizeof(tip->command)); return tip; } @@ -1014,7 +1016,7 @@ garbage_collector(void) ** can be found at the head */ static void -gctaskexit() +gctaskexit(void) { unsigned long flags; struct taskinfo *tip; @@ -1048,7 +1050,7 @@ gctaskexit() ** cleanup sockinfo structures that are connected to finished processes */ static void -gcsockinfo() +gcsockinfo(void) { int i; struct sockinfo *sip, *sipsave; @@ -1258,7 +1260,7 @@ gcsockinfo() ** remove taskinfo structures of finished tasks from hash list */ static void -gctaskinfo() +gctaskinfo(void) { int i; struct taskinfo *tip, *tipsave; @@ -1331,7 +1333,7 @@ gctaskinfo() ** remove all sockinfo structs */ static void -wipesockinfo() +wipesockinfo(void) { struct sockinfo *sip, *sipsave; int i; @@ -1359,7 +1361,7 @@ wipesockinfo() ** remove all taskinfo structs from hash list */ static void -wipetaskinfo() +wipetaskinfo(void) { struct taskinfo *tip, *tipsave; int i; @@ -1387,7 +1389,7 @@ wipetaskinfo() ** remove all taskinfo structs from exit list */ static void -wipetaskexit() +wipetaskexit(void) { gctaskexit(); } @@ -1674,7 +1676,7 @@ static int netatop_thread(void *dummy) ** called when module loaded */ int -init_module() +init_module(void) { int i; @@ -1765,7 +1767,7 @@ init_module() ** called when module unloaded */ void -cleanup_module() +cleanup_module(void) { /* ** tell kernel daemon to stop diff --git a/kernel/tkernel/netatop/netatop.h b/kernel/tkernel/netatop/netatop.h index a14e6fa5db52..6f0c66ab67de 100644 --- a/kernel/tkernel/netatop/netatop.h +++ b/kernel/tkernel/netatop/netatop.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #define COMLEN 16 struct taskcount { diff --git a/kernel/tkernel/netatop/netatopversion.h b/kernel/tkernel/netatop/netatopversion.h index 593dc6a65769..5000858fbbd5 100644 --- a/kernel/tkernel/netatop/netatopversion.h +++ b/kernel/tkernel/netatop/netatopversion.h @@ -1,2 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #define NETATOPVERSION "0.7" #define NETATOPDATE "2015/10/09 14:26:52" -- Gitee