From patchwork Thu Oct 3 18:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821434 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B6D731AB506 for ; Thu, 3 Oct 2024 18:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727981752; cv=none; b=o1aLv21jeYBwIgsUlY49YoajbqOEJ6oS+9SM9CO/YwKoXHB++RP06sOu6T8vQOxXekUM40e6X5RNUa15vvyXk+jhRZCrxjnNjIeYMUfp4WgMTaHUjoV6YefOHhUn9YVbZkSgswOiLPvKL4f2Q+CotUYRKG6Zu0a6sr5F2cCcdZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727981752; c=relaxed/simple; bh=SoSWvT0n8eQFx0vdcmEa/oaMA3v+0uKf/pAk5pq1oZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TYnzGe+2wmbv7U/9H09YQqf711ld498UhJ60IKm3mBTJR5v4fR1/mNEQ/qBkPohQ5lljh0YJg+B6qJo093UXCd7mD0L9v8C/sNG+Ursro5L33sgZeCgEV7J2HPwuk3gswNFZAcGTGIVRJDQiWYzOlfj0Lmpx/tDfnXPSmAczxIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LKewUetz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LKewUetz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DFBBC4CEC5; Thu, 3 Oct 2024 18:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727981751; bh=SoSWvT0n8eQFx0vdcmEa/oaMA3v+0uKf/pAk5pq1oZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKewUetzV702WNuJ9Gn+g7G6Kkf9pJGQif0Ju4ZlcZEo9hCIpiT3fVMCmel7Daadc 9S4OOlaQ+3cwjagfsAIFjAsAuSeuBKM95uT1ZTMWM9jcYGP7ZdyqHs/n08eFaLnWfa U2vJjjq8FWMTTJH/NzPNDuO5xwOxr2vIjq9+xA08TE3Ibd9GKhQIdFsHBunI/616fe qTZ9Oyk9LsYu8kKM0bLX5cjoj9q2nruM7Vw38Bmi1B9Qax85WVRFBtYlUgiVBmo7xR 5QTsoz7fnez9rti9xcZ+SsGkfBZUTm/QCbCb5hF5PN4GjlkUVmHB83VVAac2lOJ0g1 pvZNCTBVe7fVA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v2 04/16] xdrgen: XDR widths for enum types Date: Thu, 3 Oct 2024 14:54:34 -0400 Message-ID: <20241003185446.82984-5-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003185446.82984-1-cel@kernel.org> References: <20241003185446.82984-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever RFC 4506 says that an XDR enum is represented as a signed integer on the wire; thus its width is 1 XDR_UNIT. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index f1d93a1d0ed8..fbee954c7f70 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -227,6 +227,18 @@ class _XdrEnum(_XdrAst): maximum: int enumerators: List[_XdrEnumerator] + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return ["XDR_int"] + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrStruct(_XdrAst):