From patchwork Wed Jul 31 14:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 815654 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp773399wrs; Wed, 31 Jul 2024 07:37:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVK2bIUPmG+2w7h5VPszs8lWld48qfoAHeuQkI8/qsucn7a5MBiQwiEGcQ+ysdaeGjSOyKLVZDmw+XvGIM+i71d X-Google-Smtp-Source: AGHT+IEri/uRmKaE7rQH7gQ3RTlB/aBgxgV78yTTpT3zjZX2cT5gDCmTA9RxsvB3qXG4SFrC7lNQ X-Received: by 2002:ad4:5ca9:0:b0:6b5:4125:415d with SMTP id 6a1803df08f44-6bb55a17157mr180024436d6.13.1722436679350; Wed, 31 Jul 2024 07:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722436679; cv=none; d=google.com; s=arc-20160816; b=KRhMVB/u/TXxFtlQlxbq99650TpCKBBtRG/PxTod3LC7jOVkayvXvTKCrWdluuxwGg txNSWf6obr25q4QY2ZTTkpq3TkxnOI0XAa4sM6UhZplb+/UEZWc6+vvklfXeuP1B85aT pYhLdj64NmsH2dNQtTNz1P63KxzfDz7MJ/E5XfSad1FqVPu/gMPNY3+W5pFjVcSJKWa4 twEvgmHuC0GNVmCl7/qXjJOrscdaqp96KavRKLpi4orYcJoaeLcVQAEr5TyR6kARpOaf ekiIeh9jk0HvsJsy/R6JowIMznzMbKJTU/tJu7aFhqGYpC27nuBGciJh1QzLoYg5fXPL e9hw== 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=mqmrBtYb8ViR13sxNlTUjriTArU/8ikLrSiXBCb4+9Q=; fh=5quBhmNe3tsEAdid5ZAgwbHv9gtP/oew6yvM24yBrbo=; b=SmM5wvaAnF/nxr7nzvuNNB9nocmSfzf83incURe+DEFBZHa9KbxWQpXtkhJpSKoT/C WSa6R21Sf1//22qGHVQIGPSJsr1ThCmqrt7oDQoA4QPPo5mlsVnfIh3hQnBCKxbCoqje orgOL4GvVqvPzeLItWrNbkd09yxKxrrZd4ALmZ4Gk1DkgqOMSqIWtgcsQ7y1QeRHD88n V57hXf6cnCVbVyFbDmYmOphlziFPKDAahV8kkKZz1wN7IRcWcOHuBCtWWcDh/D0uId9p sHAP4j0PALgsqIvRoLeU/wXlGEcM5EAyBHF4lJDlwfM0I22VhEF8xUwdyDBqyYZhzWhS tVfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P0QOKp5f; 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 6a1803df08f44-6bb3fa85eaesi154101106d6.304.2024.07.31.07.37.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2024 07:37:59 -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=P0QOKp5f; 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 1sZARN-0004lR-O6; Wed, 31 Jul 2024 10:36:35 -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 1sZARH-0004VL-Vv for qemu-devel@nongnu.org; Wed, 31 Jul 2024 10:36:29 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZARD-0002eC-Nx for qemu-devel@nongnu.org; Wed, 31 Jul 2024 10:36:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so6298255e9.1 for ; Wed, 31 Jul 2024 07:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722436581; x=1723041381; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mqmrBtYb8ViR13sxNlTUjriTArU/8ikLrSiXBCb4+9Q=; b=P0QOKp5fkTNMmBU+g3UKBk1cLg8UmUMzqt++z1mf62smXFZNA0CD//fmkBYSKa/Aqs 2TY/9mxuG/MSC8zimFACc4TQ8VC4mv2Jefcd2Gy8JANM0vg1G5EFUBzODyNZkBGnVxE8 hS1GxKOJQQmIzn9G1wnwTi3Hrs59W0gmTFnfp9xiTRlhmvJNzpscGpxJT7uGoICt1R25 sTgreOWLwXK18peHomEAgB2ZvYADlpQ2SMH9EPO4Fzz4+Qk68Q1JQ2O9Xw9EBUTe6tCs SbJb3/6zavgb5QrNHcta0Bb2neWX6638obOkhHuthhE+vZHWvWODkXdFbhWjLJwguG6Q 6dEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722436581; x=1723041381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mqmrBtYb8ViR13sxNlTUjriTArU/8ikLrSiXBCb4+9Q=; b=lYwqGW9Wzbrp+lK86/Kboqm2lKR2+5NCRkHplOmcfwz49HfD1KkF8/AGr8xx/G0BiX /eluSSFYXh5JAQmPbu+m1dDXMqpVoY2NXXGpiTkgQbOgL+YhSfjBg6KlRRpRwC39BzpP YRAvPfuBkvgvXXq0tn23C8j5hcKgAS/ru2a6f65OhGxuaXf33n3cdzJALSUguxfl1YE8 0YsqmejkDR8ZQEMqUhQgrlCUC/OhO4H055UMHKGIl/2t3YzakbB0AsyK/xw+s/xYivhD +mjrfMlgmiW+Yggh8Z8N4yLamO2GqCxpFj7v+Y0Y+RXaWFWCFqtL2Gn3cyt1MZm9MoME mN2A== X-Gm-Message-State: AOJu0YygRp1KTdFUZanSzdsb0a3KvmlS09v8yXH7xaMhv4pjkKpB6xaB AGhXfzT2+gWOVS8wGxpXvsLiQfzFJEXGfr6XN7s6VvlTbz6E4sfRND4Q/VfeLejAaqK4sJc5HWr i X-Received: by 2002:a05:600c:3511:b0:426:67f9:a7d8 with SMTP id 5b1f17b1804b1-4282440e013mr41987455e9.9.1722436581281; Wed, 31 Jul 2024 07:36:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282b89a86dsm23976025e9.1.2024.07.31.07.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 07:36:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Stefan Weil , "Richard W.M. Jones" , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH 4/7] hw/ide/atapi: Be explicit that assigning to s->lcyl truncates Date: Wed, 31 Jul 2024 15:36:14 +0100 Message-Id: <20240731143617.3391947-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731143617.3391947-1-peter.maydell@linaro.org> References: <20240731143617.3391947-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 In ide_atapi_cmd_reply_end() we calculate a 16-bit size, and then assign its two halves to s->lcyl and s->hcyl like this: s->lcyl = size; s->hcyl = size >> 8; Coverity warns that the first line here can overflow the 8-bit s->lcyl variable. This is true, and in this case we're deliberately only after the low 8 bits of the value. The code is clearer to both humans and Coverity if we're explicit that we only wanted the low 8 bits, though. Signed-off-by: Peter Maydell Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf --- hw/ide/atapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index fcb6cca1573..e82959dc2d3 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -265,7 +265,7 @@ void ide_atapi_cmd_reply_end(IDEState *s) byte_count_limit--; size = byte_count_limit; } - s->lcyl = size; + s->lcyl = size & 0xff; s->hcyl = size >> 8; s->elementary_transfer_size = size; /* we cannot transmit more than one sector at a time */