[LTP] [PATCH v2 1/5] Hugetlb: Migrating libhugetlbfs counters
Tarun Sahu
tsahu@linux.ibm.com
Mon Nov 14 19:51:31 CET 2022
On Mon, 2022-11-14 at 10:49 +0100, Cyril Hrubis wrote:
> Hi!
> > > I guess that we can also put the map() (touch()) test_counters()
> > > unamp()
> > > sequence to a do_test() fuction then call it from the for() loop
> > > in
> > > run_test(). That would make the code a bit cleaner.
> > >
> > Instead, I am thinking of a defining a macro like this,
> >
> > #define CHECK_(fun) ({ \
> > if (fun) { \
> > break; \
> > } \
> > })
> >
> > inside test_counters:
> >
> > do {
> > CHECK_(map(...));
> > CHECK_(touch(...));
> > CHECK_(unmap(...));
> > } while(0)
> >
> > inside for loop of run_test:
> >
> > CHECK_(map(...));
> > CHECK_(test_counters(...));
> > CHECK_(unmap(...));
>
> While this is much better than longjmp() it still obscures the
> codeflow
> a little bit.
>
> Also I do not think that we need all the braces in the CHECK() macro,
> it
> should be enough just to do:
>
> #define CHECK(fun) \
> if (fun) \
> break;
>
> or even:
>
> #define CHECK(fun) if (fun) break;
This throws make check warning, It asks to put it in do..while
which is not preferable as we want break the parent loop, not the
loop added by macro. So I added those brackets.
>
More information about the ltp
mailing list