From: Daniel P. Berrangé Date: Thu, 22 Dec 2022 15:42:20 +0000 (-0500) Subject: rpc: use struct zero initializer instead of memset X-Git-Tag: v9.1.0-rc1~250 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c656836e37de88163f24924061556cde9e2d712;p=thirdparty%2Flibvirt.git rpc: use struct zero initializer instead of memset This is a more concise approach and guarantees there is no time window where the struct is uninitialized. Reviewed-by: Ján Tomko Signed-off-by: Daniel P. Berrangé --- diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 63d2411474..e9dc8e27d7 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1534,7 +1534,7 @@ elsif ($mode eq "client") { if ($rettype eq "void") { $call_ret = "NULL"; } else { - push(@vars_list, "$rettype ret"); + push(@vars_list, "$rettype ret = {0}"); foreach my $ret_member (@{$call->{ret_members}}) { if ($multi_ret) { @@ -1891,11 +1891,6 @@ elsif ($mode eq "client") { print "\n"; } - if ($rettype ne "void") { - print "\n"; - print " memset(&ret, 0, sizeof(ret));\n"; - } - my $callflags = "0"; if ($structprefix eq "qemu") { $callflags = "REMOTE_CALL_QEMU";