On Mon, 2015-12-28 at 00:16 -0500, Joshua Otto wrote:
> From: Chester Lin <czy...@uwaterloo.ca>
> 
> Fixes Coverity CID 1343299. The call to xc_psr_cat_set_domain_data()
> expects type xc_psr_cat_type but is provided libxl_psr_cbm_type which
> is defined in IDL.

I assume the values are the same by construction in the IDL? Assuming so
then it would be worth mentioning that here I think, so we know why we
thought this was a valid change.

>  This change adds an explicit cast to fix the
> Coverity warning, and tweaks the surrounding code to more closely
> conform to the guidelines in CODING_STYLE.
> 
> No functional changes.
> 
> Signed-off-by: Chester Lin <czy...@uwaterloo.ca>
> ---
>  tools/libxl/libxl_psr.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
> index 3d0dc61..1677f9c 100644
> --- a/tools/libxl/libxl_psr.c
> +++ b/tools/libxl/libxl_psr.c
> @@ -298,7 +298,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t
> domid,
>                            uint64_t cbm)
>  {
>      GC_INIT(ctx);
> -    int rc;
> +    int rc, r;
>      int socketid, nr_sockets;
>  
>      rc = libxl__count_physical_sockets(gc, &nr_sockets);
> @@ -310,7 +310,9 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t
> domid,
>      libxl_for_each_set_bit(socketid, *target_map) {
>          if (socketid >= nr_sockets)
>              break;
> -        if (xc_psr_cat_set_domain_data(ctx->xch, domid, type, socketid,
> cbm)) {
> +        r = xc_psr_cat_set_domain_data(ctx->xch, domid,
> (xc_psr_cat_type) type,
> +                                       socketid, cbm);
> +        if (r) {
>              libxl__psr_cat_log_err_msg(gc, errno);
>              rc = ERROR_FAIL;
>          }
> @@ -326,11 +328,14 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t
> domid,
>                            uint64_t *cbm_r)
>  {
>      GC_INIT(ctx);
> -    int rc = 0;
> -
> -    if (xc_psr_cat_get_domain_data(ctx->xch, domid, type, target,
> cbm_r)) {
> +    int rc, r;
> +    r = xc_psr_cat_get_domain_data(ctx->xch, domid, (xc_psr_cat_type)
> type,
> +                                   target, cbm_r);
> +    if (r) {
>          libxl__psr_cat_log_err_msg(gc, errno);
>          rc = ERROR_FAIL;
> +    } else {
> +        rc = 0;
>      }
>  
>      GC_FREE;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to