public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Add tst_tmpdir_path() and tst_tmpdir_mkpath()
Date: Wed, 17 Jul 2024 10:25:47 +0200	[thread overview]
Message-ID: <20240717082547.GA584952@pevik> (raw)
In-Reply-To: <20240712134412.30853-1-chrubis@suse.cz>

Hi Cyril,

> - tst_tmpdir_path() creates a singleton string copy of the library
>   internal path and returns pointer to it on all subsequent calls.

> - tst_tmpdir_mkpath() constructs a path from the temporary directory
>   path and printf-like format paramters.

> - both functions use guarded buffers to allocate the memory, which
>   especially means that there is no reason to free these strings at
>   the program end.

> - all new library tests are converted to the new API

> + macro is added for new library that fails compilation if old API
>   function is used

> This should solve the absolute temporary directory path handling once
> for all.

Thanks for this! No need for free(), no need to use asprintf() :).

...

> +/**
> + * tst_tmpdir_path - Returns a pointer to a tmpdir path.
> + *
> + * The returned path is allocated and initialized the first time this function is
> + * called, each subsequent call will return the same pointer.
> + *
> + * @return A newly allocated path. The memory is freed automatically at the end
Return must be 'return:', otherwise it's not recognised.

    * return: A newly allocated path. The memory is freed automatically at the end

> + *         of the test. If allocation fails the function calls tst_brk() and
> + *         exits the test.
> + */
> +char *tst_tmpdir_path(void);
> +
> +/**
> + * tst_tmpdir_mkpath - Construct an absolute path pointing to a file inside tmpdir.
> + *
> + * Constructs a path inside tmpdir i.e. adds a prefix pointing to the current
> + * test tmpdir to the string build by the printf-like format.
> + *
> + * @fmt A printf-like format string.
> + * @... A printf-like parameter list.
NOTE: parameters need ':', otherwise it will not be recognised.

 * @fmt: A printf-like format string.
 * @...: A printf-like parameter list.


> + *
> + * @return A newly allocated path. The memory is freed automatically at the end
and here 'return:' as well

It's always safer to generate docs and check it.

With these fixes:
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-07-17  8:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12 13:44 [LTP] [PATCH] Add tst_tmpdir_path() and tst_tmpdir_mkpath() Cyril Hrubis
2024-07-17  8:25 ` Petr Vorel [this message]
2024-07-17  8:31   ` Petr Vorel
2024-07-22 13:06     ` Petr Vorel
2024-07-22 13:10       ` Cyril Hrubis
2024-07-23 15:17         ` Andrea Cervesato via ltp
2024-07-24  7:42           ` Petr Vorel
2024-07-24  8:44             ` Cyril Hrubis
2024-07-24  9:01               ` Andrea Cervesato via ltp
2024-07-24  9:05                 ` Petr Vorel
2024-07-17  8:33   ` Cyril Hrubis

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=20240717082547.GA584952@pevik \
    --to=pvorel@suse.cz \
    --cc=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