From patchwork Fri Dec 6 10:30:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13896938 X-Patchwork-Delegate: kuba@kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 2E8AB20102F for ; Fri, 6 Dec 2024 10:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481068; cv=none; b=gWPUcBrK4Gs0jizCA2YymewlxvK3Ojku9y0PnS2IczMfGFCuSbEA9AXKxdbQtaFNGsP6PXJoVDITJDOBuhL+98YQI/HKEAe8tTVEK7Vthnoe+gpB6G7U/v3Y/zKHr26L62vRx6DeC6c4U+4ky2eOF5bwIXqQnP+bFPTW2Q+XTXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481068; c=relaxed/simple; bh=wC6a+ChsD6IhVMWBVHRpM0RPp5o9ufethiV6stIsLCk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cqHaSDmQMsPhEuu+DfcatIzsJuVdsaVdvI5u/2w9ht7EntyWsy6YqvAtxT23groMcgZbQ5j71MFt00hdLh0LKCTr/+OCeqpC7zzyIiVHRI+31qIu5pR0Qdq5JxW3ckRSQVjw/6LEdkv7Y7tHghoDjaYk1EKsMFYGvADnVYKBAZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=M43cOeYo; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="M43cOeYo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=feueyYy5EHoo9KUpy5AJh3SGdxqLmt4BKls8dt9mphM=; t=1733481067; x=1734690667; b=M43cOeYodb5irHesB/Fem6QoUPdHs2mfXTx6q3SuM0I60DW/K7zBFIiqw7Hdlw6GsExmdyzO9kd mrvGQN9V7MLMB88k14DqvRrXNQLgRrRA4tLTTVUwR2+2mPANDqQtmcl8RyUN7bBVRvWLHgmuKgMMF P7sYfjaM+yKuhGu3hSJeo1Pu80xDx5yxpdWT2j/IbpuFaBUH9XxkgNViaLJim5vlVHqbgZiTUBvlA A7tq2m6Ow+AByJGCmPfiL9qyqgUpT7oVL2uif7CD7RelhXVr3FGosBe57SYnLKU2jwsUsvT9BsVMf d3fIg/nhfxWTb/odw5OTboN8/8Gl3Y+S/nLg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98) (envelope-from ) id 1tJVbz-0000000FWya-2aCr; Fri, 06 Dec 2024 11:31:04 +0100 From: Johannes Berg To: netdev@vger.kernel.org Cc: Johannes Berg Subject: [PATCH net-next 1/2] tools: ynl-gen-c: annotate valid choices for --mode Date: Fri, 6 Dec 2024 11:30:56 +0100 Message-ID: <20241206113100.e2ab5cf6937c.Ie149a0ca5df713860964b44fe9d9ae547f2e1553@changeid> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Johannes Berg This makes argparse validate the input and helps users understand which modes are possible. Signed-off-by: Johannes Berg --- tools/net/ynl/ynl-gen-c.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index d8201c4b1520..50ec03056863 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -2635,7 +2635,8 @@ def find_kernel_root(full_path): def main(): parser = argparse.ArgumentParser(description='Netlink simple parsing generator') - parser.add_argument('--mode', dest='mode', type=str, required=True) + parser.add_argument('--mode', dest='mode', type=str, required=True, + choices=('user', 'kernel', 'uapi')) parser.add_argument('--spec', dest='spec', type=str, required=True) parser.add_argument('--header', dest='header', action='store_true', default=None) parser.add_argument('--source', dest='header', action='store_false') From patchwork Fri Dec 6 10:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13896939 X-Patchwork-Delegate: kuba@kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 7E27320101D for ; Fri, 6 Dec 2024 10:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481069; cv=none; b=pyyI/Kj2JKmV0ZcV9QHjglDTgp8I5rQ1mazwF60jtb5nl0EMElXo1NjTlKH4pEc2vkOqPsabyV3QMycp/JtKCnrZST8mH4hd+gp+RU7IrRSCCCiU/a349Gcqyp0nirKpDdE3EkMx+5hsUmDrNhFWf563mVZXR3bIukaYhr5nEeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481069; c=relaxed/simple; bh=5wHuSkoTKs2fs8huMIMitY6ncKHaYkO7sSm8q+QCNJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAbJ5ffJfVldpaf0rdyl5yE0EgmgqOzAwaECl33xkLZqaQ/2EvtFCv0rFfM/EthdqHiuJV5HzLIiZ3C5GdGDINzYFxKsytPQf3KeKTrtFAOM5Fas2HLUEs1Agi/+WfN2oLHlwpriy5irNt1ocTIvdhFypLVN5hQDre0Jgbx5oBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=rmRrZUOW; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="rmRrZUOW" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=DOywnkMYG+BOUZIFGmHoIM9+SasyqyM3GklWGnWOV4w=; t=1733481067; x=1734690667; b=rmRrZUOWzc6jbY0//sPdVWJYXrw4uSkxLItvVqiaXtjgPLw +zNcl+lzDguIEz8meITudYq3gWNl2LNRlOCN4UBjQOKvQ3xf5k5yZYMw+/Di1pVs2xFiamzaFdb78 9I3WqzHhTWfLYRYKSIsmDT05cFj0/VkLkse0Xz10xb+/1GAoU5bSA9GYEL3aRi1KjWe0eDUSncjfp Cibdfia4YxWbQWY/hfl5sx4dCZwcB0x9xfk303AP4m4JZ69pbqCbySMEymhcJVySDL3wH/U4NI5FD hrPacxJCA2Y/wfcJi3n5td/pdhlVtqsIWzcKSKGa86LgNFPryyWrawXldQg/a1Wg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98) (envelope-from ) id 1tJVc0-0000000FWya-2RZN; Fri, 06 Dec 2024 11:31:04 +0100 From: Johannes Berg To: netdev@vger.kernel.org Cc: Johannes Berg Subject: [PATCH net-next 2/2] tools: ynl-gen-c: don't require -o argument Date: Fri, 6 Dec 2024 11:30:57 +0100 Message-ID: <20241206113100.89d35bf124d6.I9228fb704e6d5c9d8e046ef15025a47a48439c1e@changeid> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206113100.e2ab5cf6937c.Ie149a0ca5df713860964b44fe9d9ae547f2e1553@changeid> References: <20241206113100.e2ab5cf6937c.Ie149a0ca5df713860964b44fe9d9ae547f2e1553@changeid> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Johannes Berg Without -o the tool currently crashes, but it's not marked as required. The only thing we can't do without it is to generate the correct #include for user source files, but we can put a placeholder instead. Signed-off-by: Johannes Berg --- tools/net/ynl/ynl-gen-c.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 50ec03056863..5df3370bfc74 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -2697,7 +2697,10 @@ def main(): cw.p('#define ' + hdr_prot) cw.nl() - hdr_file=os.path.basename(args.out_file[:-2]) + ".h" + if args.out_file: + hdr_file = os.path.basename(args.out_file[:-2]) + ".h" + else: + hdr_file = "generated_header_file.h" if args.mode == 'kernel': cw.p('#include ')