Re: [LTP] [PATCH] Add tst_tmpdir_path() and tst_tmpdir_mkpath()

Petr Vorel
2024-07-17T08:31:42Z

Hi Cyril,

...
> > +/**
> > + * 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.
> > + */

Also, formatting other lines with indent makes " A newly allocated path. The
memory is freed automatically at the end" to be bold. The correct formatting is
therefore without indent:

/**
* 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
* 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.
*
* 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_mkpath(const char *fmt, ...)
__attribute__((format(printf, 1, 2)));

Kind regards,
Petr