Re: [PATCH] iommu: replace single-char identifiers in macros

2019-06-03 Thread Robin Murphy

On 03/06/2019 14:29, Qian Cai wrote:

On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:

On 03/06/2019 13:59, Qian Cai wrote:

There are a few macros in IOMMU have single-char identifiers make the
code hard to read and debug. Replace them with meaningful names.

Suggested-by: Andrew Morton 
Signed-off-by: Qian Cai 
---
   include/linux/dmar.h | 14 --
   1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index f8af1d770520..eb634912f475 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
   
   #define	dmar_rcu_dereference(p)	rcu_dereference_check((p),

dmar_rcu_check())
   
-#define	for_each_dev_scope(a, c, p, d)	\

-   for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
: \
-   NULL, (p) < (c)); (p)++)
-
-#definefor_each_active_dev_scope(a, c, p, d)   \
-   for_each_dev_scope((a), (c), (p), (d))  if (!(d)) { continue;
} else
+#define for_each_dev_scope(devs, cnt, i, tmp)  
\
+   for ((i) = 0; ((tmp) = (i) < (cnt) ? 
\


Given that "tmp" actually appears to be some sort of device cursor, I'm
not sure that that naming really achieves the stated goal of clarity :/


"tmp" is used in the callers everywhere though, although I suppose something
like "tmp_dev" can be used if you prefer.


I don't have any preference, I'm just questioning the assertion in the 
commit message - as a reader not intimately familiar with this code, 
"tmp" is honestly no more meaningful than "d" was.


Robin.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] iommu: replace single-char identifiers in macros

2019-06-03 Thread Qian Cai
On Mon, 2019-06-03 at 14:07 +0100, Robin Murphy wrote:
> On 03/06/2019 13:59, Qian Cai wrote:
> > There are a few macros in IOMMU have single-char identifiers make the
> > code hard to read and debug. Replace them with meaningful names.
> > 
> > Suggested-by: Andrew Morton 
> > Signed-off-by: Qian Cai 
> > ---
> >   include/linux/dmar.h | 14 --
> >   1 file changed, 8 insertions(+), 6 deletions(-)
> > 
> > diff --git a/include/linux/dmar.h b/include/linux/dmar.h
> > index f8af1d770520..eb634912f475 100644
> > --- a/include/linux/dmar.h
> > +++ b/include/linux/dmar.h
> > @@ -104,12 +104,14 @@ static inline bool dmar_rcu_check(void)
> >   
> >   #define   dmar_rcu_dereference(p) rcu_dereference_check((p),
> > dmar_rcu_check())
> >   
> > -#definefor_each_dev_scope(a, c, p, d)  \
> > -   for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev)
> > : \
> > -   NULL, (p) < (c)); (p)++)
> > -
> > -#definefor_each_active_dev_scope(a, c, p, d)   \
> > -   for_each_dev_scope((a), (c), (p), (d))  if (!(d)) { continue;
> > } else
> > +#define for_each_dev_scope(devs, cnt, i, tmp)  
> > \
> > +   for ((i) = 0; ((tmp) = (i) < (cnt) ?
> > \
> 
> Given that "tmp" actually appears to be some sort of device cursor, I'm 
> not sure that that naming really achieves the stated goal of clarity :/

"tmp" is used in the callers everywhere though, although I suppose something
like "tmp_dev" can be used if you prefer.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu