From: Joseph Sutton Date: Sun, 26 Nov 2023 23:58:05 +0000 (+1300) Subject: pidl: Make sure to cast whole expressions X-Git-Tag: talloc-2.4.2~471 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3f81fa71ee08f78b43f5b1817eb44d1c59bd40e;p=thirdparty%2Fsamba.git pidl: Make sure to cast whole expressions $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 --- 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") {