public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag
Date: Fri, 12 Jun 2020 16:24:55 +0200	[thread overview]
Message-ID: <20200612142455.GA2310@yuki.lan> (raw)
In-Reply-To: <20200505032803.s6axol3sfyyzl6ag@vireshk-i7>

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

      parent reply	other threads:[~2020-06-12 14:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30  8:57 [LTP] [PATCH 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag Xiao Yang
2020-04-30  8:57 ` [LTP] [PATCH 2/2] syscalls/pidfd_open*.c: Drop .min_kver flag Xiao Yang
2020-05-04  5:11   ` Viresh Kumar
2020-05-04 12:49     ` Xiao Yang
2020-05-05  3:35       ` Viresh Kumar
2020-05-05  9:30         ` Xiao Yang
2020-05-05  9:51           ` Viresh Kumar
2020-05-12 14:32           ` Xiao Yang
2020-06-12 14:30         ` Cyril Hrubis
2020-05-04  5:09 ` [LTP] [PATCH 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag Viresh Kumar
2020-05-04  8:30   ` =?unknown-8bit?b?5p2o5pmT?=
2020-05-04 11:32     ` Xiao Yang
2020-05-04 11:31   ` Xiao Yang
2020-05-05  3:28     ` Viresh Kumar
2020-05-05  8:44       ` Xiao Yang
2020-05-12 14:25         ` Xiao Yang
2020-06-12 14:24       ` Cyril Hrubis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200612142455.GA2310@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox