From nobody Tue Feb 10 04:23:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 780B412F598; Thu, 28 Mar 2024 14:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711636305; cv=none; b=s38mZiZ3tW7fNQiTOYOW4VhvVMHsdmp3vpt/rKHC/kf4FsLknZwlxE+ScBoZ79PippCoGk1I75qO5lE6gv2Op24oIP/r0PJoTJdDRfS0iajH4IizdlWIGBAADRazxpWB5FzIc4cg7iGa5GeIc0un8UxcTXluZ5dfzbJ7ShbF76Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711636305; c=relaxed/simple; bh=P6U94BE6FHCTdl/v1oN+gzg/0SGP34DXAEXihnAEO3I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A1nUV+MAyRoF+QRv0JZ13Wa4NNOLxWvsYoe9Ll/vrTYcXX08ySADs9fgJFHdtW9hXTMtQ88jNxha7oscssneUTqSm8fca6/F1UH+CYuq0qlBYZjFTeHdoRGkcmtbZW1BS/7fzaxMwyYT1wMEHITctDlt6h6IJ+ReAc27eodp3hc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dz5xPjEt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dz5xPjEt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D19FC433F1; Thu, 28 Mar 2024 14:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711636305; bh=P6U94BE6FHCTdl/v1oN+gzg/0SGP34DXAEXihnAEO3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dz5xPjEt5VyYuoA/EUZ5hzXQNEmdtPQiJEPQIKiRkUOsl3dJ+VLdy8KmQi6j4VNH7 UyWLrfIqWtuEBxwj4eNtV0jHUM7jFg8diimwdcslOz2EbT3MRAfgmaEmwRuaY8ABGk 6kIR6c1mrdk4Vk2W9PxHF3EN/ZgpnM+JmelIXpvXSdIifuSMDlohPjCQ3NhDZ4/Gpz 1OA3c2Fmvv9eJVsH4ZuCZ7aX1gHKDPgc576+A8RORprUymUXmYkaQ8ZGglVC+gVJPC c5eKJCqL3pXda8JK1lqY94e+adEyykt962vJ5gWK/Vnp5Ei50ZuqULlKICze1BQtCk j62QouhM/AjHA== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Nathan Chancellor Cc: Arnd Bergmann , Dmitry Vyukov , Andrey Konovalov , Nick Desaulniers , Bill Wendling , Justin Stitt , Andrew Morton , kasan-dev@googlegroups.com, llvm@lists.linux.dev Subject: [PATCH 4/9] kcov: avoid clang out-of-range warning Date: Thu, 28 Mar 2024 15:30:42 +0100 Message-Id: <20240328143051.1069575-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328143051.1069575-1-arnd@kernel.org> References: <20240328143051.1069575-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The area_size is never larger than the maximum on 64-bit architectutes: kernel/kcov.c:634:29: error: result of comparison of constant 1152921504606= 846975 with expression of type '__u32' (aka 'unsigned int') is always false= [-Werror,-Wtautological-constant-out-of-range-compare] if (remote_arg->area_size > LONG_MAX / sizeof(unsigned long= )) ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The compiler can correctly optimize the check away and the code appears correct to me, so just add a cast to avoid the warning. Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt --- kernel/kcov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index f9ac2e9e460f..c3124f6d5536 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -627,7 +627,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigne= d int cmd, mode =3D kcov_get_mode(remote_arg->trace_mode); if (mode < 0) return mode; - if (remote_arg->area_size > LONG_MAX / sizeof(unsigned long)) + if ((unsigned long)remote_arg->area_size > + LONG_MAX / sizeof(unsigned long)) return -EINVAL; kcov->mode =3D mode; t->kcov =3D kcov; --=20 2.39.2