Re: [PATCH 4/6] staging: qlge: qlge_main: Simplify while statements.

2020-07-14 Thread Dan Carpenter
On Tue, Jul 14, 2020 at 12:10:22PM +0530, Suraj Upadhyay wrote:
> On Mon, Jul 13, 2020 at 05:12:35PM +0300, Dan Carpenter wrote:
> > On Mon, Jul 13, 2020 at 05:50:14PM +0530, Suraj Upadhyay wrote:
> > > Simplify while loops into more readable and simple for loops.
> > > 
> > 
> > I don't think either is more clear that the other.  Walter Harms hates
> > count down loops and he's not entirely wrong...
> > 
> > regards,
> > dan carpenter
> 
> Hi Dan,
>   Thanks for your response.
> Should I send a v2 of this patch or not ??
> Also do you have any problems with the other two patches doing the same
> thing in different files ??
> I am all ears.

I would just resend patch 6/6.  If this is your driver and you're going
to be working on it extensively then you do what makes you feel
comfortable.  But to me the original code seems fine with while count
down loops.

regards,
dan carpenter

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/6] staging: qlge: qlge_main: Simplify while statements.

2020-07-14 Thread Suraj Upadhyay
On Tue, Jul 14, 2020 at 02:41:37PM +0900, Benjamin Poirier wrote:
> On 2020-07-13 17:50 +0530, Suraj Upadhyay wrote:
> > Simplify while loops into more readable and simple for loops.
> > 
> > Signed-off-by: Suraj Upadhyay 
> > ---
> [...]
> > @@ -1824,7 +1821,7 @@ static struct sk_buff *ql_build_rx_skb(struct 
> > ql_adapter *qdev,
> > sbq_desc->p.skb = NULL;
> > skb_reserve(skb, NET_IP_ALIGN);
> > }
> > -   do {
> > +   for (; length > 0; length -= size, i++) {
> > lbq_desc = ql_get_curr_lchunk(qdev, rx_ring);
> > size = min(length, qdev->lbq_buf_size);
> >  
> > @@ -1839,7 +1836,7 @@ static struct sk_buff *ql_build_rx_skb(struct 
> > ql_adapter *qdev,
> > skb->truesize += size;
> > length -= size;
> > i++;
> > -   } while (length > 0);
> > +   }
> 
> Looks like length and i modification should be removed from here. But in
> this instance, maybe the original was better anyways.
 
Thanks for pointing that out. It nearly slipped.

> Agreed with Dan. At least some of those loops can be converted to "count
> up" loops for a more familiar appearance.

I mostly tried to convert the do-while loops, which I think are't that
obvious than while and for loops.

Thanks,

Suraj Upadhyay.



signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/6] staging: qlge: qlge_main: Simplify while statements.

2020-07-14 Thread Suraj Upadhyay
On Mon, Jul 13, 2020 at 05:12:35PM +0300, Dan Carpenter wrote:
> On Mon, Jul 13, 2020 at 05:50:14PM +0530, Suraj Upadhyay wrote:
> > Simplify while loops into more readable and simple for loops.
> > 
> 
> I don't think either is more clear that the other.  Walter Harms hates
> count down loops and he's not entirely wrong...
> 
> regards,
> dan carpenter

Hi Dan,
Thanks for your response.
Should I send a v2 of this patch or not ??
Also do you have any problems with the other two patches doing the same
thing in different files ??
I am all ears.

Thanks,

Suraj Upadhyay.



signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel