]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpcgen: drop type-puning workarounds
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 20 Dec 2022 17:14:07 +0000 (12:14 -0500)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 3 Nov 2023 18:06:34 +0000 (14:06 -0400)
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 <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/rpc/genprotocol.pl

index 37216303dc0b85abf82b0cdf18d60211778306b4..67cf6d4c0ba5f4f0f88cef8137a542de67cd25d8 100755 (executable)
@@ -85,29 +85,6 @@ while (<RPCGEN>) {
         @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