Skip to contentSkip to conversation

tools: convert bitfields to unsigned type

PATCH Superseded Olaf Hering 2 participants 5 messages May 3, 2023 – May 8, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: convert bitfields to unsigned type

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.

---
 tools/include/libxenvchan.h | 6 +++---
 tools/xentrace/xenalyze.c   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/include/libxenvchan.h +3 -3
index 30cc73cf97..3d3b8aa8dd 100644
@@ -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;
 	/**
tools/xentrace/xenalyze.c +1 -1
index 12dcca9646..1b4a188aaa 100644
@@ -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;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Olaf Hering

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.

---
  tools/include/libxenvchan.h | 6 +++---
  tools/xentrace/xenalyze.c   | 2 +-
  2 files changed, 4 insertions(+), 4 deletions(-)
tools/include/libxenvchan.h +3 -3
index 30cc73cf97..3d3b8aa8dd 100644
@@ -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;
  	/**
tools/xentrace/xenalyze.c +0 -0
index 12dcca9646..1b4a188aaa 100644

tools/xentrace/xenalyze.c struct hvm_data { · line 1380

Quoted 5 lines
tools/xentrace/xenalyze.c +1 -1
@@ -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:

Juergen

#2 lore raw

Mon, 8 May 2023 11:06:11 +0200 Juergen Gross <[email protected]>:

Quoted 3 lines

tools/xentrace/xenalyze.c struct hvm_data { · line 1380

Quoted 2 lines
tools/xentrace/xenalyze.c +1 -1
-    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

#3 lore raw
Quoted 7 lines · Olaf Hering

Mon, 8 May 2023 11:06:11 +0200 Juergen Gross <[email protected]>:

Quoted 3 lines

tools/xentrace/xenalyze.c struct hvm_data { · line 1380

Quoted 2 lines
tools/xentrace/xenalyze.c +1 -1
-    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

#4 lore raw

Mon, 8 May 2023 13:23:27 +0200 Juergen Gross <[email protected]>:

Quoted 1 line

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