From e3f81fa71ee08f78b43f5b1817eb44d1c59bd40e Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Mon, 27 Nov 2023 12:58:05 +1300 Subject: [PATCH] pidl: Make sure to cast whole expressions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit $cvar could be an expression such as ‘1 << 10’. In such cases this cast presumably was intended to apply to the entire expression, not just to the ‘1’. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 0472f3b01c8..57f8e8b5638 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -2082,11 +2082,11 @@ sub ConvertScalarToPython($$$$) # possibly 64 bit unsigned long. (enums are signed in C, # unsigned in NDR) if ($ctypename =~ /^(uint32|uint3264)$/) { - return "PyLong_FromUnsignedLongLong((uint32_t)$cvar)"; + return "PyLong_FromUnsignedLongLong((uint32_t)($cvar))"; } if ($ctypename =~ /^(uint|uint8|uint16|uint1632)$/) { - return "PyLong_FromLong((uint16_t)$cvar)"; + return "PyLong_FromLong((uint16_t)($cvar))"; } if ($ctypename eq "DATA_BLOB") { -- 2.47.3