Subject: Re: [PATCH v2] rtrs-clt: silence kbuild test inconsistent intenting smatch warning

From: Jason Gunthorpe <[email-masked]>
Date: Wed, 20 May 2020 16:11:05 -0300

On Wed, May 20, 2020 at 12:04:28PM +0200, Danil Kipnis wrote:
> On Wed, May 20, 2020 at 1:38 AM Jason Gunthorpe <[email-masked]> wrote:
> >
> > On Tue, May 19, 2020 at 07:29:15AM -0700, Bart Van Assche wrote:
> > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > > index 468fdd0d8713..8dfa56dc32bc 100644
> > > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > > @@ -727,18 +727,13 @@ struct path_it {
> > >       struct rtrs_clt_sess *(*next_path)(struct path_it *it);
> > >  };
> > >
> > > -#define do_each_path(path, clt, it) {                                        \
> > > -     path_it_init(it, clt);                                          \
> > > -     rcu_read_lock();                                                \
> > > -     for ((it)->i = 0; ((path) = ((it)->next_path)(it)) &&           \
> > > -                       (it)->i < (it)->clt->paths_num;               \
> > > +#define for_each_path(path, clt, it)                                 \
> > > +     for (path_it_init((it), (clt)), rcu_read_lock(), (it)->i = 0;   \
> > > +          (((path) = ((it)->next_path)(it)) &&                       \
> > > +           (it)->i < (it)->clt->paths_num) ||                        \
> > > +                  (path_it_deinit(it), rcu_read_unlock(), 0);        \
> > >            (it)->i++)
> >
> > That is nicer, even better to write it with some inlines..
> 
> You mean pass a callback to an inline function that would iterate?

no, just wrap some of that logic embedded in the for statement in some
inlines, not sure

Jason