๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26602

Re: [PATCH net-next 02/23] selftests: can: add J1939 test helper header and library

#26602
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 23:12
103 lines
11796 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] j1939_gw.c can fail to build because nothing it includes
  defines static_assert().

--

selftests: can: add J1939 test helper header and library

This commit adds shared code for the upcoming J1939 selftests: C helpers
in j1939_helpers.c/h, kselftest harness glue in j1939_tests.h, and a
j1939_lib.sh runner that sets up vcan interfaces. It also adds a small
j1939_gw tool that installs CAN gateway rules between the J1939 vcan and
the CAN_RAW peer's vcan.

Link: https://patch.msgid.link/20261130-j1939-selftests-v7-2-2491693ccb8d@pengutronix.de

> diff --git a/tools/testing/selftests/net/can/Makefile b/tools/testing/selftests/net/can/Makefile
> index 3adaa13dcbfa3..cf0b06974d546 100644
> --- a/tools/testing/selftests/net/can/Makefile
> +++ b/tools/testing/selftests/net/can/Makefile
> @@ -2,12 +2,16 @@
>  
>  top_srcdir = ../../../../..
>  
> -CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
> +CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include -I$(top_srcdir)/tools/include $(KHDR_INCLUDES)

[ ... ]

> diff --git a/tools/testing/selftests/net/can/j1939_gw.c b/tools/testing/selftests/net/can/j1939_gw.c
> new file mode 100644
> index 0000000000000..4018432add9a2
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/j1939_gw.c

[ ... ]

