From 7ec0f69cd1c3fc495dbb052390a0f9f5160decf8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 30 Apr 2024 20:22:09 +0200 Subject: [PATCH] toolcontext: introduce var for run in valgrind --- lib/commands/toolcontext.c | 13 ++++++------- lib/commands/toolcontext.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 307369535..484720b87 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -47,6 +47,8 @@ #ifdef HAVE_VALGRIND #include +#else +#define RUNNING_ON_VALGRIND 0 #endif #ifdef __linux__ @@ -1702,6 +1704,8 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd, cmd->handles_unknown_segments = 0; cmd->hosttags = 0; cmd->check_devs_used = 1; + cmd->running_on_valgrind = RUNNING_ON_VALGRIND; + dm_list_init(&cmd->arg_value_groups); dm_list_init(&cmd->formats); dm_list_init(&cmd->segtypes); @@ -1714,9 +1718,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd, /* Set in/out stream buffering before glibc */ if (set_buffering -#ifdef HAVE_VALGRIND - && !RUNNING_ON_VALGRIND /* Skipping within valgrind execution. */ -#endif + && !cmd->running_on_valgrind /* Skipping within valgrind execution. */ #ifdef SYS_gettid /* For threaded programs no changes of streams */ /* On linux gettid() is implemented only via syscall */ @@ -2094,10 +2096,7 @@ void destroy_toolcontext(struct cmd_context *cmd) dm_device_list_destroy(&cmd->cache_dm_devs); -#ifdef HAVE_VALGRIND - if (!RUNNING_ON_VALGRIND) /* Skipping within valgrind execution. */ -#endif - if (cmd->linebuffer) { + if (!cmd->running_on_valgrind && cmd->linebuffer) { int flags; /* Reset stream buffering to defaults */ if (is_valid_fd(STDIN_FILENO) && diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index dec11ecbc..3c2b9eaab 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -139,6 +139,7 @@ struct cmd_context { */ unsigned is_long_lived:1; /* optimises persistent_filter handling */ unsigned is_interactive:1; + unsigned running_on_valgrind:1; unsigned check_pv_dev_sizes:1; unsigned handles_missing_pvs:1; unsigned handles_unknown_segments:1;