Re: [Xen-devel] xen-netback: add control protocol implementation

2016-05-17 Thread Paul Durrant
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: 17 May 2016 17:32
> To: Paul Durrant
> Cc: xen-de...@lists.xenproject.org
> Subject: re: xen-netback: add control protocol implementation
> 
> Hello Paul Durrant,
> 
> The patch 40d8abdee806: "xen-netback: add control protocol
> implementation" from May 13, 2016, leads to the following static
> checker warning:
> 
>   drivers/net/xen-netback/hash.c:362 xenvif_set_hash_mapping()
>   warn: should this be 'len == -1'
> 
> drivers/net/xen-netback/hash.c
>341  u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
>342  u32 off)
>343  {
>344  u32 *mapping = &vif->hash.mapping[off];
>345  struct gnttab_copy copy_op = {
>346  .source.u.ref = gref,
>347  .source.domid = vif->domid,
>348  .dest.u.gmfn = virt_to_gfn(mapping),
>349  .dest.domid = DOMID_SELF,
>350  .dest.offset = xen_offset_in_page(mapping),
>351  .len = len * sizeof(u32),
>352  .flags = GNTCOPY_source_gref
>353  };
>354
>355  if ((off + len > vif->hash.size) || copy_op.len > 
> XEN_PAGE_SIZE)
>356  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>357
>358  while (len-- != 0)
>359  if (mapping[off++] >= vif->num_queues)
>360  return 
> XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>361
>362  if (len != 0) {
> 
> We know that "len" is always UINT_MAX here meaning this is always true.
> What are trying to test?
> 

Yes, that's clearly bogus. The test is supposed to be checking whether the 
copy_op actually does something so it should be:

If (copy_op.len != 0)

I'll send a patch.

  Paul

>363  gnttab_batch_copy(©_op, 1);
>364
>365  if (copy_op.status != GNTST_okay)
>366  return 
> XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>367  }
>368
>369  return XEN_NETIF_CTRL_STATUS_SUCCESS;
>370  }
> 
> regards,
> dan carpenter

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] xen-netback: add control protocol implementation

2016-05-17 Thread Dan Carpenter
Hello Paul Durrant,

The patch 40d8abdee806: "xen-netback: add control protocol
implementation" from May 13, 2016, leads to the following static
checker warning:

drivers/net/xen-netback/hash.c:362 xenvif_set_hash_mapping()
warn: should this be 'len == -1'

drivers/net/xen-netback/hash.c
   341  u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
   342  u32 off)
   343  {
   344  u32 *mapping = &vif->hash.mapping[off];
   345  struct gnttab_copy copy_op = {
   346  .source.u.ref = gref,
   347  .source.domid = vif->domid,
   348  .dest.u.gmfn = virt_to_gfn(mapping),
   349  .dest.domid = DOMID_SELF,
   350  .dest.offset = xen_offset_in_page(mapping),
   351  .len = len * sizeof(u32),
   352  .flags = GNTCOPY_source_gref
   353  };
   354  
   355  if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE)
   356  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   357  
   358  while (len-- != 0)
   359  if (mapping[off++] >= vif->num_queues)
   360  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   361  
   362  if (len != 0) {

We know that "len" is always UINT_MAX here meaning this is always true.
What are trying to test?

   363  gnttab_batch_copy(©_op, 1);
   364  
   365  if (copy_op.status != GNTST_okay)
   366  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   367  }
   368  
   369  return XEN_NETIF_CTRL_STATUS_SUCCESS;
   370  }

regards,
dan carpenter

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel