tools/libxc: Drop copy-in in xc_physinfo()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 23 Dec 2021 16:10:15 +0000 (16:10 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 5 Jan 2022 09:44:26 +0000 (09:44 +0000)
The first thing XEN_SYSCTL_physinfo does is zero op->u.physinfo.

Do not copy-in.  It's pointless, and most callers don't initialise their
xc_physinfo_t buffer to begin with.  Remove the redundant zeroing from the
remaining callers.

Spotted by Coverity.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Chen <Wei.Chen@arm.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
tools/libs/ctrl/xc_misc.c
tools/libs/light/libxl.c
tools/libs/stat/xenstat.c
tools/misc/xenpm.c
tools/xenmon/xenbaked.c
tools/xentrace/xentrace.c

index 3820394413a985d03fcd25e0ed012bcfc41d360a..265f15ec2da344e948cbbe532d6d456a09accfc0 100644 (file)
@@ -195,8 +195,6 @@ int xc_physinfo(xc_interface *xch,
 
     sysctl.cmd = XEN_SYSCTL_physinfo;
 
-    memcpy(&sysctl.u.physinfo, put_info, sizeof(*put_info));
-
     if ( (ret = do_sysctl(xch, &sysctl)) != 0 )
         return ret;
 
index a77aa856fdd6f0fc48f5e19037eef20de8dc0382..667ae6409be73b8bbe6d16ce5213c62a1796eedd 100644 (file)
@@ -351,7 +351,7 @@ const char *libxl_defbool_to_string(libxl_defbool b)
 /******************************************************************************/
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
 {
-    xc_physinfo_t xcphysinfo = { 0 };
+    xc_physinfo_t xcphysinfo;
     int rc;
     long l;
     GC_INIT(ctx);
index e49689aa2da94b3eba3a3aede8e71d72f8c0fc72..8bab2e66a7fe53a6ca80fa5f89afe6f282e9a099 100644 (file)
@@ -135,7 +135,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
 {
 #define DOMAIN_CHUNK_SIZE 256
        xenstat_node *node;
-       xc_physinfo_t physinfo = { 0 };
+       xc_physinfo_t physinfo;
        xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE];
        int new_domains;
        unsigned int i;
index d0191d498484cf664ba704d7d1f43c4503d4f8ac..4f8cde690a7c77f4465fd0815c901b4232240419 100644 (file)
@@ -1244,7 +1244,7 @@ struct {
 int main(int argc, char *argv[])
 {
     int i, ret = 0;
-    xc_physinfo_t physinfo = { 0 };
+    xc_physinfo_t physinfo;
     int nr_matches = 0;
     int matches_main_options[ARRAY_SIZE(main_options)];
 
index 1ed34334c8247ce326db33874b27f0d6c74378d4..7591de7c609fd0ceb23097770dc666536f7df3ec 100644 (file)
@@ -436,7 +436,7 @@ static struct t_struct *map_tbufs(unsigned long tbufs_mfn, unsigned int num,
  */
 static unsigned int get_num_cpus(void)
 {
-    xc_physinfo_t physinfo = { 0 };
+    xc_physinfo_t physinfo;
     xc_interface *xc_handle = xc_interface_open(0,0,0);
     int ret;
 
index a8903ebf4625efb73e59818de4fb83ef3e55ce71..864e30d50cc3ef52a3f889e2edc6ac724774903c 100644 (file)
@@ -589,7 +589,7 @@ static void set_evt_mask(uint32_t mask)
  */
 static unsigned int get_num_cpus(void)
 {
-    xc_physinfo_t physinfo = { 0 };
+    xc_physinfo_t physinfo;
     int ret;
     
     ret = xc_physinfo(xc_handle, &physinfo);