[LTP] [PATCH 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag
Cyril Hrubis
chrubis@suse.cz
Fri Jun 12 16:24:55 CEST 2020
Hi!
> > > > +
> > > > + pidfd = pidfd_open(getpid(), 0);
> > > > + if (pidfd == -1)
> > > > + tst_brk(TFAIL | TERRNO, "pidfd_open(getpid(), 0) failed");
> > > This could have been written as:
> > > TEST(pidfd = pidfd_open(getpid(), 0));
> >
> > Why do you want to keep TEST()? I don't think it is necessary:
> >
> > 1) pidfd and TERRNO are enough to check return value and errno.
> >
> > 2) It is OK for testcase to not use TEST().
>
> As far as I have understood, that is the preferred way of doing it
> from LTP maintainers.
>
> Over that it was already there, why remove it now ? Just fix the
> problems you are trying to fix and that should be good.
I do not care that much if the test uses the macro or not, but you should
really keep changes separate from the removal of the kernel minimal version.
Also I guess that we can supress the warning by a cast in the SAFE_FCNTL()
macro so that we can pass long there.
This should do:
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index c39d8768b..c153f163c 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -215,14 +215,14 @@ pid_t safe_getpgid(const char *file, const int lineno, pid_t pid);
({int tst_ret_ = ioctl(fd, request, ##__VA_ARGS__); \
tst_ret_ < 0 ? \
tst_brk(TBROK | TERRNO, \
- "ioctl(%i,%s,...) failed", fd, #request), 0 \
+ "ioctl(%i,%s,...) failed", (int)fd, #request), 0 \
: tst_ret_;})
#define SAFE_FCNTL(fd, cmd, ...) \
({int tst_ret_ = fcntl(fd, cmd, ##__VA_ARGS__); \
tst_ret_ == -1 ? \
tst_brk(TBROK | TERRNO, \
- "fcntl(%i,%s,...) failed", fd, #cmd), 0 \
+ "fcntl(%i,%s,...) failed", (int)fd, #cmd), 0 \
: tst_ret_;})
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list