diff mbox series

[v1] tools: convert bitfields to unsigned type

Message ID 20230503150142.4987-1-olaf@aepfle.de (mailing list archive)
State Superseded
Headers show
Series [v1] tools: convert bitfields to unsigned type | expand

Commit Message

Olaf Hering May 3, 2023, 3:01 p.m. UTC
clang complains about the signed type:

implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]

The potential ABI change in libxenvchan is covered by the Xen version based SONAME.

The xenalyze change follows the existing pattern in that file.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 tools/include/libxenvchan.h | 6 +++---
 tools/xentrace/xenalyze.c   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Jürgen Groß May 8, 2023, 9:06 a.m. UTC | #1
On 03.05.23 17:01, Olaf Hering wrote:
> clang complains about the signed type:
> 
> implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
> 
> The potential ABI change in libxenvchan is covered by the Xen version based SONAME.
> 
> The xenalyze change follows the existing pattern in that file.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>   tools/include/libxenvchan.h | 6 +++---
>   tools/xentrace/xenalyze.c   | 2 +-
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/include/libxenvchan.h b/tools/include/libxenvchan.h
> index 30cc73cf97..3d3b8aa8dd 100644
> --- a/tools/include/libxenvchan.h
> +++ b/tools/include/libxenvchan.h
> @@ -79,11 +79,11 @@ struct libxenvchan {
>   	xenevtchn_handle *event;
>   	uint32_t event_port;
>   	/* informative flags: are we acting as server? */
> -	int is_server:1;
> +	unsigned int is_server:1;
>   	/* true if server remains active when client closes (allows reconnection) */
> -	int server_persist:1;
> +	unsigned int server_persist:1;
>   	/* true if operations should block instead of returning 0 */
> -	int blocking:1;
> +	unsigned int blocking:1;
>   	/* communication rings */
>   	struct libxenvchan_ring read, write;
>   	/**
> diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
> index 12dcca9646..1b4a188aaa 100644
> --- a/tools/xentrace/xenalyze.c
> +++ b/tools/xentrace/xenalyze.c
> @@ -1377,7 +1377,7 @@ struct hvm_data {
>       tsc_t exit_tsc, arc_cycles, entry_tsc;
>       unsigned long long rip;
>       unsigned exit_reason, event_handler;
> -    int short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
> +    unsigned short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;

Please use "unsigned int" instead of a pure "unsigned".

With that you can add my:

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
Olaf Hering May 8, 2023, 10 a.m. UTC | #2
Mon, 8 May 2023 11:06:11 +0200 Juergen Gross <jgross@suse.com>:

> > -    int short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
> > +    unsigned short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;  
> Please use "unsigned int" instead of a pure "unsigned".

The entire file uses just 'unsigned' for bitfields.

Olaf
Jürgen Groß May 8, 2023, 11:23 a.m. UTC | #3
On 08.05.23 12:00, Olaf Hering wrote:
> Mon, 8 May 2023 11:06:11 +0200 Juergen Gross <jgross@suse.com>:
> 
>>> -    int short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
>>> +    unsigned short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
>> Please use "unsigned int" instead of a pure "unsigned".
> 
> The entire file uses just 'unsigned' for bitfields.

I have found 18 lines using "unsigned int" for bitfields in this file.


Juergen
Olaf Hering May 8, 2023, 3:40 p.m. UTC | #4
Mon, 8 May 2023 13:23:27 +0200 Juergen Gross <jgross@suse.com>:

> I have found 18 lines using "unsigned int" for bitfields in this file.

There is indeed a mix of both variants in this file.
I scrolled just down to line 6999, only looking for ':1'.


Olaf
diff mbox series

Patch

diff --git a/tools/include/libxenvchan.h b/tools/include/libxenvchan.h
index 30cc73cf97..3d3b8aa8dd 100644
--- a/tools/include/libxenvchan.h
+++ b/tools/include/libxenvchan.h
@@ -79,11 +79,11 @@  struct libxenvchan {
 	xenevtchn_handle *event;
 	uint32_t event_port;
 	/* informative flags: are we acting as server? */
-	int is_server:1;
+	unsigned int is_server:1;
 	/* true if server remains active when client closes (allows reconnection) */
-	int server_persist:1;
+	unsigned int server_persist:1;
 	/* true if operations should block instead of returning 0 */
-	int blocking:1;
+	unsigned int blocking:1;
 	/* communication rings */
 	struct libxenvchan_ring read, write;
 	/**
diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
index 12dcca9646..1b4a188aaa 100644
--- a/tools/xentrace/xenalyze.c
+++ b/tools/xentrace/xenalyze.c
@@ -1377,7 +1377,7 @@  struct hvm_data {
     tsc_t exit_tsc, arc_cycles, entry_tsc;
     unsigned long long rip;
     unsigned exit_reason, event_handler;
-    int short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
+    unsigned short_summary_done:1, prealloc_unpin:1, wrmap_bf:1;
 
     /* Immediate processing */
     void *d;