Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1454844rdb; Sun, 7 Jan 2024 22:16:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs0rdW/k8+I4M6KwtdL+YUNMnLfwsn3hV3PLlClXun3Hm+KkAbut9VKzRrTxwlv44j9feX X-Received: by 2002:a05:6358:9486:b0:16d:edaa:921c with SMTP id i6-20020a056358948600b0016dedaa921cmr4810647rwb.12.1704694619264; Sun, 07 Jan 2024 22:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704694619; cv=none; d=google.com; s=arc-20160816; b=cFLR4SsknWFUDFxJBI7H7qj3WBqh77C+Q3iuv7B+5rDTRPJigfsEpi6FLv0OblVPmu +G1KTQxN+SkKogE4/85FzeyBh2r3RjBn2yjqXa0M1AMAhYLGWqG0bvqSNWH+g1TmAt9L lDj1DsWs6RWCThFA5cpwXL43vxpi42kvNZmftoOPMQSlfSvLwmQFiyKU7VpDUI51JNhw l7Xi4YN6EdoQ+yg7P5riBG7jugEzqvHXZEGzvNqS1leb+Am1GnUPcY/oBKWzR+tsstqS jhxyXp6GVRd3JY7TAx9Jvo/929/iPoosLWmOc3mBA+N12zuzUpAmcJPOmJpFx0y0R81A TpDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=R96nFtUAHcvK+Syyw7DXDD2f4NflWNpk/wdXNthWbzI=; fh=DjViX+b9qx4jt1CHSZN2srOCVDay1gk3mWMrJTaPezY=; b=fSGK948g7zfHKYAddR4hQqaVn7nzDu45IW2hrv68tIO2qCvZuYReq3eP1Egp7BIjrT PmnEVplw1Ys7jId0LU5TnD92Fp0Aw6gayOVwYPR0PGbrpZd7PYFevueuu/lcnXwbATme Uvgo4iWonL/kv/D4U+L744727jBXv7RnA/pUwzLrYQhyH4w/UOIQ+FhyG8UnXId7cldx 31Pp0XSGAjE7vK3pDSHVhsM1OJgs27R8FlEIeZABLebCrWz9hoDhpD/Jnoo3/h+MLw0n ubz8pQ9nJaHB4a03hpz5FM/M8PMxk6Ml7lAke0Cqiq+6ffo0UK+wA6JHgOSwWb/3A5Fj qFxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ehxx9LLd; spf=pass (google.com: domain of linux-kernel+bounces-19094-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q8-20020a17090aa00800b0028bf2811d79si5065336pjp.100.2024.01.07.22.16.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 22:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19094-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ehxx9LLd; spf=pass (google.com: domain of linux-kernel+bounces-19094-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 D849A281B32 for ; Mon, 8 Jan 2024 06:16:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 514B38489; Mon, 8 Jan 2024 06:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ehxx9LLd" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21D6379DE; Mon, 8 Jan 2024 06:16:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2045bedb806so1671584fac.3; Sun, 07 Jan 2024 22:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704694609; x=1705299409; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=R96nFtUAHcvK+Syyw7DXDD2f4NflWNpk/wdXNthWbzI=; b=ehxx9LLdjRFHfsVMpsrdenN9NZuOs8NJSmXFuz8thZMoWg6dKQT59fOL1MBwP1WA/y M+8LpcdG4u1r3jxDL9m7mqvz61GAvZ2LuubxndkmZhbkSanrt2LUWIwXuMMYn7k1ImWh hapqsRWHIOkne3GtXjRZFNEc0kLRCBqWahJ51jr7g2hxmIDaaNq08uEWd5rtJlG8ZeG7 jP6o+tf8ow879kpDJ4Gp+qCIrlFHFyJKJ9jKtUwtG/ZgUypqWjdVbzqHALqOyl+h3g0F XUyGFvTvamLWpsav6AO41df+Mep2FnQFZgdrAomh/WfQjaBdMEmES+vBNotfvPRtpHJa bZfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704694609; x=1705299409; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=R96nFtUAHcvK+Syyw7DXDD2f4NflWNpk/wdXNthWbzI=; b=S1gj4k8adxtfZ5AF16vVxzSoYv14vpp4X9+3xeFhjOvQRmUe7VZeDtSM5G0RYcVf63 QodtB34Tel/PiedzmsxpfDI8NVOpHcY3Q3ZhIF3LChboxw7OFWTe4t1DnT1V8kYVyykj VlhKcJpBSgoENXAkp1Pra2Myyinl2JeVmC7S/qAqaO3612xuBO+BrWziSTzrdzgFs4ol krPSWnrj/tdG0HWsEUGtzmSS+iKgXTR3guxcYDJtSMuQHKlEVKJH+QvpUNtn3XuS9tL9 65tRVnL67pE2GTgsu632xy0MHLKSQIITVRUsnGL5EwLKYv3jsxGiWqE0QvDaygLZC6Az nwQw== X-Gm-Message-State: AOJu0Yzo6ijRQYkYE79yJ9/6sGxoklrT2+RhoPDPjzCtyiV9lOuN1u/Z sWGASkJGdvSW3SiYjv23Mkc= X-Received: by 2002:a05:6358:5384:b0:175:67e3:f9be with SMTP id z4-20020a056358538400b0017567e3f9bemr3641697rwe.31.1704694608850; Sun, 07 Jan 2024 22:16:48 -0800 (PST) Received: from google.com ([2620:15c:9d:2:7a4a:2478:1813:e8c2]) by smtp.gmail.com with ESMTPSA id nc6-20020a17090b37c600b0028649b84907sm5464921pjb.16.2024.01.07.22.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 22:16:48 -0800 (PST) Date: Sun, 7 Jan 2024 22:16:45 -0800 From: Dmitry Torokhov To: Arnd Bergmann Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Subject: [PATCH] asm-generic: make sparse happy with odd-sized put_unaligned_*() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline __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 --- 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.195.gebba966016-goog -- Dmitry