From 07e18c18a4984211c20d62e2be1c2b9396af0209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 20 Dec 2022 12:14:07 -0500 Subject: [PATCH] rpcgen: drop type-puning workarounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current RPC code is post-processed to introduce an intermediate variable, rather than casting directly to char ** at time of use. This is said to be a workaround for type-puning warnings that the compiler emitted. Neither GCC or CLang emit any warnings for the code in question today, across any of the architectures we test in CI. Thus it is presumed that somewhere in the 15 years since the workaround was done, the compilers have got smarter and do the right thing. Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrangé --- src/rpc/genprotocol.pl | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 37216303dc..67cf6d4c0b 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -85,29 +85,6 @@ while () { @uses = grep /[^.>]\bi\b/, @function; @function = grep !/[^.>]\bi\b/, @function if @uses == 1; - # (char **)&objp->... gives: - # warning: dereferencing type-punned pointer will break - # strict-aliasing rules - # so rewrite it. - my %uses = (); - my $i = 0; - foreach (@function) { - $uses{$1} = $i++ if m/\(char \*\*\)\&(objp->[a-z_.]+_val)/i; - } - if (keys %uses >= 1) { - my $i = 1; - - foreach (sort(keys %uses)) { - $i = $uses{$_}; - unshift @function, - (" char **objp_cpp$i = (char **) (void *) &$_;\n"); - $i++; - } - @function = - map { s{\(char \*\*\)\&(objp->[a-z_.]+_val)} - {objp_cpp$uses{$1}}gi; $_ } @function; - } - # The code uses 'IXDR_PUT_{U_,}LONG' but it's wrong in two # ways: Firstly these functions are deprecated and don't # work on 64 bit platforms. Secondly the return value should