Message ID | 20180620075917.21056-2-pvorel@suse.cz |
---|---|
State | Superseded |
Delegated to: | Petr Vorel |
Headers | show |
Series | [1/3] lib: Add SAFE_CHROOT(path) macro | expand |
Hi! > +extern void *TEST_RETURN_PTR; > + > +#define TESTPTR(SCALL) \ > + do { \ > + errno = 0; \ > + TEST_RETURN_PTR = (void*)(TEST_RETURN = (intptr_t)SCALL); \ I guess that this expression is safe enough, since TEST_RETURN is long, so the assigment will not overflow, but that also begs a question why do we assign it in the first place? > + TEST_ERRNO = errno; \ > + } while (0) > + > /* > * Functions to convert ERRNO to its name and SIGNAL to its name. > */ > diff --git a/lib/tst_res.c b/lib/tst_res.c > index 8ff7ee425..84becbef4 100644 > --- a/lib/tst_res.c > +++ b/lib/tst_res.c > @@ -55,6 +55,7 @@ > > long TEST_RETURN; > int TEST_ERRNO; > +void *TEST_RETURN_PTR; Can we please name it a bit better so that we avoid renaming it later on? What about TST_RET_PTR so that it's consistent with the planned rename of TEST_RETURN to just TST_RET? > #define VERBOSE 1 > #define NOPASS 3 > -- > 2.17.1 >
diff --git a/include/tst_test.h b/include/tst_test.h index 54ff306d9..ab45e2783 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -195,6 +195,15 @@ void tst_reinit(void); extern long TEST_RETURN; extern int TEST_ERRNO; +extern void *TEST_RETURN_PTR; + +#define TESTPTR(SCALL) \ + do { \ + errno = 0; \ + TEST_RETURN_PTR = (void*)(TEST_RETURN = (intptr_t)SCALL); \ + TEST_ERRNO = errno; \ + } while (0) + /* * Functions to convert ERRNO to its name and SIGNAL to its name. */ diff --git a/lib/tst_res.c b/lib/tst_res.c index 8ff7ee425..84becbef4 100644 --- a/lib/tst_res.c +++ b/lib/tst_res.c @@ -55,6 +55,7 @@ long TEST_RETURN; int TEST_ERRNO; +void *TEST_RETURN_PTR; #define VERBOSE 1 #define NOPASS 3
for testing with pointers Signed-off-by: Petr Vorel <pvorel@suse.cz> --- include/tst_test.h | 9 +++++++++ lib/tst_res.c | 1 + 2 files changed, 10 insertions(+)