lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YqInZ/KNEJFN9kNS@Sassy>
Date:   Thu, 9 Jun 2022 13:01:27 -0400
From:   Srivathsan Sivakumar <sri.skumar05@...il.com>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     Manish Chopra <manishc@...vell.com>, GR-Linux-NIC-Dev@...vell.com,
        Coiby Xu <coiby.xu@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        netdev@...r.kernel.org, linux-staging@...ts.linux.dev,
        linux-kernel@...r.kernel.org
Subject: [PATCH] staging: qlge: qlge_main.c: convert do-while loops to for
 loops

On Thu, Jun 09, 2022 at 06:26:53PM +0300, Dan Carpenter wrote:
> On Thu, Jun 09, 2022 at 11:15:51AM -0400, Srivathsan Sivakumar wrote:
> > diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
> > index 8c35d4c4b851..308e8b621185 100644
> > --- a/drivers/staging/qlge/qlge_main.c
> > +++ b/drivers/staging/qlge/qlge_main.c
> > @@ -3006,13 +3006,13 @@ static int qlge_start_rx_ring(struct qlge_adapter *qdev, struct rx_ring *rx_ring
> >  		cqicb->flags |= FLAGS_LL;	/* Load lbq values */
> >  		tmp = (u64)rx_ring->lbq.base_dma;
> >  		base_indirect_ptr = rx_ring->lbq.base_indirect;
> > -		page_entries = 0;
> > -		do {
> > -			*base_indirect_ptr = cpu_to_le64(tmp);
> > -			tmp += DB_PAGE_SIZE;
> > -			base_indirect_ptr++;
> > -			page_entries++;
> > -		} while (page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN));
> > +
> > +		for (page_entries = 0; page_entries <
> > +			MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN); page_entries++) {
> > +				*base_indirect_ptr = cpu_to_le64(tmp);
> > +				tmp += DB_PAGE_SIZE;
> > +				base_indirect_ptr++;
> > +		}
> 
> It's better than the original, but wouldn't it be better yet to write
> something like this (untested):
> 
> 		for (i = 0; i <	MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN); i++)
> 			base_indirect_ptr[i] = cpu_to_le64(tmp + (i * DB_PAGE_SIZE));
> 
> Same with the other as well, obviously.
> 
> regards,
> dan carpenter
> 

Hello Dan,

Thanks for your input

wouldn't base_indirect_ptr point at a different endian value if tmp is
added with (i * DB_PAGE_SIZE)?

Thanks,
Srivathsan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