Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4997021ybi; Tue, 30 Jul 2019 11:52:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1Sljfgl4gpbJEooowOcZ+W70ePMQB+et24UTFtpSEibEc7XgYZ951q68aWGX+qR6OHZdN X-Received: by 2002:a17:90a:a404:: with SMTP id y4mr122433019pjp.58.1564512746583; Tue, 30 Jul 2019 11:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564512746; cv=none; d=google.com; s=arc-20160816; b=hF3iVUeOjtQtkGQhZTyvTzBZcCLRGfz8iq8fFcCF6t279y9vCEeDom/oa1/0o0VAU4 6p3Ph9EeR2vNlu5jXdZa2NColXZ8aFNQ0EJAH3xZn5gJevptiWThD30dq0+ZYPRkT0Nw syg0GQyKUNCJaXTXQNRMPBapwXrx+yTUD+tTFtdCsCCsCtcymrVOLQ3TOqc10032gH53 g/2Q0o9GT8TANHrozZyB356ePrDigDSMmymAP2FiYHU0V7RCjVvzXUDEe8I/zLByKdf5 nzl1BH0YvMtERrIc+fQfWqixRUrwenF+uulT4K55KuvUX9QlUvK9ZT4rD5f/9enZ5Aev DwqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=z+Aoa8C7fOJajFrFJKatcii8S1WaU/OkCjEyKezFuyo=; b=vNBn3IL6k4EXbdaFEEJLJdLqseHoIwg0NfTkkUYbVuo5uQwGVI/WLIDbi5SS4oHpIf H5tqguMnQ3Yl2zIMzL6WkenMs479eBX88qmx+Hb9SlY0BPX4JC3/UnkN4H7uaGS6Gijy JwHKk/0EcHFWuTBalxBg+W83Difg24e8WwshHMtkiOeh0FdaOIAg7xqbK14aPIu+HemW O8nIwF1I1+tN6A1WIIgp0HBKwhMxky9OZaxHk3sR/maTTNB1Fz7KcB/XytZeD1/0gYZP kuldxreYudATzfxaHAg5XFkouNpzc7AKv7fRSaae3u6augxIpZcT9QeqTuTN/G1HpkHN eWVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si31344382pfa.76.2019.07.30.11.52.11; Tue, 30 Jul 2019 11:52:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730320AbfG3SvT (ORCPT + 99 others); Tue, 30 Jul 2019 14:51:19 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:42057 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbfG3SvR (ORCPT ); Tue, 30 Jul 2019 14:51:17 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 085DA8022C; Tue, 30 Jul 2019 20:51:02 +0200 (CEST) Date: Tue, 30 Jul 2019 20:51:14 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Bastien Nocera , Jonathan Cameron , Sasha Levin Subject: Re: [PATCH 4.19 044/113] iio: iio-utils: Fix possible incorrect mask calculation Message-ID: <20190730185114.GA9061@amd> References: <20190729190655.455345569@linuxfoundation.org> <20190729190706.217460325@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6TrnltStXW4iwmi0" Content-Disposition: inline In-Reply-To: <20190729190706.217460325@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit 208a68c8393d6041a90862992222f3d7943d44d6 ] >=20 > On some machines, iio-sensor-proxy was returning all 0's for IIO sensor > values. It turns out that the bits_used for this sensor is 32, which makes > the mask calculation: >=20 > *mask =3D (1 << 32) - 1; >=20 > If the compiler interprets the 1 literals as 32-bit ints, it generates > undefined behavior depending on compiler version and optimization > level. Ok, it would be problem if code was like that. But it is not: > @@ -159,9 +159,9 @@ int iioutils_get_type(unsigned *is_signed, unsigned *= bytes, unsigned *bits_used, > *be =3D (endianchar =3D=3D 'b'); > *bytes =3D padint / 8; > if (*bits_used =3D=3D 64) > - *mask =3D ~0; > + *mask =3D ~(0ULL); > else > - *mask =3D (1ULL << *bits_used) - 1; > + *mask =3D (1ULL << *bits_used) - 1ULL; > =20 Note 1ULL already being there before the change. AFAICT this does not change anything; 1ULL << foo will already have long long type, so substraction will be long long too. AFAICT this does not change the binary code at all, so it can't fix a bug... Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --6TrnltStXW4iwmi0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1AkaIACgkQMOfwapXb+vIz1wCdFnxRxuvUPqBT4+aAx/xeDgxh DYAAnibK5SoZyFhiFuV15BOC/Bixqt5L =P1tq -----END PGP SIGNATURE----- --6TrnltStXW4iwmi0--