public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag
Date: Wed, 13 May 2020 21:12:11 +0800	[thread overview]
Message-ID: <5EBBF22B.80501@cn.fujitsu.com> (raw)
In-Reply-To: <20200513123409.GA10803@yuki.lan>

On 2020/5/13 20:34, Cyril Hrubis wrote:
> Hi!
>> pidfd_open(2) will set close-on-exec flag on the file descriptor as it
>> manpage states, so check close-on-exec flag by fcntl(2).
>>
>> BTW:
>> I tried to pass (long) TST_RET to fcntl() but triggered the following
>> compiler warning, so pass (int) pidfd instead.
>> ------------------------------------------------------
>> In file included from pidfd_open01.c:9:
>> pidfd_open01.c: In function ???run???:
>> ../../../../include/tst_test.h:76:41: warning: format ???%i??? expects argument of type ???int???, but argument 5 has type ???long int??? [-Wformat=]
>>     76 |   tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
>>        |                                         ^~~~~~~~~
>> ../../../../include/tst_safe_macros.h:224:5: note: in expansion of macro ???tst_brk???
>>    224 |     tst_brk(TBROK | TERRNO,                          \
>>        |     ^~~~~~~
>> pidfd_open01.c:20:9: note: in expansion of macro ???SAFE_FCNTL???
>>     20 |  flag = SAFE_FCNTL(TST_RET, F_GETFD);
>
> You can either cast the TST_RET to int as SAFE_FCNTL((int)TST_RET, ...)
> or if you decide to store the pidfd into an int variable there is no
> added value in using the TEST() macro here so the code should just do
> pidfd = pidfd_open(...) and use the pidfd instead of TST_RET.
Hi Cyril,

Thanks for your reply.
I also think it is OK to replace TEST() and TST_RET directly.

Thanks,
Xiao Yang
>




      reply	other threads:[~2020-05-13 13:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13  1:26 [LTP] [PATCH v2 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag Xiao Yang
2020-05-13  1:26 ` [LTP] [PATCH v2 2/2] syscalls/pidfd_open*.c: Drop .min_kver flag Xiao Yang
2020-05-13  5:55   ` Viresh Kumar
2020-05-13  6:03     ` Xiao Yang
2020-05-13  6:13       ` Viresh Kumar
2020-05-13  6:31         ` Xiao Yang
2020-05-13  6:39           ` Viresh Kumar
2020-05-13  2:28 ` [LTP] [PATCH v2 1/2] syscalls/pidfd_open01.c: Add check for close-on-exec flag Xiao Yang
2020-05-13  9:20   ` Petr Vorel
2020-05-13 10:21     ` Xiao Yang
2020-05-13 10:30       ` Petr Vorel
2020-05-14  7:37         ` Petr Vorel
2020-05-14  9:43           ` Xiao Yang
2020-05-14 14:14             ` Petr Vorel
2020-05-14 14:27               ` Xiao Yang
2020-05-13 12:34 ` Cyril Hrubis
2020-05-13 13:12   ` Xiao Yang [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=5EBBF22B.80501@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --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