Skip to content

Commit

Permalink
tools/libxc: Drop copy-in in xc_physinfo()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Wei Chen <[email protected]>
Acked-by: Anthony PERARD <[email protected]>
  • Loading branch information
andyhhp committed Jan 5, 2022
1 parent af0c543 commit 06cc1f8
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions tools/libs/ctrl/xc_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tools/libs/light/libxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/libs/stat/xenstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/misc/xenpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)];

Expand Down
2 changes: 1 addition & 1 deletion tools/xenmon/xenbaked.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tools/xentrace/xentrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 06cc1f8

Please sign in to comment.