[PATCH v1] tools: convert bitfields to unsigned type

Olaf Hering posted 1 patch 1 year ago
Failed in applying to current master (apply log)
There is a newer version of this series
tools/include/libxenvchan.h | 6 +++---
tools/xentrace/xenalyze.c   | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
[PATCH v1] tools: convert bitfields to unsigned type
Posted by Olaf Hering 1 year ago
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;
 
     /* Immediate processing */
     void *d;
Re: [PATCH v1] tools: convert bitfields to unsigned type
Posted by Juergen Gross 1 year ago
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
Re: [PATCH v1] tools: convert bitfields to unsigned type
Posted by Olaf Hering 1 year ago
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
Re: [PATCH v1] tools: convert bitfields to unsigned type
Posted by Juergen Gross 1 year ago
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
Re: [PATCH v1] tools: convert bitfields to unsigned type
Posted by Olaf Hering 1 year ago
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