Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Apr 2023 19:43:34 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 00172f341666 - main - geom: use bool for one-bit wide bit-field
Message-ID:  <202304171943.33HJhYa1065493@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

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

commit 00172f341666f2d5535ae6f4630c93593e86a4cb
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-04-17 18:56:51 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-17 19:43:00 +0000

    geom: use bool for one-bit wide bit-field
    
    A one-bit wide bit-field can take only the values 0 and -1.  Clang 16
    introduced a warning that "implicit truncation from 'int' to a one-bit
    wide bit-field changes value from 1 to -1".  Fix by using c99 bool.
    
    Reported by:    Clang, via dim
    Reviewed by:    dim
    Sponsored by:   The FreeBSD Foundation
---
 sys/geom/part/g_part.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/geom/part/g_part.h b/sys/geom/part/g_part.h
index c96cec264b87..4987b7c54c0e 100644
--- a/sys/geom/part/g_part.h
+++ b/sys/geom/part/g_part.h
@@ -132,10 +132,10 @@ struct g_part_entry {
 	quad_t		gpe_start;	/* First LBA of partition. */
 	quad_t		gpe_end;	/* Last LBA of partition. */
 	int		gpe_index;
-	int		gpe_created:1;	/* Entry is newly created. */
-	int		gpe_deleted:1;	/* Entry has been deleted. */
-	int		gpe_modified:1;	/* Entry has been modified. */
-	int		gpe_internal:1;	/* Entry is not a used entry. */
+	bool		gpe_created:1;	/* Entry is newly created. */
+	bool		gpe_deleted:1;	/* Entry has been deleted. */
+	bool		gpe_modified:1;	/* Entry has been modified. */
+	bool		gpe_internal:1;	/* Entry is not a used entry. */
 };
 
 /* G_PART table (KOBJ instance). */
@@ -170,12 +170,12 @@ struct g_part_table {
 	uint32_t	gpt_heads;
 
 	int		gpt_depth;	/* Sub-partitioning level. */
-	int		gpt_isleaf:1;	/* Cannot be sub-partitioned. */
-	int		gpt_created:1;	/* Newly created. */
-	int		gpt_modified:1;	/* Table changes have been made. */
-	int		gpt_opened:1;	/* Permissions obtained. */
-	int		gpt_fixgeom:1;	/* Geometry is fixed. */
-	int		gpt_corrupt:1;	/* Table is corrupt. */
+	bool		gpt_isleaf:1;	/* Cannot be sub-partitioned. */
+	bool		gpt_created:1;	/* Newly created. */
+	bool		gpt_modified:1;	/* Table changes have been made. */
+	bool		gpt_opened:1;	/* Permissions obtained. */
+	bool		gpt_fixgeom:1;	/* Geometry is fixed. */
+	bool		gpt_corrupt:1;	/* Table is corrupt. */
 };
 
 struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304171943.33HJhYa1065493>