Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp139113rdb; Mon, 15 Jan 2024 15:32:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy9j+brepm7SE71escKzNXvRcMLY2bNGGITwRmMe6Ymm3LqduN9x5Wb6bJUrnoMAlAsS1I X-Received: by 2002:a05:6a00:ac3:b0:6db:76c3:ef0 with SMTP id c3-20020a056a000ac300b006db76c30ef0mr1904434pfl.19.1705361556305; Mon, 15 Jan 2024 15:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705361556; cv=none; d=google.com; s=arc-20160816; b=CJS34YrcNTuunpMH6FT4n1nEhidTyIXkhmYr3495o5hCIvVjcUv82K54MMM21+Z39a 43fYpbq6ta1t5U9gGPdDSQeH2NhH1i/3GdMTCJEUnWmjzuLWI4edvFLoaCP7SICuQGhA H3AoZ7ksChdLR4J9VyDfxxDzmjjwzNXK7oNZi1o68/WNDRMmE3uboYqrHjHh1SWw0+Bl wp0ytWdJ2tFDrxTxT9Tq8qwOeyGOYiRV5DuzlO/o9DopKDJLdE+VRUt2s40Zkd1zkvxu uw2aWfk4ECPWUu4im/Yk0/oBojw4pzmUD8s77y5D5rBajOPF1kIq09zmd4BbT1ik4PzT ziqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=rcYLWJA/d1HQ1lqzszkZIXQyIIPCI93gxuDeHJnLRAw=; fh=Z8XMWIFr901KUfWQKy8nBwHOhYOnwZ4zADGGz2FZGjc=; b=STnGH4oe/yG3u2uzf4lBpjY4Mzf3TtOQzp63FWEi/Yy8sSmxt2GBG7kWAzwQXlQWS/ fDAsysN0zjLm+XJnIVQYj/9TpwTpPcdPy5qlZmCLuZc14EXxhANx67tjrLdmlJpPjB+l OwFTKLTdhAVC+TgsEox0NATO6gvABQxGfmbg5WAt4bvx/+xqH05xmwelc7PdvHXTdQHU WrQAwx4fc2l4td7XT4Vv9hYxsCZq7Gt0dfJ+7k4QtXG2QWGeQlr0ss00X/iw5fQCidw1 Nj9Kn5SJGsLUk+sUG2rlYqHNnxCR0Gg0svvENgJhx+mVdrBJdLnZEpJRZrfVh/gkmb6W EaFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B2Vu3Tx0; spf=pass (google.com: domain of linux-kernel+bounces-26557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26557-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c6-20020a63d146000000b005be029a66d1si9862831pgj.806.2024.01.15.15.32.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 15:32:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B2Vu3Tx0; spf=pass (google.com: domain of linux-kernel+bounces-26557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26557-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F3B91281A9D for ; Mon, 15 Jan 2024 23:32:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 017D81BDD8; Mon, 15 Jan 2024 23:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B2Vu3Tx0" 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 2AE9B1B7F8; Mon, 15 Jan 2024 23:26:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 239B9C433C7; Mon, 15 Jan 2024 23:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705361174; bh=EYKfpeOjQcNy5olvIYknZHSp3uT9jDCqmH7907PblMA=; h=From:To:Cc:Subject:Date:From; b=B2Vu3Tx0Gv4bS1MVNyuI4DLC4V76pnV+up+xCp9GxE2lS3321z53xSj6OjL8msWZ2 XF/ezqeq+itcaM4kR/i4goaK9UZGKtg5lNYiDPh2sDp/M8c8WEOJE37YKwfxr0SZvV KgK9V3IqbZ3IJZhXQ6vaf9Ldcw7FODcOu87ADTXIEAZFk1h+oo78IrydnTzLIPEtlb tHdDyGptsZDv9ahV8oymUly3btatqHuXj7EcCncSobhlzkWPs14b/YXZIGPRgOL9Oe /J+0hatRw/XVu4L2hVnK8sUM7Pcgnf+uCcjzklKQpa+E8KjzJUTCXvZEiBjZtXXnG0 XdWu8TqQfGnQg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Torokhov , kernel test robot , Linus Torvalds , Sasha Levin , linux-arch@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 01/14] asm-generic: make sparse happy with odd-sized put_unaligned_*() Date: Mon, 15 Jan 2024 18:25:35 -0500 Message-ID: <20240115232611.209265-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.73 Content-Transfer-Encoding: 8bit From: Dmitry Torokhov [ Upstream commit 1ab33c03145d0f6c345823fc2da935d9a1a9e9fc ] __put_unaligned_be24() and friends use implicit casts to convert larger-sized data to bytes, which trips sparse truncation warnings when the argument is a constant: CC [M] drivers/input/touchscreen/hynitron_cstxxx.o CHECK drivers/input/touchscreen/hynitron_cstxxx.c drivers/input/touchscreen/hynitron_cstxxx.c: note: in included file (through arch/x86/include/generated/asm/unaligned.h): include/asm-generic/unaligned.h:119:16: warning: cast truncates bits from constant value (aa01a0 becomes a0) include/asm-generic/unaligned.h:120:20: warning: cast truncates bits from constant value (aa01 becomes 1) include/asm-generic/unaligned.h:119:16: warning: cast truncates bits from constant value (ab00d0 becomes d0) include/asm-generic/unaligned.h:120:20: warning: cast truncates bits from constant value (ab00 becomes 0) To avoid this let's mask off upper bits explicitly, the resulting code should be exactly the same, but it will keep sparse happy. Reported-by: kernel test robot Suggested-by: Linus Torvalds Closes: https://lore.kernel.org/oe-kbuild-all/202401070147.gqwVulOn-lkp@intel.com/ Signed-off-by: Dmitry Torokhov Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/asm-generic/unaligned.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h index 699650f81970..a84c64e5f11e 100644 --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -104,9 +104,9 @@ static inline u32 get_unaligned_le24(const void *p) static inline void __put_unaligned_be24(const u32 val, u8 *p) { - *p++ = val >> 16; - *p++ = val >> 8; - *p++ = val; + *p++ = (val >> 16) & 0xff; + *p++ = (val >> 8) & 0xff; + *p++ = val & 0xff; } static inline void put_unaligned_be24(const u32 val, void *p) @@ -116,9 +116,9 @@ static inline void put_unaligned_be24(const u32 val, void *p) static inline void __put_unaligned_le24(const u32 val, u8 *p) { - *p++ = val; - *p++ = val >> 8; - *p++ = val >> 16; + *p++ = val & 0xff; + *p++ = (val >> 8) & 0xff; + *p++ = (val >> 16) & 0xff; } static inline void put_unaligned_le24(const u32 val, void *p) @@ -128,12 +128,12 @@ static inline void put_unaligned_le24(const u32 val, void *p) static inline void __put_unaligned_be48(const u64 val, u8 *p) { - *p++ = val >> 40; - *p++ = val >> 32; - *p++ = val >> 24; - *p++ = val >> 16; - *p++ = val >> 8; - *p++ = val; + *p++ = (val >> 40) & 0xff; + *p++ = (val >> 32) & 0xff; + *p++ = (val >> 24) & 0xff; + *p++ = (val >> 16) & 0xff; + *p++ = (val >> 8) & 0xff; + *p++ = val & 0xff; } static inline void put_unaligned_be48(const u64 val, void *p) -- 2.43.0