diff mbox

[rdma-next,1/5] RDMA/ipoib: Use min_t() macro instead of min()

Message ID 20180704184651.26728-2-kamalheib1@gmail.com (mailing list archive)
State Superseded
Headers show

Commit Message

Kamal Heib July 4, 2018, 6:46 p.m. UTC
Use min_t() macro to avoid the casing when using min() macro, also
use "unsigned int" instead of "unsigned" which is prefered.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 drivers/infiniband/ulp/ipoib/ipoib_cm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Leon Romanovsky July 4, 2018, 7:08 p.m. UTC | #1
On Wed, Jul 04, 2018 at 09:46:47PM +0300, Kamal Heib wrote:
> Use min_t() macro to avoid the casing when using min() macro, also

casing -> casting

> use "unsigned int" instead of "unsigned" which is prefered.
>
> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> ---
>  drivers/infiniband/ulp/ipoib/ipoib_cm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> index 23cb1adc636f..9e7e5fd8eac6 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> @@ -547,7 +547,7 @@ static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space,
>  					   0, PAGE_SIZE);
>  			--skb_shinfo(skb)->nr_frags;
>  		} else {
> -			size = min(length, (unsigned) PAGE_SIZE);
> +			size = min_t(unsigned int, length, PAGE_SIZE);
>
>  			skb_frag_size_set(frag, size);
>  			skb->data_len += size;
> @@ -641,8 +641,8 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
>  		}
>  	}
>
> -	frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len,
> -					      (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
> +	frags = PAGE_ALIGN(wc->byte_len -
> +			min_t(unsigned int, wc->byte_len, IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;

wc->byte_len is u32 and not unsigned int.

>
>  	newskb = ipoib_cm_alloc_rx_skb(dev, rx_ring, wr_id, frags,
>  				       mapping, GFP_ATOMIC);
> --
> 2.14.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kamal Heib July 4, 2018, 9:09 p.m. UTC | #2
On Wed, Jul 04, 2018 at 10:08:44PM +0300, Leon Romanovsky wrote:
> On Wed, Jul 04, 2018 at 09:46:47PM +0300, Kamal Heib wrote:
> > Use min_t() macro to avoid the casing when using min() macro, also
> 
> casing -> casting
>
I'll fix it in v2.
 
> > use "unsigned int" instead of "unsigned" which is prefered.
> >
> > Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> > ---
> >  drivers/infiniband/ulp/ipoib/ipoib_cm.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> > index 23cb1adc636f..9e7e5fd8eac6 100644
> > --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> > +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
> > @@ -547,7 +547,7 @@ static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space,
> >  					   0, PAGE_SIZE);
> >  			--skb_shinfo(skb)->nr_frags;
> >  		} else {
> > -			size = min(length, (unsigned) PAGE_SIZE);
> > +			size = min_t(unsigned int, length, PAGE_SIZE);
> >
> >  			skb_frag_size_set(frag, size);
> >  			skb->data_len += size;
> > @@ -641,8 +641,8 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
> >  		}
> >  	}
> >
> > -	frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len,
> > -					      (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
> > +	frags = PAGE_ALIGN(wc->byte_len -
> > +			min_t(unsigned int, wc->byte_len, IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
> 
> wc->byte_len is u32 and not unsigned int.
I'll fix it in v2.

Thanks,
Kamal
> 
> >
> >  	newskb = ipoib_cm_alloc_rx_skb(dev, rx_ring, wr_id, frags,
> >  				       mapping, GFP_ATOMIC);
> > --
> > 2.14.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 23cb1adc636f..9e7e5fd8eac6 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -547,7 +547,7 @@  static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space,
 					   0, PAGE_SIZE);
 			--skb_shinfo(skb)->nr_frags;
 		} else {
-			size = min(length, (unsigned) PAGE_SIZE);
+			size = min_t(unsigned int, length, PAGE_SIZE);
 
 			skb_frag_size_set(frag, size);
 			skb->data_len += size;
@@ -641,8 +641,8 @@  void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
 		}
 	}
 
-	frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len,
-					      (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
+	frags = PAGE_ALIGN(wc->byte_len -
+			min_t(unsigned int, wc->byte_len, IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
 
 	newskb = ipoib_cm_alloc_rx_skb(dev, rx_ring, wr_id, frags,
 				       mapping, GFP_ATOMIC);