at 24.11-pre 66 lines 2.1 kB view raw
1From 63b1c7332bee6080bffecf9ce9d75ff15d799166 Mon Sep 17 00:00:00 2001 2From: Natanael Copa <ncopa@alpinelinux.org> 3Date: Wed, 16 Nov 2022 10:42:39 +0100 4Subject: [PATCH] fix stdio usage 5 6--- 7 lib/commands/toolcontext.c | 4 ++-- 8 tools/lvmcmdline.c | 6 +++--- 9 2 files changed, 5 insertions(+), 5 deletions(-) 10 11diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c 12index b630554a9..f20080d18 100644 13--- a/lib/commands/toolcontext.c 14+++ b/lib/commands/toolcontext.c 15@@ -1667,7 +1667,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd, 16 /* FIXME Make this configurable? */ 17 reset_lvm_errno(1); 18 19-#ifndef VALGRIND_POOL 20+#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 21 /* Set in/out stream buffering before glibc */ 22 if (set_buffering 23 #ifdef SYS_gettid 24@@ -2045,7 +2045,7 @@ void destroy_toolcontext(struct cmd_context *cmd) 25 dm_hash_destroy(cmd->cft_def_hash); 26 27 dm_device_list_destroy(&cmd->cache_dm_devs); 28-#ifndef VALGRIND_POOL 29+#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 30 if (cmd->linebuffer) { 31 /* Reset stream buffering to defaults */ 32 if (is_valid_fd(STDIN_FILENO) && 33diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c 34index a5bb6a5c5..0ebfa375c 100644 35--- a/tools/lvmcmdline.c 36+++ b/tools/lvmcmdline.c 37@@ -3422,7 +3422,7 @@ static int _check_standard_fds(void) 38 int err = is_valid_fd(STDERR_FILENO); 39 40 if (!is_valid_fd(STDIN_FILENO) && 41- !(stdin = fopen(_PATH_DEVNULL, "r"))) { 42+ !freopen(_PATH_DEVNULL, "r", stdin)) { 43 if (err) 44 perror("stdin stream open"); 45 else 46@@ -3432,7 +3432,7 @@ static int _check_standard_fds(void) 47 } 48 49 if (!is_valid_fd(STDOUT_FILENO) && 50- !(stdout = fopen(_PATH_DEVNULL, "w"))) { 51+ !freopen(_PATH_DEVNULL, "w", stdout)) { 52 if (err) 53 perror("stdout stream open"); 54 /* else no stdout */ 55@@ -3440,7 +3440,7 @@ static int _check_standard_fds(void) 56 } 57 58 if (!is_valid_fd(STDERR_FILENO) && 59- !(stderr = fopen(_PATH_DEVNULL, "w"))) { 60+ !freopen(_PATH_DEVNULL, "w", stderr)) { 61 printf("stderr stream open: %s\n", 62 strerror(errno)); 63 return 0; 64-- 652.38.1 66