Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib/tst_checkpoint.c: Replace SAFE_CLOSE with SAFE_UNLINK
Date: Fri, 30 Apr 2021 11:16:18 +0200	[thread overview]
Message-ID: <YIvK4qFFbWpsEv2y@yuki> (raw)
In-Reply-To: <20210429142232.29596-1-zhaogongyi@huawei.com>

Hi!
> When we call tst_checkpoint_init and set the cleanup_fn to NULL, the file
> checkpoint_futex_base_file might be left over.
> 
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
>  lib/tst_checkpoint.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
> index 9e9dcf9e6..3360ab07b 100644
> --- a/lib/tst_checkpoint.c
> +++ b/lib/tst_checkpoint.c
> @@ -78,7 +78,7 @@ void tst_checkpoint_init(const char *file, const int lineno,
> 
>  	tst_max_futexes = page_size / sizeof(uint32_t);
> 
> -	SAFE_CLOSE(cleanup_fn, fd);
> +	SAFE_UNLINK(cleanup_fn, "checkpoint_futex_base_file");

We ensure that the file is created in the test temporary directory and
we do check that the test created a temporary directory with the
tst_tmpdir_created() before we attempt to open the file, so the file is
removed at the end of the test along with rest of the files the test has
created.

Also we have to close the fd, we keep reference to the file only via the
mmaped() pages, there is no point in keeping it open.

-- 
Cyril Hrubis
chrubis@suse.cz

      reply	other threads:[~2021-04-30  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29 14:22 [LTP] [PATCH] lib/tst_checkpoint.c: Replace SAFE_CLOSE with SAFE_UNLINK Zhao Gongyi
2021-04-30  9:16 ` 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=YIvK4qFFbWpsEv2y@yuki \
    --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