From nobody Fri Oct 3 06:37:17 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C20462DF6E9; Thu, 4 Sep 2025 22:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757023411; cv=none; b=QUbWfzaistSAnqxsfalBKdVJZjf1pC6r1ZOHv3OCyRYewwFRtq9ytuPNuDLzWZLXgtV+x0nGcoyS3xP+dlHc6fRQh+7lupNI0oCYOYnJE663xgWRpYOnm0WcSwvKwysutx6fShLoyfUjupmdtbMmIcYSK6EMFNBkNmvFSUvqt60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757023411; c=relaxed/simple; bh=kfNKsp1FHappfXlSa3oCQen0sULVOEgKmZ5WZwpdTBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HIuFe/hNkAy44WnPSPO7OY8VIZe7JjTYNd0d+RLZwEqgqCKqxtJBkegN6jlT3yJCD/Z/R0RuRDQRxugEE+EwqGx4tYGpBmNJ4xdteDjObA1je1sccdV6alNPEKNGDKINy6w491IsVH6bt8pS0PARYo6Hy39SJQbNSAmSv6w5DVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=HhCs/zKf; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="HhCs/zKf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1757023398; bh=kfNKsp1FHappfXlSa3oCQen0sULVOEgKmZ5WZwpdTBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HhCs/zKfXQtb+hq+pa99bB1PTkRLkiO84V9dq15EmSJ/7PDXYqePkTS4Kxe7A4Kui /Ggma/1U5k+fZeVj03VOXSNzULLuzFfQqFdgO+L/SrRKHoH0fWcOf9RQD42wvHKm41 sxWwZHSzWSB/0haGq/bShUKKUkDomWGs9AoILzyYGYTQjOkQBM6Mrf4DRRMOAVyxNc gSMZ8HXgUPFLkk2fJDMGOwOts+xB0+sRyvPpTlhLHVMYGulzk5BflSFjoIrr+oq9JO 7j7R61lMNpbvNCi1roX5TtWlYHYqobDzTTEf/vO1mx9dCz/+6ZSTqmU0JYTB8P7/4p 9QtGcAAlyHj9w== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 9485860142; Thu, 4 Sep 2025 22:03:18 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id B168C2024AB; Thu, 04 Sep 2025 22:02:09 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 05/11] tools: ynl-gen: define nlattr *array in a block scope Date: Thu, 4 Sep 2025 22:01:28 +0000 Message-ID: <20250904220156.1006541-5-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250904-wg-ynl-prep@fiberby.net> References: <20250904-wg-ynl-prep@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Instead of trying to define "struct nlattr *array;" in the all the right places, then simply define it in a block scope, as it's only used here. Before this patch it was generated for attribute set _put() functions, like wireguard_wgpeer_put(), but missing and caused a compile error for the command function wireguard_set_device(). $ make -C tools/net/ynl/generated wireguard-user.o -e CC wireguard-user.o wireguard-user.c: In function =E2=80=98wireguard_set_device=E2=80=99: wireguard-user.c:548:9: error: =E2=80=98array=E2=80=99 undeclared (first us= e in ..) 548 | array =3D ynl_attr_nest_start(nlh, WGDEVICE_A_PEERS); | ^~~~~ Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen Reviewed-by: Donald Hunter --- tools/net/ynl/pyynl/ynl_gen_c.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen= _c.py index b0eeedfca2f2..e6a84e13ec0a 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -842,6 +842,9 @@ class TypeArrayNest(Type): return get_lines, None, local_vars =20 def attr_put(self, ri, var): + ri.cw.block_start() + ri.cw.p('struct nlattr *array;') + ri.cw.nl() ri.cw.p(f'array =3D ynl_attr_nest_start(nlh, {self.enum_name});') if self.sub_type in scalars: put_type =3D self.sub_type @@ -857,6 +860,7 @@ class TypeArrayNest(Type): else: raise Exception(f"Put for ArrayNest sub-type {self.attr['sub-t= ype']} not supported, yet") ri.cw.p('ynl_attr_nest_end(nlh, array);') + ri.cw.block_end() =20 def _setter_lines(self, ri, member, presence): return [f"{member} =3D {self.c_name};", @@ -2063,13 +2067,9 @@ def put_req_nested(ri, struct): init_lines.append(f"hdr =3D ynl_nlmsg_put_extra_header(nlh, {struc= t_sz});") init_lines.append(f"memcpy(hdr, &obj->_hdr, {struct_sz});") =20 - has_anest =3D False has_count =3D False for _, arg in struct.member_list(): - has_anest |=3D arg.type =3D=3D 'indexed-array' has_count |=3D arg.presence_type() =3D=3D 'count' - if has_anest: - local_vars.append('struct nlattr *array;') if has_count: local_vars.append('unsigned int i;') =20 --=20 2.51.0