This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8c4051b0340f1e2aadd0155d93913043167358c7 Author: zhangyuan29 <[email protected]> AuthorDate: Fri May 8 20:23:14 2026 +0800 net/arp: Avoid sizeof on an array element in arp_update. The Tasking compiler reports "W515: side effects of 'sizeof' operand are ignored" for sizeof(g_arptable[i]). Use sizeof(struct arp_entry_s) in arp_update(), and in ipt_sockopt.c compute the table count once in an enum instead of calling nitems() in the loop condition. Signed-off-by: Zhang Yuan <[email protected]> --- net/arp/arp_table.c | 2 +- net/netfilter/ipt_sockopt.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/net/arp/arp_table.c b/net/arp/arp_table.c index 3e2938b7993..e26dbd0ac50 100644 --- a/net/arp/arp_table.c +++ b/net/arp/arp_table.c @@ -621,7 +621,7 @@ void arp_cleanup(FAR struct net_driver_s *dev) iob_free_queue(&g_arptable[i].at_queue); #endif - memset(&g_arptable[i], 0, sizeof(g_arptable[i])); + memset(&g_arptable[i], 0, sizeof(struct arp_entry_s)); } } } diff --git a/net/netfilter/ipt_sockopt.c b/net/netfilter/ipt_sockopt.c index d02e5dfbb36..108011927f3 100644 --- a/net/netfilter/ipt_sockopt.c +++ b/net/netfilter/ipt_sockopt.c @@ -89,6 +89,11 @@ static struct ipt_table_s g_tables[] = #endif }; +enum +{ + IPT_NTABLES = nitems(g_tables) +}; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -120,7 +125,8 @@ static void ipt_table_init(FAR struct ipt_table_s *table) static FAR struct ipt_table_s *ipt_table(FAR const char *name) { int i; - for (i = 0; i < nitems(g_tables); i++) + + for (i = 0; i < IPT_NTABLES; i++) { ipt_table_init(&g_tables[i]); if (g_tables[i].repl != NULL && @@ -144,6 +150,7 @@ static FAR struct ipt_table_s *ipt_table(FAR const char *name) static FAR struct ipt_replace *ipt_table_repl(FAR const char *name) { FAR struct ipt_table_s *table = ipt_table(name); + if (table) { return table->repl;
