|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [PATCH] tools/libxc: Drop copy-in in xc_physinfo()
Hi Andrew,
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of
> Andrew Cooper
> Sent: 2021年12月24日 0:23
> To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>; Anthony PERARD
> <anthony.perard@xxxxxxxxxx>; Juergen Gross <jgross@xxxxxxxx>
> Subject: [PATCH] tools/libxc: Drop copy-in in xc_physinfo()
>
> 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 pointless zeroing from the
> remaining callers.
>
> Spotted by Coverity.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> CC: Juergen Gross <jgross@xxxxxxxx>
> ---
> tools/libs/ctrl/xc_misc.c | 2 --
> tools/libs/light/libxl.c | 2 +-
> tools/libs/stat/xenstat.c | 2 +-
> tools/misc/xenpm.c | 2 +-
> tools/xenmon/xenbaked.c | 2 +-
> tools/xentrace/xentrace.c | 2 +-
> 6 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/tools/libs/ctrl/xc_misc.c b/tools/libs/ctrl/xc_misc.c
> index 3820394413a9..265f15ec2da3 100644
> --- a/tools/libs/ctrl/xc_misc.c
> +++ b/tools/libs/ctrl/xc_misc.c
> @@ -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;
>
> diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c
> index a77aa856fdd6..667ae6409be7 100644
> --- a/tools/libs/light/libxl.c
> +++ b/tools/libs/light/libxl.c
> @@ -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);
> diff --git a/tools/libs/stat/xenstat.c b/tools/libs/stat/xenstat.c
> index e49689aa2da9..8bab2e66a7fe 100644
> --- a/tools/libs/stat/xenstat.c
> +++ b/tools/libs/stat/xenstat.c
> @@ -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;
> diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
> index d0191d498484..4f8cde690a7c 100644
> --- a/tools/misc/xenpm.c
> +++ b/tools/misc/xenpm.c
> @@ -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)];
>
> diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
> index 1ed34334c824..7591de7c609f 100644
> --- a/tools/xenmon/xenbaked.c
> +++ b/tools/xenmon/xenbaked.c
> @@ -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;
>
> diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
> index a8903ebf4625..864e30d50cc3 100644
> --- a/tools/xentrace/xentrace.c
> +++ b/tools/xentrace/xentrace.c
> @@ -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);
> --
> 2.11.0
>
Reviewed-by: Wei Chen <Wei.Chen@xxxxxxx>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |