From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f43.google.com (mail-yx1-f43.google.com [74.125.224.43]) (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 9E6633C0A05 for ; Tue, 26 May 2026 20:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=74.125.224.43 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779828902; cv=pass; b=JQYbYDeGnuFU3eIimbpPUXQ2krxA2rTaYAj8vwIRWZMqO5/ZSBhQh2fqv4cO6b4gvZcHG0iINLaDx3Ctt0T4CYiLDW58U3f2YOhUB2PrVuk3sTnbXCrlob2mnOh1WpWCg2XtuODrF6Jo+L6QpOqwoCd+iglTP/48Zj8VYW/gkVQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779828902; c=relaxed/simple; bh=fETlrkQR+rc/8sic5BN0xkquNsZXlYpf4D6aInCz9k0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IUBAbXEMSR9JtH+VeRwFv1YlMDgNgPJWe69pLbV6bmoCb/aZ02gOEyv/BJRkp+J7CD6MT2MpbSVBum4yCqguQFyhDw4xgvJAQezPQxW0iKNTfB4oI3V5BbUfoaEV4uLYfzeNUUwA2uKojChKtRmCqKEAV55qQD+/OKvhiK+NqVY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LDxhmR3m; arc=pass smtp.client-ip=74.125.224.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LDxhmR3m" Received: by mail-yx1-f43.google.com with SMTP id 956f58d0204a3-6563f83ae9fso10660179d50.1 for ; Tue, 26 May 2026 13:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779828900; cv=none; d=google.com; s=arc-20240605; b=Gtaa7F/yx+OzOyq9JP2xsdtxic7lBxqnNf2dyQNpG2ZVJQCPJbhI2+XXJ9JUnHckak d0LIDzGo+p3ueFBlxk6t1C9YYCj3sBiFqgpeL0IELB4OWINVH4VifmEmaQ36AkxJIalj 3xW+UaI5B4Oqr/qD7+a3/hdLc0Izm+Byr35Sr84XwCkA83mNDNVPVe0xfX/DJ+8nfGgz /tjWzIIL5vDrJKds6EPpQG3f80asR20gw9LMfn/NlS7aizNZleoRoRwwIesyXkWPr7Ap TTGxqAxPRTPZiLPaJcVSKch8+OW9+EDzsZ8XP4LASxkSl/hUXCnYSFwSGXZdHWGc8h5b wtag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kCoTiZGubefWxkg0PokQrP5fkZHllIjc/WJPwBH1DZc=; fh=z+iHINcp/XYXp/Vx3wUYlXL/aySQoGKwaGKbFzK1XIs=; b=YokvCIfMSvo2U/i7ppodV4tuo8jqAUIGKaUMgTjYsWBDCmAtvwzADQlWHPbxPzWWcz 9iAQ+ECKuNi7Rj0zEG6FQlHUnpQo7KVpUKA+HR8W/D8oG9+Yrmee6ZANAGech5Uv7mmd AwGSIJm8CeyM8hWMkHPurbaHdhAZ1zFFDVGWlFQyXqLXmuWyUS2NqdSmOkWbmtlVQ9TE +upNY+mv+2iEnism2O1pX7xLWtQKaKtGS06fCJGD+xpHWsNCLjt0kw7THQDqwZTCiWLs cJCN/4CbqW7OZLwu9UYtDoyzjujoP2djAQU7WQUkWS8OhynXUm1wu7zJ2rZ0V0MlxmUD ukCw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779828900; x=1780433700; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kCoTiZGubefWxkg0PokQrP5fkZHllIjc/WJPwBH1DZc=; b=LDxhmR3mCLbh9PUbBhnbRMPdeufEN+On/HfBIBfVnVCX8bHiN9IIORu7+YYtRKQKDG JEtQGG7EbeTOkvRPdmLfQLuHorlvWsOdV8JO/4OoenXiT0E82WMoaryKGFNJIb051F1f mqiCBYfOLC6VgoRA4VpNfg0EnFG82d1KIaluQK91Chu03FGD7nYORqu4ogbavZFT7Tpx 4liZ2INt+KkevP/6h/s1vFvL3ozntE39B7ag6u5fmqR2WOY9iVx/UOqvfGUh9yfa4CNT h70/mw8Wn5Wocwh/pFV0wnoObAsLWgfPa3Aae5Z2k+gV6Pw6NBug9kCjILoDLsLWZGyS U7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779828900; x=1780433700; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kCoTiZGubefWxkg0PokQrP5fkZHllIjc/WJPwBH1DZc=; b=TRMMC0Ku6HWMh6SEQ+OTgZGeQdVYmaQk19A5EKx1AURJSu9dM8zEgA1LryrJmTnfW8 M6YsqLw5hZdhxxuCvAlow/Z3MSRwGd70kplAOHh+xpU8w/z2XTQr+Ca265IgT7F7iDzT N8fjFZkX+0afDDLhXSfLk3/I2kfu4LQOYfg2DQNr28Y5yQQaB2iWycmLv/dbdcQShI41 hqmp3zPXFVaiBmJVd+RWDywT+4e6waNY+evtA42PtDu0TOyHXYwvcDY8rBYDinxoGZuR N9+pPp7Z6MvnDVQUNHYTUi7/qX6xf3mqahXKqG0c+Bn69/irk5ppJueYmR3TcIgzDWHM ErrA== X-Forwarded-Encrypted: i=1; AFNElJ97WzwCblBRvzdwuO/sSBKqRgn4rZ8qGbEZ7O7yvBbuYu70A0jpvit/l5cssFU43Hci8XfkFLeogDWyt84=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg+uzV4HskRIbo+VQxbRKXf5wXdG8cNTikmPqU8KhHpue4V4YP NS3R2rJbLZl133GTUFHn3bG6MKxa7kbCnZu/6Rh2aOsFtdlmIxpzBZSEtw+4yI6r1dtxYmXCcMl grViHs53/Z/cDOYmGK9il90/Ixed9Czg= X-Gm-Gg: Acq92OGrjFbC2qBGiTTKCfFbzEZdZv7usf1SBrNCgtrnoe62VIoileQH5gHIYjOqgBY N+eaav+47KlU3eZbSQeuSL/HFxY1NtGDxF5GgbxiPmH0O1KVek5t4rwVTkSdsVoipnVs1y6W/kZ KsSI5M+06s0x1akyPqOzCyjZl1UbCoRWY/+C2vbCXRLnbjLwrbFFdABBRP00jgstwtKH2DyA1DW +3KKkZQFcjZvkMhS3OxTfhtuU6n39zPhavqSXgvniNJFzt+k4VDnRA6qc8/x7cNyahI5xJAeGTX ljJ3bt4pRoOLWUDKOybjOClWLPQJJguoJ2attpoQ X-Received: by 2002:a05:690e:4850:b0:651:cf77:f7cd with SMTP id 956f58d0204a3-65ec963f9ffmr13950537d50.13.1779828900477; Tue, 26 May 2026 13:55:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260524020309.18618-1-m32285159@gmail.com> <20260526153842.61e15dfd@jic23-huawei> In-Reply-To: <20260526153842.61e15dfd@jic23-huawei> From: Maxwell Doose Date: Tue, 26 May 2026 15:54:49 -0500 X-Gm-Features: AVHnY4IThspKmr_e2QUhwMVBzVy48hMrdp5Yq2oPDkWIhkx_5zhlb3XD-VfbTQc Message-ID: Subject: Re: [PATCH v2] iio: chemical: scd30: Cleanup initializations in scd30_float_to_fp() To: Jonathan Cameron Cc: Joshua Crofts , David Lechner , =?UTF-8?B?TnVubyBTw6E=?= , Andy Shevchenko , "open list:IIO SUBSYSTEM AND DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 26, 2026 at 9:38=E2=80=AFAM Jonathan Cameron = wrote: > > On Mon, 25 May 2026 08:49:17 +0200 > Joshua Crofts wrote: > > > On Sun, 24 May 2026 at 04:04, Maxwell Doose wrote= : > > > > > > Include linux/bitfield.h for FIELD_GET(). > > > > > > Create new macros for bit manipulation in combination with manual bit > > > manipulation being replaced with FIELD_GET(). > > > > > > The current variable declaration and initializations are barely reada= ble > > > and use comma separations across multiple lines. Refactor the > > > initializations so that mantissa and exp have separate declarations a= nd > > > sign gets initialized later. > > > > > Signed-off-by: Maxwell Doose > > Sashiko review of this one is really interesting. If you fancy doing a b= it > of digging it would be good to verify that it is correct on the original > code giving a very wrong answer on 64 bit platforms. > > I poked the compiler explorer (https://godbolt.org/) with and without -m3= 2 > passed to 64bit gcc. Looks like sashiko is right to me. However given th= e way > it is used I think we are in undefined behaviour territory so it might > 'work' unless the compiler is feel malicious. > > Upshot, verify it for your own understanding and then add a fixes tag > for wherever that issue came from. > > https://sashiko.dev/#/patchset/20260524020309.18618-1-m32285159%40gmail.c= om > Woof, this'll be quite a doozy to look into. I'm no good in terms of understanding compilers (I ought to do a deeper dive into stuff like that at some point), but I guess compiler explorer is sufficient for now (note that I'm also no good at understanding assembly). I think (and correct me if I'm wrong) that under the hood, BIT(n) does (1UL << n) and since an unsigned long is 64 bits on 64-bit architectures, float32 gets sign extended to 0xFFFFFFFF7FFFFFFF which is a problem. Regardless, will send a v3 with fixes, reported-by, and closes tags (I guess sashiko technically reported it) as well as an explanation for the fixes tag. best regards, max