Date: Sat, 1 Feb 2020 19:17:07 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Ian Lepore <ian@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r357349 - in head/sys: conf modules/tpm Message-ID: <5146F5D0-6E0A-415D-8C14-AE8C5CD05CAA@FreeBSD.org> In-Reply-To: <e057f88c8f57438c31264d470a1e272c5f7998c9.camel@freebsd.org> References: <202001311936.00VJaEDP056807@repo.freebsd.org> <e057f88c8f57438c31264d470a1e272c5f7998c9.camel@freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] On 1 Feb 2020, at 18:55, Ian Lepore <ian@FreeBSD.org> wrote: > > On Fri, 2020-01-31 at 19:36 +0000, Dimitry Andric wrote: >> Author: dim >> Date: Fri Jan 31 19:36:14 2020 >> New Revision: 357349 >> URL: https://svnweb.freebsd.org/changeset/base/357349 >> >> Log: >> Merge r357348 from the clang 10.0.0 import branch: >> >> Disable new clang 10.0.0 warnings about converting the result of shift >> operations to a boolean in tpm(4): >> >> sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context] >> WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD); >> ^ >> sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD' >> #define TPM_CRB_CTRL_CANCEL_CMD BIT(0) >> ^ >> sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT' >> #define BIT(x) (1 << (x)) >> ^ >> >> Such warnings can be useful in C++ contexts, but not so much in kernel >> drivers, where this type of bit twiddling is commonplace. So disable it >> for this case. >> > > I think the point of the compiler warning about shift in a boolean > context is the same as warning about assignment in a boolean > context. I.e, > > if (a << 3) > > might be a typo for > > if (a < 3) > > in the same way as "a = 3" might have been intended to be "a == 3". Yes, clang inherited this warning from gcc, where it says in: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wint-in-bool-context -Wint-in-bool-context Warn for suspicious use of integer values where boolean values are expected, such as conditional expressions (?:) using non-boolean integer constants in boolean context, like if (a <= b ? 2 : 3). Or left shifting of signed integers in boolean context, like for (a = 0; 1 << a; a++);. Likewise for all kinds of multiplications regardless of the data type. This warning is enabled by -Wall. -Dimitry [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXjXAowAKCRCwXqMKLiCW o7GMAKDVh6PO3SpDC9sf6fOWLj7s9Gcd5ACg0EkRgDA8CXvK9NijozxV82TFMO4= =WC// -----END PGP SIGNATURE-----home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5146F5D0-6E0A-415D-8C14-AE8C5CD05CAA>
