From patchwork Sun Mar 20 17:11:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553205 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp887794mag; Sun, 20 Mar 2022 10:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqIS06i3Z2JTwbRzeEdvGO0gYo+1xUmPB2mIQc22BHVp9xPQPy5SU8TsFgatUUH95y7Fkg X-Received: by 2002:ad4:5dcb:0:b0:43f:c947:bf13 with SMTP id m11-20020ad45dcb000000b0043fc947bf13mr13840789qvh.22.1647798153989; Sun, 20 Mar 2022 10:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798153; cv=none; d=google.com; s=arc-20160816; b=dqeP7aQLCOYHt8VhheOZh4D0NBYzpszYclyAagyej9BNCktN1d+ASRXE+TrX4p9zHO 8peFnySUeObhgOKCmUD2uIMbm7nITmG9xkLh9ZTIFZ56qfJK/CA7y4DJeKLLdjLzK/8i l0J0m3gOM3O7E0AKYzjjlSqpMNdkPSvB8TehtJx0dOolNnWTBubjeCp9tDGBqOuAO2bh ZR0D9NMO1q9kIT02qNSFGONZBnMo5yYs+4KUGXjQBoc0n24AoUeanFdQ2q2uIKT+SzDe 5sM5u/XSCyd+AopatRyqGDFQuDGERimgKEu6NZPn4wSLKSPzQY0OGeOjIabWBn6Mhzf9 qUMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=U+tnTWIyiA7uFVWOo5QjiwIMxSwOAEykfkLAIQjlUEWua1dcHRpO6eKyHviRog8k5T STLP8WTkF/9ZtLET7pcsC8pl+QQqIv7qgC6UyeVu8uH+5fAtX3vQhTIhkwPfX4Cs1TF6 TTk38alQ/5kIisLoCByXCzen4Ewd1V0geNagMvlQT433z8/6L0QWcZYMF3lXiCyZgg6/ 6Dd+9Mz0FiUDcidef5UkSbl2pY2myMfHgVpC6Dm9f9M6p0PyRQCh5SswQVbm+jsUNYlo UeC6W05WxcDaf7Hq2kXiekUoKITjz7oj7A4KKNKOXroxOmycu/MVI7BnJkV5WBvufuLy eIwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/shiz6q"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h22-20020a05620a401600b0067e4be237f0si1475426qko.53.2022.03.20.10.42.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/shiz6q"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzZZ-0006ik-Hw for patch@linaro.org; Sun, 20 Mar 2022 13:42:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz68-0000TM-W7 for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:11 -0400 Received: from [2607:f8b0:4864:20::531] (port=37783 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz67-0003WJ-Ae for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:08 -0400 Received: by mail-pg1-x531.google.com with SMTP id bc27so8737071pgb.4 for ; Sun, 20 Mar 2022 10:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=B/shiz6qIymYhuvpj6wTahnrzdecbRNJ+ZyCC4mKOhd73lbUjNyp3v5htkzLKYMpWN LvSLdaU/Xvbd+QZr+7uVZvNj1Y4c3QJIRGruq2fWYjkwCwlsNjIoPyTdFt43RUKP0/2G Ju+p2iVUIVmUIYjAZa7yNXPFKLNyDq0ClJcQoLlWAwBMe1NVbi6Ej5Mb7ntHIe31uhTt hIy8g3PRQMQCO/hW9UH1uJgpYfkHOBNWtD09yfRtVtFwR4qpl83+r+iwNzfl6BEKFcyn DY1/MKnDK2xukst25SVKYk+8Np2FhIDRv8DeLwl5CtmTrv2xQs21Bll0kOLVu0tQjRgb Ct+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gCBSdMHIZY9oTeXD1kIq/kpHPvmFkpcjsrAAZS31tWY=; b=2O2QAI1X1tTlo/jdXgFv15oMKPPPfVq3ntZiEx3/WAKvTzIEOmMsQPJ8jLSk31idT2 N0f0BI7ifrok59JjIrUxMolO83RD2/NZ63oCvZT4MyIEyWaxsFXpcCh90fI+sgWouIjp dnKFklA+l85AcJXhpr6TjY2pDjYhq1tIEuHra6gKaPSg85ylsxRr016i2j2ag6oNzOgo 3+oVFu1aMRbThY00PzD/PYJ7GpQ77VT6mMFhT8c+WIgR7cn82eTySu7UQ+kr91gyAAyt Q7/KwldOysOFvyR7ZJLehNwt/Gzff8T9KdAinCJ1UbPWIjmhUzv4fRR6E/UnPjDdEk00 W89g== X-Gm-Message-State: AOAM533RXVTtP7B5iMh8ahwDTYHNZZpvDgiDMkQtQ70upkSIT+U+JK07 ZCtY2DXfPKgDHV3I5ViuYAJwZmfq0G7uyQ== X-Received: by 2002:a63:1223:0:b0:381:32e6:e56b with SMTP id h35-20020a631223000000b0038132e6e56bmr15007259pgl.375.1647796326031; Sun, 20 Mar 2022 10:12:06 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:12:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 32/36] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Sun, 20 Mar 2022 10:11:31 -0700 Message-Id: <20220320171135.2704502-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Only call is_daemonized once. We require the result on all paths after this point. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/log.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/log.c b/util/log.c index 42b13e6bf1..f1f6d09c90 100644 --- a/util/log.c +++ b/util/log.c @@ -132,6 +132,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, int log_flags, Error **errp) { bool need_to_open_file; + bool daemonized; QemuLogFile *logfile; QEMU_LOCK_GUARD(&global_mutex); @@ -187,7 +188,8 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, * or to a file (if there is a filename). * If we are daemonized, we will only log if there is a filename. */ - need_to_open_file = log_flags && (!is_daemonized() || filename); + daemonized = is_daemonized(); + need_to_open_file = log_flags && (!daemonized || filename); if (logfile && !need_to_open_file) { qatomic_rcu_set(&global_file, NULL); @@ -205,7 +207,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, return; } /* In case we are a daemon redirect stderr to logfile */ - if (is_daemonized()) { + if (daemonized) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); /* This will skip closing logfile in qemu_logfile_free. */ @@ -213,7 +215,7 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, } } else { /* Default to stderr if no log file specified */ - assert(!is_daemonized()); + assert(!daemonized); fd = stderr; }