[LTP] [PATCH v2 1/5] Hugetlb: Migrating libhugetlbfs counters
Cyril Hrubis
chrubis@suse.cz
Mon Nov 14 10:49:28 CET 2022
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;
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list