From nobody Tue Feb 10 14:33:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722436679; cv=none; d=zohomail.com; s=zohoarc; b=UCqkbB0N15h3YiPraQZWz/4OUJPN+pcCVCBe1321W5s1BZLia0O4rcjVPrS8gkEOsO3O/Os4shp6wcLyMA783b3NVNe1dwmCCtwR/Qk55i85Nm4KGhJbULIQeRJHlD2cUsBfll8i1FpA8SYE96cyizxwKKrRbPGFL9DhTnk8F0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722436679; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mqmrBtYb8ViR13sxNlTUjriTArU/8ikLrSiXBCb4+9Q=; b=kFrTPehuRC2as3GV+2b7/Rw645RFrUylfkZUP3bP+U0gfyOrm3tfIU2WUwhG1F5dCES96oVFjy3Dh31MRUJOynAh6/i1dlBklQnpkNLv+Ctg4oYXjRanqocwR2ouDJsFlD5hHb0fhbCRXX7GYZxBjJoy2r4fBvk+BKijFk9EL6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722436679772655.2181741042707; Wed, 31 Jul 2024 07:37:59 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEtiVN0DM+ve/n9wSITlXRKO/G5kfu3YXSne2swaTnggBpLftRGrMeemDnnl8zRtp/caLxj0w== 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) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722436680238116600 Content-Type: text/plain; charset="utf-8" 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 =3D size; s->hcyl =3D 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: Kevin Wolf Reviewed-by: Markus Armbruster --- 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 =3D byte_count_limit; } - s->lcyl =3D size; + s->lcyl =3D size & 0xff; s->hcyl =3D size >> 8; s->elementary_transfer_size =3D size; /* we cannot transmit more than one sector at a time */ --=20 2.34.1