From 4de14e2723139b488e69251e500f022f50f983e1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 10 Apr 2024 13:11:11 +0200 Subject: [PATCH] lib: Use fdopen_keepfd() Signed-off-by: Volker Lendecke Reviewed-by: Martin Schwenke --- source3/lib/tallocmsg.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/source3/lib/tallocmsg.c b/source3/lib/tallocmsg.c index da05357a4df..a5c6603a92b 100644 --- a/source3/lib/tallocmsg.c +++ b/source3/lib/tallocmsg.c @@ -21,11 +21,11 @@ #include "source3/lib/tallocmsg.h" #include "lib/util/talloc_report_printf.h" #include "lib/util/debug.h" +#include "lib/util/util_file.h" static bool pool_usage_filter(struct messaging_rec *rec, void *private_data) { FILE *f = NULL; - int fd; if (rec->msg_type != MSG_REQ_POOL_USAGE) { return false; @@ -38,18 +38,9 @@ static bool pool_usage_filter(struct messaging_rec *rec, void *private_data) return false; } - fd = dup(rec->fds[0]); - if (fd == -1) { - DBG_DEBUG("dup(%"PRIi64") failed: %s\n", - rec->fds[0], - strerror(errno)); - return false; - } - - f = fdopen(fd, "w"); + f = fdopen_keepfd(rec->fds[0], "w"); if (f == NULL) { DBG_DEBUG("fdopen failed: %s\n", strerror(errno)); - close(fd); return false; }