Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-03-03 Thread Jakob Koschel
> On 3. Mar 2022, at 05:58, David Laight wrote: > > From: Xiaomeng Tong >> Sent: 03 March 2022 02:27 >> >> On Wed, 2 Mar 2022 14:04:06 +, David Laight >> wrote: >>> I think that it would be better to make any alternate loop macro >>> just set the variable to NULL on the loop exit. >>> Th

Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-03-01 Thread Jakob Koschel
> On 1. Mar 2022, at 18:36, Greg KH wrote: > > On Tue, Mar 01, 2022 at 12:28:15PM +0100, Jakob Koschel wrote: >> >> >>> On 1. Mar 2022, at 01:41, Linus Torvalds >>> wrote: >>> >>> On Mon, Feb 28, 2022 at 1:47 PM Jakob Koschel

Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-03-01 Thread Jakob Koschel
> On 1. Mar 2022, at 01:41, Linus Torvalds > wrote: > > On Mon, Feb 28, 2022 at 1:47 PM Jakob Koschel wrote: >> >> The goal of this is to get compiler warnings right? This would indeed be >> great. > > Yes, so I don't mind having a one-time

Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-03-01 Thread Jakob Koschel
> On 28. Feb 2022, at 21:10, Linus Torvalds > wrote: > > On Mon, Feb 28, 2022 at 12:03 PM Linus Torvalds > wrote: >> >> Side note: we do need *some* way to do it. > > Ooh. > > This patch is a work of art. > > And I mean that in the worst possible way. > > We can do > >typeof(po

Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-03-01 Thread Jakob Koschel
> On 28. Feb 2022, at 21:56, Christian König wrote: > > > > Am 28.02.22 um 21:42 schrieb James Bottomley: >> On Mon, 2022-02-28 at 21:07 +0100, Christian König wrote: >>> Am 28.02.22 um 20:56 schrieb Linus Torvalds: On Mon, Feb 28, 2022 at 4:19 AM Christian König wrote: [SNIP

[Intel-gfx] [PATCH 0/6] Remove usage of list iterator past the loop body

2022-02-28 Thread Jakob Koschel
rated by similar use cases. Because the output of get_maintainer.pl was too big, I included all the found lists and everyone from the previous discussion. Jakob Koschel (6): drivers: usb: remove usage of list iterator past the loop body treewide: remove using list iterator after loop body as a

Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-02-28 Thread Jakob Koschel
> On 28. Feb 2022, at 12:20, Greg KH wrote: > > On Mon, Feb 28, 2022 at 12:08:18PM +0100, Jakob Koschel wrote: >> If the list does not contain the expected element, the value of >> list_for_each_entry() iterator will not point to a valid structure. >> To avoid type

Re: [Intel-gfx] [PATCH 1/6] drivers: usb: remove usage of list iterator past the loop body

2022-02-28 Thread Jakob Koschel
> On 28. Feb 2022, at 12:24, Dan Carpenter wrote: > > On Mon, Feb 28, 2022 at 12:08:17PM +0100, Jakob Koschel wrote: >> diff --git a/drivers/usb/gadget/udc/at91_udc.c >> b/drivers/usb/gadget/udc/at91_udc.c >> index 9040a0561466..0fd0307bc07b 100644 >> --- a/

[Intel-gfx] [PATCH 5/6] treewide: remove dereference of list iterator after loop body

2022-02-28 Thread Jakob Koschel
loop and only setting the original variable if a suitable element was found. Then determing if the element was found is simply checking if the variable is set. Signed-off-by: Jakob Koschel --- drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 11 +++ drivers/scsi/wd719x.c

[Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

2022-02-28 Thread Jakob Koschel
the list traversal loop, use a dedicated pointer to point to the found element. Determining if an element was found is then simply checking if the pointer is != NULL. Signed-off-by: Jakob Koschel --- arch/x86/kernel/cpu/sgx/encl.c | 6 +++-- drivers/scsi/scsi_transport_sas.c| 17

[Intel-gfx] [PATCH 3/6] treewide: fix incorrect use to determine if list is empty

2022-02-28 Thread Jakob Koschel
the break, it is set to the correct value and leaving it NULL if no element was found. Signed-off-by: Jakob Koschel --- arch/powerpc/sysdev/fsl_gtm.c| 4 ++-- drivers/media/pci/saa7134/saa7134-alsa.c | 4 ++-- drivers/perf/xgene_pmu.c | 13 +++-- 3 files

[Intel-gfx] [PATCH 1/6] drivers: usb: remove usage of list iterator past the loop body

2022-02-28 Thread Jakob Koschel
limiting scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found request object. Signed-off-by: Jakob Koschel --- drivers/usb/gadget/udc/aspeed-vhub/epn.c | 11 ++ drivers/usb/gadget/udc/at91_udc.c| 26 ++-- drivers/usb

[Intel-gfx] [PATCH 6/6] treewide: remove check of list iterator against head past the loop body

2022-02-28 Thread Jakob Koschel
list_entry_is_head() or &pos->member == head, using the iterator variable after the loop should be avoided. In preparation to limiting the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element. Signed-off-by: Jakob Koschel --- arch/arm/mach-mmp

[Intel-gfx] [PATCH 4/6] drivers: remove unnecessary use of list iterator variable

2022-02-28 Thread Jakob Koschel
When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will *always* be a bogus pointer computed based on the head element. To avoid type confusion use the actual list head directly instead of last iterator value. Signed-off-by: Jakob