From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v8 1/2] coredump01: New core_pattern specifiers test
Date: Tue, 8 Sep 2026 17:34:07 +0200 [thread overview]
Message-ID: <aqAq70zXDbhPv6_w@yuki.lan> (raw)
In-Reply-To: <20260908-coredump-v8-1-591f96004543@suse.com>
Hi!
> +static void set_pattern(const char *fmt, ...)
> +{
> + char pattern[PATTERN_MAX];
> + char readback[PATTERN_MAX];
> + va_list va;
> + int len;
> +
> + va_start(va, fmt);
> + len = vsnprintf(pattern, sizeof(pattern), fmt, va);
> + va_end(va);
> +
> + if (len >= PATTERN_MAX)
> + tst_brk(TCONF, "core_pattern does not fit into %i bytes", PATTERN_MAX - 1);
> +
> + SAFE_FILE_PRINTF(PATH_KERN_CORE_PATTERN, "%s", pattern);
We actually have safe_file_vprintf() it's not just exposed, we can
easily expose the API with:
diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 73ebd2ab8..f3b322072 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -65,6 +65,10 @@ void safe_file_read_str(const char *file, const int lineno,
safe_file_printf(__FILE__, __LINE__, NULL, \
(path), (fmt), ## __VA_ARGS__)
+#define SAFE_FILE_VPRINTF(path, fmt, va) \
+ safe_file_vprintf(__FILE__, __LINE__, NULL, \
+ (path), (fmt), va)
+
/* Same as SAFE_FILE_PRINTF() but returns quietly if the path doesn't exist */
#define SAFE_TRY_FILE_PRINTF(path, fmt, ...) \
safe_try_file_printf(__FILE__, __LINE__, NULL, \
diff --git a/lib/safe_file_ops.c b/lib/safe_file_ops.c
index 19da1fd97..1069a017f 100644
--- a/lib/safe_file_ops.c
+++ b/lib/safe_file_ops.c
@@ -280,7 +280,7 @@ err:
return 1;
}
-static void safe_file_vprintf(const char *file, const int lineno,
+void safe_file_vprintf(const char *file, const int lineno,
void (*cleanup_fn)(void), const char *path, const char *fmt,
va_list va)
{
And then we can do SAFE_FILE_VPRINTF() here directly instead of the
double printf().
The rest looks fine:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-08 15:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:26 [LTP] [PATCH v8 0/2] coredump testing suite Andrea Cervesato
2026-09-08 6:26 ` [LTP] [PATCH v8 1/2] coredump01: New core_pattern specifiers test Andrea Cervesato
2026-09-08 6:48 ` [LTP] " linuxtestproject.agent
2026-09-08 15:34 ` Cyril Hrubis [this message]
2026-09-08 6:26 ` [LTP] [PATCH v8 2/2] coredump02: Verify ELF structure and notes Andrea Cervesato
2026-09-08 15:59 ` Cyril Hrubis
2026-09-09 9:15 ` Andrea Cervesato via ltp
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=aqAq70zXDbhPv6_w@yuki.lan \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--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