From patchwork Thu Apr 6 15:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 670762 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp928338wrt; Thu, 6 Apr 2023 09:00:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YOHRLAd7bU4sBCTBmaOoOQwtJyDcYPR9OE7dn8n/viR6iX+MCKFyI/QCSoGeRDTA3fAEq7 X-Received: by 2002:a05:622a:8c:b0:3db:575e:613a with SMTP id o12-20020a05622a008c00b003db575e613amr11386397qtw.23.1680796816965; Thu, 06 Apr 2023 09:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680796816; cv=none; d=google.com; s=arc-20160816; b=vSLtO2UtUJTlrLsMZDNDHo9sghnSuxt68oSAFYqq/MiiIJIUttWlveBcEZPdMgMAjj 8ML7Csp/rcj66OATdPTAjaKmOQA1piDCKzq5q/qlXgxvIOpkCM4BxPQhLtjslxu1suTY Rh7ETU2MlmzzR7E4RwGXYqrBtfvdU6i1Hvy7MzPVrCC8ZcTp/qJhHn8vfN4WJq2pXIDo MTynyZfM5PjBow9TK2/5NCU3Jnt1Ies4K6pmCuxhK/0U4b9wiTkROt8Uh36RvObkDd5I f1bAD0eNb1gQI4+7EdMm34mWl0ePO+/FFlw7PHAUGiJmXF6xL3lJSs2MgvpVyM+nCHvj 01GQ== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=Ghy81EekBAOnqDStLjJy01CkdBOBv7GWVAE81d+KVFE=; b=IXHtoU/g3WuJsbWIjaRRVxQPEv0W5229lDRbocZKKjbeDgPleI4Imw0OyDG+n5QHxs 0necc/kIxs9hjSwTM2KeKA1FPGyMZdoYBfLXWC7LTrpnfAayY6AH/kSKpqihN1+aL2kX NSBgBUiCs0PKfsp62d4wdL4Zj13OUc6XZuuCGUZD+6+dnzdpjqdhx0Ckq3kBK7a/Bsqk SvC8DMBorMMcxDhsQTePQMdmFAweLKXUWjiNIqNXvd9UyN2yKqoTcbqmFcNORPg9v5RL THcIbHY0d2CI/jb2Awts8GkV8bu4e1vQh/9S2Ul8WT/5qltC6IyaVazTHxxmHYoHlfyB wq5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K/K4nSGP"; 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 f13-20020a05622a104d00b003d9d35acac3si1155682qte.625.2023.04.06.09.00.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Apr 2023 09:00: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="K/K4nSGP"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkS1h-0002ll-7z; Thu, 06 Apr 2023 11:59:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkS1e-0002lI-VH for qemu-devel@nongnu.org; Thu, 06 Apr 2023 11:59:50 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkS1d-0003R6-5K for qemu-devel@nongnu.org; Thu, 06 Apr 2023 11:59:50 -0400 Received: by mail-wm1-x32a.google.com with SMTP id o32so22836098wms.1 for ; Thu, 06 Apr 2023 08:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680796787; x=1683388787; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ghy81EekBAOnqDStLjJy01CkdBOBv7GWVAE81d+KVFE=; b=K/K4nSGP7NG73a3AXNhCeeYmGZ2tvcDs9f3lQVM+4J70HoP7RKEqsZ70wT4W3E12BD sR3VLqnzX3IzcfN/z3f1feADNahSAmZMMEXZ6sjsya47w5aKKWiXIeRwpFCdXyPYGHsu RalGiJoZwZkCVsk2rKJgzLASkQzZTF3+1MfdEDecjV+BnhKmWy3ifp0+ZfqERA+rMjSs EbiMF4K4AmzhkBzQUStuuMn/Fuc/bMAoWOlTBmbWjG4H/4p9WeCsA0qp/DmpMmHTL/rw g23HX6DSIt9K8IeLiHeeW7JkZQwuS/kxlJyxMYrAQ5Fzh8oJL5c2LZtniWk5ecn5mAya qrsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680796787; x=1683388787; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ghy81EekBAOnqDStLjJy01CkdBOBv7GWVAE81d+KVFE=; b=RyNVQTN0QxlbRvVgE0QsaqJr2C58jxmh/weIY5Pa2j8y7azUQsrx7oxRF3TnWMUxB1 ks29A0lkCofUAygAzatEvCaIUOoQayXfYTNjnZHXcDy4TkQntpiv0ysrnuvAZRhfGFC6 KSMueegbel2ileyl5tKXRmrHv7ZbdW9uCmtAzjgIxw8UQDcAmwKWAz8wJ7wEPGJYuanb Ui/VkcLza4s5x7GNLkQFQKLTESEelseuddZ7Q0oELIbDkeR6ntij7cyidHU1VF7Sv8O3 buwvWbugpDDTXL5XDHA9+90usJhKAQVN2GORIp2oublEG97ugPnFmqkFOmoLEb6cwoHE Q5hA== X-Gm-Message-State: AAQBX9cCqvstY75KQz8ZJgHn5YBwHGE9TwLuHbAdqo++/MUbrlSvk8F9 PRBL42vNxRCn6rGvsBxaM7ss9wozlf7i4V12Ct4= X-Received: by 2002:a7b:cb97:0:b0:3ed:5d41:f9a7 with SMTP id m23-20020a7bcb97000000b003ed5d41f9a7mr8210661wmi.2.1680796787397; Thu, 06 Apr 2023 08:59:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o22-20020a05600c511600b003ef5bb63f13sm5773390wms.10.2023.04.06.08.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 08:59:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Eduardo Habkost Subject: [PATCH] target/i386: Avoid unreachable variable declaration in mmu_translate() Date: Thu, 6 Apr 2023 16:59:46 +0100 Message-Id: <20230406155946.3362077-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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 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-bounces+patch=linaro.org@nongnu.org Coverity complains (CID 1507880) that the declaration "int error_code;" in mmu_translate() is unreachable code. Since this is only a declaration, this isn't actually a bug, but: * it's a bear-trap for future changes, because if it was changed to include an initialization 'int error_code = foo;' then the initialization wouldn't actually happen (being dead code) * it's against our coding style, which wants declarations to be at the start of blocks * it means that anybody reading the code has to go and look up exactly what the C rules are for skipping over variable declarations using a goto Move the declaration to the top of the function. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- target/i386/tcg/sysemu/excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c index e87f90dbe3c..b5f0abffa3d 100644 --- a/target/i386/tcg/sysemu/excp_helper.c +++ b/target/i386/tcg/sysemu/excp_helper.c @@ -147,6 +147,7 @@ static bool mmu_translate(CPUX86State *env, const TranslateParams *in, hwaddr pte_addr, paddr; uint32_t pkr; int page_size; + int error_code; restart_all: rsvd_mask = ~MAKE_64BIT_MASK(0, env_archcpu(env)->phys_bits); @@ -467,7 +468,6 @@ do_check_protect_pse36: out->page_size = page_size; return true; - int error_code; do_fault_rsvd: error_code = PG_ERROR_RSVD_MASK; goto do_fault_cont;