From patchwork Tue Jul 23 15:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 813955 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2365040wro; Tue, 23 Jul 2024 08:11:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUWAM5QXeS1ZPJJUY487gtj5OrKypJQQtRMcgNAU8IbkRTgJqjqd2ctGRDxd7XAadt+wyGpYWqY5d/8gojs37FH X-Google-Smtp-Source: AGHT+IGANUkPCp5i/yxPXAzShdxc/TzbDZS5drLyd6ZOph6f8mYZ8Oxu1MKMlWWeLFxmy/Br8vY7 X-Received: by 2002:a05:6871:824:b0:25e:14e9:10c9 with SMTP id 586e51a60fabf-261213255e1mr10956227fac.6.1721747470850; Tue, 23 Jul 2024 08:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721747470; cv=none; d=google.com; s=arc-20160816; b=t8lKMDv28bTf+alm+DRot9eQmaCvP7N6CgV3mvUuI3yevoKtMvWXtS7qnN1WRf0ACY BOMLM7cbyAq/gpZ6VgosHTrhYQX/hCQAbWNBUiGqD7Stp+C8VKk2HkCRQg7OzACSBAT0 r15MRlwDdNgO6wjA13IbfAZ4KSOmJHscz6zRvPTrZeX1ZY+cCUTouVYrJnppWXyNbVHC Ir7M7U6nFKnn3huXTffNxMdXNG8lRbIvT3LneiJss3fZr+TO1Gv5eSR57RKEeBKYdlxc UiLQVyHp8bD8RNRDNPnFrzScUq5lt9tmdJwkonWhhoxsSeCmNQ8eVrern9iJhBwlJCto gphw== 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=E7tA8acdK/9lyUFqq7vEXa8PgCnGp+reT1bghch5Ilc=; fh=AviQk2djdIC6erHNV64fPAlsYrBm9AENj/pCljp3+TU=; b=gYMj5Hi/EVRuCl/3CYmb4Ytt0Qbtciwn5DBhLPJVkFdJ4QBHppJPjZhKQ+maz+vu4A JkXsvJ5fHmy8CZckc5e9oX7A8t+M3vWF4969R+HF+zmOtPyQsUFDkGMYAi8WiNQC7vDU w7XPNRSoWH5csrDwmqFuhRGNUMp792+pN64yfrwpctr2CAead1U4sir7BKV3vDI0cFVc irQ4QCwnvUBMmwaKkxa0xGBLkAokBTKC409uftKFmQ7CBBtYtkbKdt6N/6wJICd3fmqp kIvbM5judDsjnZ1qEuaj0Da8oJIIe361CYjWfJpgPylq9Gu2x2XwHL6DojbfMWJP/43V MXtA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TuX2Wo0K; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19906e644si1028399485a.481.2024.07.23.08.11.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 08:11:10 -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=TuX2Wo0K; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWHA9-0000kY-J6; Tue, 23 Jul 2024 11:10:49 -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 1sWHA7-0000ar-4o for qemu-devel@nongnu.org; Tue, 23 Jul 2024 11:10:47 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWHA5-0001Cv-It for qemu-devel@nongnu.org; Tue, 23 Jul 2024 11:10:46 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-427d2cc1c4eso40102905e9.1 for ; Tue, 23 Jul 2024 08:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721747444; x=1722352244; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=E7tA8acdK/9lyUFqq7vEXa8PgCnGp+reT1bghch5Ilc=; b=TuX2Wo0K3+uuTuveRLnqfdhf66FlgTtRS6udS49Q+xuXum8VlmRxBvnzAmffsu7yoB rrI5QqJXEwRVs9o6wzktz+l2Vu1V3g6KRUfG/1QNj/2YPaw97pH25ud8CL3fMYNRpVq1 3o5mXdTHVQ3e4VgsALqAg2GvJtC+P7K1hTI3tVHb7z/D1BQy783DLy944TicTo9gelNj DBIWA95reoNBmgrEW4RMU0I/xPuntsyjUM8ZRwLfdZjtK+R3TWPGZcN2WZWurlmLBjBY fxVXNo8kWw6UfGe40pY+EM8V/WPMWOyu/PGqRfURsh+I7b9P2ykog+/PNKgJGWCnEILB +GtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721747444; x=1722352244; 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=E7tA8acdK/9lyUFqq7vEXa8PgCnGp+reT1bghch5Ilc=; b=UXxohRbu773zdO0cHuokTTP1MBZLnq0xZkG52tExHXQAGqjWvUVPGfQPY6a1tev4pX ZrZ5hGhVo0mphsYKLOwQuX4w2wBpleAfzg8ZrCRRPhMV+YKAnT7LtdzesW97DCp+XrMO 2COOQ0yYkoFQEpOBmYCdFY7dIbk9ZMKPqBSTmmS94vmsjOPKOgWjZghcVy6cMIj7rh7l WPppLttPMpHevDY9djsf7uk0v27wM68mgT2VMH35bWTmbjrIiO/1U4eIjKS03psH1aK4 KM0/YSOvu/sQkWQn2MpyJ7fC6Zk/llW7p9ObA732ptfnVy+IO1A7hKz5umXjEWMHWW8H V8dQ== X-Gm-Message-State: AOJu0YztVaJ7co45eYC8LBSra8MJDnTxyJz+6fR42ALMVbTooNjYypXr kE4MuQ/0JC+Ua9Mt6EdLZYiWcsMJ/6OUkwkqTFJYndk1RojYoz4Z8BNaqDJ5rki5cxwnFZMnPEt / X-Received: by 2002:a05:600c:4f89:b0:426:58ca:5a3 with SMTP id 5b1f17b1804b1-427ed059c63mr22441005e9.30.1721747443827; Tue, 23 Jul 2024 08:10:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427e5803bb0sm93113395e9.45.2024.07.23.08.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 08:10:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Bastian Koppelmann Subject: [PATCH] target/tricore: Use unsigned types for bitops in helper_eq_b() Date: Tue, 23 Jul 2024 16:10:42 +0100 Message-Id: <20240723151042.1396610-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::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 points out that in helper_eq_b() we have an int32_t 'msk' and we end up shifting into its sign bit. This is OK for QEMU because we use -fwrapv to give this well defined semantics, but when you look at what this function is doing it's doing bit operations, so we should be using an unsigned variable anyway. This also matches the return type of the function. Make 'ret' and 'msk' uint32_t. Resolves: Coverity CID 1547758 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/tricore/op_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index ba9c4444b39..a0d5a0da1df 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -1505,8 +1505,8 @@ uint32_t helper_sub_h(CPUTriCoreState *env, target_ulong r1, target_ulong r2) uint32_t helper_eq_b(target_ulong r1, target_ulong r2) { - int32_t ret; - int32_t i, msk; + uint32_t ret, msk; + int32_t i; ret = 0; msk = 0xff;