From patchwork Sat Mar 26 13:25:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554389 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6456233mag; Sat, 26 Mar 2022 07:14:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDhVa4zulMcefCOTw6pk/gFo9ojy0QTkV81/Lt90tC4hTxmKdLBwzvht7uC8ZIuT9iJ9lu X-Received: by 2002:a05:622a:507:b0:2e2:3401:49e3 with SMTP id l7-20020a05622a050700b002e2340149e3mr13847923qtx.560.1648304056215; Sat, 26 Mar 2022 07:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648304056; cv=none; d=google.com; s=arc-20160816; b=Gsfz8zz5MZDSbIX3V9yFyy4oZUKNRh2e+dw0LBbNb/NHjBYrXRHVeLmL3/TJlp32+q qzc4UqwpQz9r1Y04HfKLCMdnqKmsvvIBqCOAiDXHTyD+KGk61bs/d5WGkyKZBQ9oDVKS X85iWZgG7yKEtZb6E9GJ0qwxqm3wVqS+yL+Y2Sy2yVmdb99xuIbbyuQmkwbD8fyD4h58 PcqEDzzM0Fx/Kk/+GoBIgIrJVr5aSBxwTagTXXYlMwdyMxKHrjTk3hK68DgEfSEVPm54 SzvNc9DVEeS4nEMzIQ7J0mTj7gGPybVUgvQ3i1mxjHD00OvmZpYofJrvhRzZuWUjcYFi cTEA== 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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=gHzpAfqCp5zrl9KFw8WxXRJyk7UBYF+KhhCrZdhX8TR/M94F+DY2Dcr3tHknwzQbg+ NxITWpHfnTJRTwItxtR1WgOdlsFQryZu2/ZzH+4vNL2ye3A1gSWUcw0B1Y+OPXOKcTVd Hvtf52aM/KtxKrTxSRBUdtUNm2psvWIeUHEmnzxTtXOYo9tkaTteHyFf1jPJ/TcEMXaX 1AQXajP7pBBZaB8KrjSYBkD87yloGaIalBERU/HnF4sWap7uuPt3F1E7SFmaiSnx8i/0 p98nDLK6ykOjQhUA+08d27UG+4dhD/CYCzIFLLU1+214i70jNAXo709dpdbGVQV4jcni JbRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKlD8bVa; 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 t10-20020a05620a450a00b0067e4be238dcsi3950965qkp.289.2022.03.26.07.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:14:16 -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=IKlD8bVa; 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]:50462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7BH-0000Ym-RA for patch@linaro.org; Sat, 26 Mar 2022 10:14:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6UD-0002uL-58 for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:45 -0400 Received: from [2607:f8b0:4864:20::22a] (port=33767 helo=mail-oi1-x22a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6UB-0005yu-MU for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:29:44 -0400 Received: by mail-oi1-x22a.google.com with SMTP id k10so11121935oia.0 for ; Sat, 26 Mar 2022 06:29:43 -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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=IKlD8bVa2Xe1puGxVnGrt5HiftufZ2/k0vjbvAfUVM8ff0BJmA+wnPVIVxz4OBrsmd 7LAy2v1kfhSSc40b9THPzYy8bXechskS+EpKDchFLL+XSgSSey2kFK4Yq77mmBSDbKO1 7NTMTXj6jJmUj/wWZko3+GuM6/JLXAgFZvhOSk2mXQSNB34Nzl3lSqBfZNwsAsNiFvDE UcMHtFFTKgzGVlP9X9kBYwUZOw0cTpFacO/v5jgkI57lvLWnHJAQBx40WHUsblE5OH3I SePoC4sf/P3eibo4ygpOU8MCrejIeNrWWCIUDmanjn/eP6rZanzPG1l2CKvfSL8netIp ok/g== 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=8IUyfSympPHVcXXqktu1H7rxzjIdvEh5QtmnECcsrkY=; b=FJiyzs+JeCGLH75y0CK+AzkPVZvO7z0w/IzuvX3xShVHshgjd9MD6rCL8EQHaZ21JO SDRBuvpy4Vbi/yEfOYeEN7QN2KcTFOE4ZdCu6oQM3KWw7mmfTNJyYIPNyETqrGsd+33X es7mAZ14GRmRgFGSPm9JEoOt1U9SI00zvx9yf4qVvAEDJeHj4zzqWCmqiu0iFJH+B/iH r7UA7AWp2JfUdiuYJ8dIl/3AWZ/7qZbZIdF9zLB5o+nqLY7rUEQR2RcJZPgIFYLbdMmL fKS7gCqV07Old2WPr6ZqgDs3KBrPY1MKnBDihHoNSPK4cLxan2nnGlEnSALldXtMiVfh 8EFw== X-Gm-Message-State: AOAM5304ELdRKg9+5g564Jj92YBrqkYBuNis6pglGWcSALLxrXmupOww 2k5VO7qmUfJY/5cDKKlsf1W+p5sEZy1mPjjx X-Received: by 2002:aca:b01:0:b0:2ee:bfb8:7312 with SMTP id 1-20020aca0b01000000b002eebfb87312mr7779732oil.22.1648301382714; Sat, 26 Mar 2022 06:29:42 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id s24-20020a056808209800b002da3b9bf8e0sm4394509oiw.32.2022.03.26.06.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:29:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 35/39] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Sat, 26 Mar 2022 07:25:30 -0600 Message-Id: <20220326132534.543738-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::22a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22a.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, =?utf-8?q?Philippe_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: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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; }