> +#include <linux/can.h>
> +#include <linux/can/gw.h>
> +#include <linux/kernel.h>
> +#include <linux/netlink.h>
> +#include <linux/rtnetlink.h>
> +
> +/* an RTM_NEWROUTE request for a CAN->CAN rule, see net/can/gw.c */
> +struct cgw_req {

[ ... ]

> +static_assert(offsetof(struct cgw_req, src_attr) ==
> +	      NLMSG_SPACE(sizeof(struct rtcanmsg)),
> +	      "the attributes must follow the aligned rtcanmsg");
> +static_assert(offsetof(struct cgw_req, dst_attr) ==
> +	      offsetof(struct cgw_req, src_attr) + RTA_SPACE(sizeof(__u32)),
> +	      "the attributes must be packed as netlink aligns them");

[Severity: Medium]
Which header defines static_assert for j1939_gw.c?

The only candidate is <linux/kernel.h>, which is presumably meant to
resolve to tools/include/linux/kernel.h. That file pulls in <assert.h>
and <linux/build_bug.h>.

The Makefile puts -I$(top_srcdir)/usr/include ahead of
-I$(top_srcdir)/tools/include. After make headers, which is the usual
step before an in-tree selftest build, usr/include/linux/kernel.h
exists. It is the installed include/uapi/linux/kernel.h, and it only
includes <linux/sysinfo.h> and <linux/const.h>. That means the uAPI
header shadows the tools one.

None of the other headers included here pulls in <assert.h>. GCC 14 and
earlier default to gnu17, where static_assert is not a keyword, so
these two file-scope static_assert() lines fail to compile.

j1939_helpers.h is not affected because it includes <linux/build_bug.h>
directly, and that header has no uAPI counterpart.

j1939_gw is in TEST_GEN_FILES, so a compile failure here also stops the
existing test_raw_filter target from building in net/can. Later patches
in the series do not change this include list or the Makefile include
order.

Could j1939_gw.c include <linux/build_bug.h> or <assert.h> directly?
Moving tools/include ahead of usr/include would also fix it.

> +
> +/* Add a rule from src to dst; return 0 or a negative errno. */
> +static int cgw_add(int nl, unsigned int src, unsigned int dst)

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202230853.2665144-2-mkl%40pengutronix.de
Technical Details
Message-ID: <179633953573.3146.8765255233108616500@kernel.org>
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376897-linux-kernel-netdev=dewy.ru
References: <20261202230853.2665144-3-mkl@pengutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376897-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 02/23] selftests: can: add J1939 test helper header and library
Date: Thu, 03 Dec 2026 23:12:15 +0000
Organization: Usenet Network
Message-ID: <179633953573.3146.8765255233108616500@kernel.org>
References: <20261202230853.2665144-3-mkl@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2624991"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GzBiuPek4SG8I86HBkeTsPDP9wg= sha256:Z8c5w1jiEtulQxlYO6uvoxRHY/YI4x9rknYDlSoAmGA= sha1:mm4/OP35Q7Nf9Bj5ajgO8XGYFcg= sha256:n9jDS+2oag2gXFZ1KGDrJINn+osrvj7Z1DP6lQ5+M3A=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A447B117A60; Fri,  4 Dec 2026 02:12:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F8GDyrBxJplE; Fri,  4 Dec 2026 02:12:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376897-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 74C16117A44; Fri,  4 Dec 2026 02:12:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 17CD12A434; Thu,  3 Dec 2026 23:12:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796339543; b=1HTBc0+2AkTsKbRhyD8WBPHBhKvOWp8hHab5UWZjU3lp8N9F5ODFKabaYNMBMbEbycGB VvQuboMvRa37ZOmvUmW+AHotY37bbbQ4F13XFMEG/cGlbeNKdVjQgLeRTnI48qhv7chaR RYH+NR8Il4zK1GdUnKLpdo+bz1so47KY9ifi85SxbQzNTOQXW25HlAIf0hc2nqr1R68ec YUWdnVb1/xHqxobLsI0izPkxk1doMHRkjBPEAZnnFrJhEzN6+IvalEbeu5K/M2ZP5cc3c KEgORHt1vFI2NJg1oqGZvf3hh1Dk9OLZF+bDjsN8J54++9oDa5hK7YEkQoSQxyBLsBQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339543; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=DRL5Gq5cf7j2cjIGHMeyIRhbV9uJ8NnHLyk4GvCsC+M=; b=rjO466nrbEejlOBO1Q0KogpNUxDhCuR48uOdNFwS2chjeQWEglFbB23egIcjWERXQ19r eHYmoYZlQHI60nspiG4b2BcFCF+VzDvHfSMSoDS5o8txWVbZXPWt0w+Nnfh1lwLC+Ctx/ MEF70ycc2cSC/M4ZhSvP8h5DchVBAPMoYZaa/MGcLPSJAKzstYVBNhfQCUQNZIs9aF72G Ipx5M/IWN7ur1XgEnlCXoFlJYVAmiX4jyZaE3FNfNvv6djqEjOnFy9rH7b3vOWWdNww+b l41skuUeGc0AuHgsXqX5rVY6GKC8VZFi1wnH55k/2yvRPRN3MajqcSn7/opmd5sEytQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QuECTKF1; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2A1A606A32F; Thu,  3 Dec 2026 23:12:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QuECTKF1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796339537; b=EBqCa4R/+fJAle/DAKI6DpTwDOcjcqoFdKOnFGlZkt05xZofWH/L0ZhTcoAVa8g0BAAd 259pNQHvr2APXBLY3goYbGDUm9eE0NfgxVUw5EtXCTuZIc5J0UCwcgFzvC0inqWR6Bwt2 Kvit2zgIzE/waA9fRS936v+lGkWInzTB2mI21uQK7J0lgd3oFyyDpsCpDWXA3k+Iq9VPT txcWAepiqsbZTQTk0N9Fwi20caXJePzasCN4adNqKz2vF98LgduedPEB0Lt/eu/B7XAm9 9P4buuxCx+MTc5Zgx+qDgp2qR+wKofcwhSCX+P6Mx7r/osPfYOoHFTIFOxgP7/wW5VA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339537; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=DRL5Gq5cf7j2cjIGHMeyIRhbV9uJ8NnHLyk4GvCsC+M=; b=uCOZaB0GYBruAnSuKFUJ8DpBzdK1G0ZOtvW69/dZByBdUxDvFmnwgbqbKFV7eZTdZ6X/ 5GbiHpZeiZgPs7ok7RiuoymtvivQAZWTlGFFUizAQHF8uw9bNzNdNapwqXgP/H2OkLda4 fdEnDq11vHnnTRJEp7tza1vPiyMTYWqsJyKiN3YKh/nKnL6SoKLh9K5LT3k8Rq5JAwtc3 DgytIanzRuEet3xjhLC8ffeM60ivf41vquE/p9fmre0siWBNzSWJllXTjp77Q/sl3idg0 ZyK+DiqZWtEwfRsZJkeggZb/q6oKX9XZAZ5hm5OxQvWUeAecTJN2oK040YbSL8qNZIg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QuECTKF1; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E4BB606A322; Thu,  3 Dec 2026 23:12:16 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36AFD1F000C2; Thu,  3 Dec 2026 23:12:16 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796339536; bh=DRL5Gq5cf7j2cjIGHMeyIRhbV9uJ8NnHLyk4GvCsC+M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=QuECTKF1RugZ49Sg7vAdRcGtMVzmN8PlUZTohOduBCuEiYrrhHhhxZrWHzRgp9SIw V6rlMpC33m+YFybHbmkS+zyigkoI2cAXGrfOT1npBRW207Ge58ivhgMaHzo9Z/8KZL 4sFO1JtwXO9HvHAlNsw66ZN2i8x6jEIN3pFVqhIg9M7Niw9ghddpwHP95U2GWurxHs sk6HYinb391dTq57S1KzB+BV0v5jEuJSEqO5wLV7xKNnwruNHxn5LOFQr2R4HYWWbo QTmzvfTsaGGhph6zvtR7Wj5SDcvD6VYQfUROdGkipgdEwIHyXPeV3oY1XjlSZyWlRi zjEducSNCxi+w==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, s.grosjean@peak-system.fr, stable@vger.kernel.org
X-In-Reply-To: <20261202230853.2665144-3-mkl@pengutronix.de>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 11463