From patchwork Wed Apr 20 18:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564010 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4423585map; Wed, 20 Apr 2022 11:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX2I94DVFqzgx/FONhyD9cwLnpBdX+LAVdCibWTpLO0+m3A7rjukqm4cksE0BNDECKVwY8 X-Received: by 2002:a05:6902:103:b0:628:3eb4:a6cc with SMTP id o3-20020a056902010300b006283eb4a6ccmr21158444ybh.4.1650480210878; Wed, 20 Apr 2022 11:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480210; cv=none; d=google.com; s=arc-20160816; b=RPE3me3Eff5AcLUzUq6WzQ6NS7w+CEX6hu/sHufdb9Ivfp8cQDjkwOCkXKWvQiHMfl aFsefFjaZfNzY9Rbrpj3YK3U9fkIFut9h9uPVsDsSRhkMrXVXEK40LI7DQH1w0HjVNlR wAVlmu0ArjOc54ri9klhFoljHeOF2j4A4gnQzBSctrxRgPjU7STll6Abuf9C6mwJx5MX 8NesiS7PPAvZ3DHhKjKf0oLs+nPMti1oWh0wZSsrQ5tliSk8Fe2LeFOO54oU4XpgR8hE 529Dy5Ta5WcyOgayEJ6DkRYD72vKGWzgD7+ot0XO4dMg5ffhM+CkyuxkvT/bffJRwpl+ 785Q== 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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=IuR+3Hp/JiAcAJPWCX0dGflZaizedG8OtkjEw9EUJ7ClYb9x6OIGAposGR5lMNEVe/ MEBrpfe625oTOBjxfeA83Sn5n8MAOKM6S1kFpFEEy8dLEOS4CltdQpXU13REQX1pDSdQ O6FHoempEyVfaYSPDqAWXe5dVgP9pns5s7Gh5Oy8GLqTTgrQNdj30LS6uexjZZS/IMlS A40fktkEfs/SAO4NRLjg6a/xHv+q/rw3Uq4k1dCsJJFOJzc31UEhrxCtUnoN0im+f7Y+ P4nrr1pcCmVbYtCTXzitpjWZXUu0S8wgGy1INF2K6Qb4YeOQujtZcu4eneaHc0zeXT4a OrZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eLiEo58Y; 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 131-20020a250389000000b0064546fb1d85si788179ybd.611.2022.04.20.11.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:43:30 -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=eLiEo58Y; 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]:39094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFIY-0001I6-Dq for patch@linaro.org; Wed, 20 Apr 2022 14:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjC-0006Y9-Ey for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjB-0001Nb-0W for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:58 -0400 Received: by mail-pl1-x636.google.com with SMTP id q3so2524860plg.3 for ; Wed, 20 Apr 2022 11:06:56 -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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=eLiEo58YBAd+F7BfF6M1murFbSsCh2Ga7+QSuFrvO9joYjro79ToBkPJfpZ1QfeV9K AR4vKz+UyFKBnSyctHzRUf8pJZMhlOLETTp4yvopCEXd9CWCuUzzsHX55F6dza6o6rT8 WkzuM46Wq1YYWJD7LZ92Uxhy0KNkk07BMsUnX7BsoSiR+tO4ihEgOOzqreuXtBNWZUP4 qBdZLenY3A50QMg0PvX8ieUF6WKQe0p5sPiCSRjHpsAUmkiS5aC+UY4AkMAk8eoM8ZDY 6p9B9jH7pYzSiAH49ZUjI0glGTR44h5bhnsSalafJVNbV5KClhuZIFBr1TEgT8PcGerb HkaQ== 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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=o4Wl0MWe/8ZtYznAN+HDRVZg3T4FF0Wxs8eyREkhghO7qmPDnNRjcw2iTj0yJ3lJZf ahe4iUw5p3GqBWiK8WrDbeb8gVVqeRfYRHxf2g3gaAuKSifXGN77B8/O+8VvZcjc0vXC vr16HV79RsD9vI/WTjwOBggdA40f5vm41/fDAGRcghxHJ5JCf9VLNigiN8sqf+hy60dL FTVuG1Id6vXPMcYqmJkpaQ/0fC1YU47fXY8XvIDtNoyq8U+8zqV9TpHvidn7FfdKS9nT NEFjDlEkNvsl6yNJy/vDKnAwoL78QIb9cnB+RDq7MElTHmSfwperAejwQ/Gg8UBwPASo o3uQ== X-Gm-Message-State: AOAM532IM++dPp2yWeduglOxjNEZ+3JpnM656O/JJ2ujISyhlPBK7dLU QK/+R2K5xrWK+FrPc2rM+xjuGX7cn6EMcg== X-Received: by 2002:a17:90b:4f92:b0:1cd:3a73:3a46 with SMTP id qe18-20020a17090b4f9200b001cd3a733a46mr6001884pjb.66.1650478015737; Wed, 20 Apr 2022 11:06:55 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 35/39] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Wed, 20 Apr 2022 11:06:14 -0700 Message-Id: <20220420180618.1183855-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-36-richard.henderson@linaro.org> --- util/log.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/log.c b/util/log.c index bb201664ac..631856e231 100644 --- a/util/log.c +++ b/util/log.c @@ -123,6 +123,7 @@ static bool 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); @@ -178,7 +179,8 @@ static bool 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); @@ -196,7 +198,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, return false; } /* 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. */ @@ -204,7 +206,7 @@ static bool 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; }