Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 01 Jan 2026 22:21:43 +0000
From:      Robert Clausecker <fuz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: fff2795baf1a - stable/15 - libc/stdc_has_single_bit.c: fix gcc warning (-Wparentheses)
Message-ID:  <6956f377.c87f.1921335c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by fuz:

URL: https://cgit.FreeBSD.org/src/commit/?id=fff2795baf1ae298b0fcf137bc584faf1d79c785

commit fff2795baf1ae298b0fcf137bc584faf1d79c785
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2025-12-03 18:36:27 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-01-01 20:57:32 +0000

    libc/stdc_has_single_bit.c: fix gcc warning (-Wparentheses)
    
    gcc14 is concerned that the operator precedence between - and & might
    be confusing.  Throw in some redundant parentheses to make it shut up.
    The LLVM build was fine before this change.
    
    Reported by:    Martin Filla <freebsd@sysctl.cz>
    Approved by:    markj (mentor)
    MFC after:      1 month
    Fixes:          6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
    Differential Revision:  https://reviews.freebsd.org/D54057
    
    (cherry picked from commit 3d71ce92eae9f1417f35a0d07912858fd8f6fa0b)
---
 lib/libc/stdbit/stdc_has_single_bit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/libc/stdbit/stdc_has_single_bit.c b/lib/libc/stdbit/stdc_has_single_bit.c
index e5f676265551..a448464b04d9 100644
--- a/lib/libc/stdbit/stdc_has_single_bit.c
+++ b/lib/libc/stdbit/stdc_has_single_bit.c
@@ -10,29 +10,29 @@
 bool
 stdc_has_single_bit_uc(unsigned char x)
 {
-	return (x != 0 && (x & x - 1) == 0);
+	return (x != 0 && (x & (x - 1)) == 0);
 }
 
 bool
 stdc_has_single_bit_us(unsigned short x)
 {
-	return (x != 0 && (x & x - 1) == 0);
+	return (x != 0 && (x & (x - 1)) == 0);
 }
 
 bool
 stdc_has_single_bit_ui(unsigned int x)
 {
-	return (x != 0 && (x & x - 1) == 0);
+	return (x != 0 && (x & (x - 1)) == 0);
 }
 
 bool
 stdc_has_single_bit_ul(unsigned long x)
 {
-	return (x != 0 && (x & x - 1) == 0);
+	return (x != 0 && (x & (x - 1)) == 0);
 }
 
 bool
 stdc_has_single_bit_ull(unsigned long long x)
 {
-	return (x != 0 && (x & x - 1) == 0);
+	return (x != 0 && (x & (x - 1)) == 0);
 }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6956f377.c87f.1921335c>