From patchwork Fri Jul 8 15:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588568 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp813405mab; Fri, 8 Jul 2022 09:28:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vSqHK7Jd1mkGyoacdCbXZLomiGhOYSkmytcIST6ubr34FRK9aH1qMuWRVsPywg8U2i80PH X-Received: by 2002:ae9:e21a:0:b0:6ae:fa03:479b with SMTP id c26-20020ae9e21a000000b006aefa03479bmr3046869qkc.108.1657297719888; Fri, 08 Jul 2022 09:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297719; cv=none; d=google.com; s=arc-20160816; b=AhOlwsNhDiopFGMWOrGzvWWOUmk5L3oGVzEFZn20wIUq75mRYy1/5zNoCflp7bhDYo Jt3TAsmQEFmFP1zWjKzT4E6IE2RBdmYvnFcOXpaZ3Q/zbP8wTS7lXBpkRev6YgO0zqVB tzox2Fw1czB482XGBQ8SYiqfQIR7AhjOIhyuESBT2MSDnCKxD9OmUF2dpujeohoEIPIH uj542w6ZNKzjk13o/RdhZ7XPNDbhYqrqHUn34bhCnm3QH2HLu0JGw9ybpgaaCBvhtx6E OKoiJQTwdrRLFg2+40adf7SxiftRdFHH78UPrN6OcayGP9OExcS3hx39MYpsNUFQRMsu 5IJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=W9clK9K4+8X5B/4DNlH9mx5SK0k7ufsF0qklyhZjD3QdhEn99hKXLMNTsP6BnpWe56 9DiCzyOBlsN+1Np+b40CJ61Aun0bUWhbNzEUTFETiMNkTNAMmVGKeoySvsgoXoDS1Meo CclqZzgyVQoWqYPscgBKJpeBrJ5Ea38BNz7u3MaTgKMN+IIWraMrQnzpEkM72gxwZZwL tXbrBoyMiVi2efYYBEDZ6U5Y7FCivMhAMAvrZbB8++84WagjAlRfAiD8t320vEWbGX4h 1/TggR7Z5HGKJE/RuFe1f2csqCUZpOHZRHWaI1A4X5sSvV8D/il6dmWYb+V5TlVrJja6 kYHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j99DO5x8; 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 fq8-20020a056214258800b004702c38f4casi26805610qvb.234.2022.07.08.09.28.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 09:28:39 -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=j99DO5x8; 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]:54456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qqN-0001lw-Fc for patch@linaro.org; Fri, 08 Jul 2022 12:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9qCJ-0003wr-Tc for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:15 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:50772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9qCI-0002Mv-6W for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:47:15 -0400 Received: by mail-pj1-x102e.google.com with SMTP id a15so11634223pjs.0 for ; Fri, 08 Jul 2022 08:47:13 -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=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=j99DO5x8nS4GWZgN7/isM8hAHv2aQ/GA/Ij2mh7eapSfu61OmoN7atzL7BbqmhY00O KrhP2DoYzTl3/b5I011Xo/8pNm5bJZAjvbHQxGOEY/ky39O3gBPFsREaavJmssmQCnw2 9wZYv0apGloRI0uTNcbZVuvGYWocwiuq1UqV/Dx5yJLf30g6vwZeTyl94PfG7ORonzj4 qL5KQ1Wsn7eTgf5T53NXxzGtJQTn3VXdc9rao4LQTpfmauNq5XWlzRrkxya39qwfZHNE mY6YfpZU2+DDhKr3wPHGVkIx7KDXB1U1GwuBeFsYkufJTtJfoW7uOQsk1YbbsoFW/8Uz 6Apw== 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=Lcnb+cJ/wyqPfEDRcfJ9HbxKsjqemLvSn/xAJtNX7ic=; b=470DCiE7J5GUwbvx47uUzYB1XcAXqqrbP+wNxCfea1rzRDF13SwuaDfjnq9st00dOP pGnIVdwCGRsS+HLvPWlCYT3HvIjBx6CsLW768lLj+MiQCk8Qy6VRzfKhxeY2gi5rB8So ysRtm1z+VS3KIB22hvA95VAWuLtqkXTc4/Ffxf8hOe8L8X0TnqG5hXAIHZHY2XgL58Tx zZyuVn/QtiPqrfSL6bfUoc/+QqJQgNI4332n9UsoT1MeKy3dZGzLqkMyOj+3eODEZIPQ d7vR+k2SYDDLKqOQC2zIBGiX/Kbje0G2IM+SY3uOg948E7Ot32GHsqEGkabeyrM68hgt hLvQ== X-Gm-Message-State: AJIora8SEWwVON8/gHAgtOSjs0DNwnbQapz8xeIVEgivxARKy5ZYuo2+ tPs196R/txizFJO8BPJw1mzpmES7e41oM8Ov X-Received: by 2002:a17:90b:1b49:b0:1ec:a756:edc with SMTP id nv9-20020a17090b1b4900b001eca7560edcmr502319pjb.200.1657295232878; Fri, 08 Jul 2022 08:47:12 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a390300b001ef81bac701sm1782089pjb.42.2022.07.08.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:47:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [RISU PATCH v4 02/29] Unify master_fd and apprentice_fd to comm_fd Date: Fri, 8 Jul 2022 21:16:33 +0530 Message-Id: <20220708154700.18682-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708154700.18682-1-richard.henderson@linaro.org> References: <20220708154700.18682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Any one invocation cannot be both master and apprentice. Let's use only one variable for the file descriptor. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/risu.c b/risu.c index 79b1092..059348f 100644 --- a/risu.c +++ b/risu.c @@ -30,7 +30,7 @@ void *memblock; -int apprentice_fd, master_fd; +static int comm_fd; bool trace; size_t signal_count; @@ -50,7 +50,7 @@ sigjmp_buf jmpbuf; int read_sock(void *ptr, size_t bytes) { - return recv_data_pkt(master_fd, ptr, bytes); + return recv_data_pkt(comm_fd, ptr, bytes); } int write_trace(void *ptr, size_t bytes) @@ -58,9 +58,9 @@ int write_trace(void *ptr, size_t bytes) size_t res; #ifdef HAVE_ZLIB - if (master_fd == STDOUT_FILENO) { + if (comm_fd == STDOUT_FILENO) { #endif - res = write(master_fd, ptr, bytes); + res = write(comm_fd, ptr, bytes); #ifdef HAVE_ZLIB } else { res = gzwrite(gz_trace_file, ptr, bytes); @@ -71,14 +71,14 @@ int write_trace(void *ptr, size_t bytes) void respond_sock(int r) { - send_response_byte(master_fd, r); + send_response_byte(comm_fd, r); } /* Apprentice function */ int write_sock(void *ptr, size_t bytes) { - return send_data_pkt(apprentice_fd, ptr, bytes); + return send_data_pkt(comm_fd, ptr, bytes); } int read_trace(void *ptr, size_t bytes) @@ -86,9 +86,9 @@ int read_trace(void *ptr, size_t bytes) size_t res; #ifdef HAVE_ZLIB - if (apprentice_fd == STDIN_FILENO) { + if (comm_fd == STDIN_FILENO) { #endif - res = read(apprentice_fd, ptr, bytes); + res = read(comm_fd, ptr, bytes); #ifdef HAVE_ZLIB } else { res = gzread(gz_trace_file, ptr, bytes); @@ -218,11 +218,11 @@ int master(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB - if (trace && master_fd != STDOUT_FILENO) { + if (trace && comm_fd != STDOUT_FILENO) { gzclose(gz_trace_file); } #endif - close(master_fd); + close(comm_fd); if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); @@ -244,11 +244,11 @@ int apprentice(void) { if (sigsetjmp(jmpbuf, 1)) { #ifdef HAVE_ZLIB - if (trace && apprentice_fd != STDIN_FILENO) { + if (trace && comm_fd != STDIN_FILENO) { gzclose(gz_trace_file); } #endif - close(apprentice_fd); + close(comm_fd); fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); return report_match_status(true); } @@ -375,31 +375,31 @@ int main(int argc, char **argv) if (ismaster) { if (trace) { if (strcmp(trace_fn, "-") == 0) { - master_fd = STDOUT_FILENO; + comm_fd = STDOUT_FILENO; } else { - master_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); + comm_fd = open(trace_fn, O_WRONLY | O_CREAT, S_IRWXU); #ifdef HAVE_ZLIB - gz_trace_file = gzdopen(master_fd, "wb9"); + gz_trace_file = gzdopen(comm_fd, "wb9"); #endif } } else { fprintf(stderr, "master port %d\n", port); - master_fd = master_connect(port); + comm_fd = master_connect(port); } return master(); } else { if (trace) { if (strcmp(trace_fn, "-") == 0) { - apprentice_fd = STDIN_FILENO; + comm_fd = STDIN_FILENO; } else { - apprentice_fd = open(trace_fn, O_RDONLY); + comm_fd = open(trace_fn, O_RDONLY); #ifdef HAVE_ZLIB - gz_trace_file = gzdopen(apprentice_fd, "rb"); + gz_trace_file = gzdopen(comm_fd, "rb"); #endif } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - apprentice_fd = apprentice_connect(hostname, port); + comm_fd = apprentice_connect(hostname, port); } return apprentice(); }