Skip to contentSkip to conversation

chardev/baum: Fix compiler warning for Windows builds

PATCH Applied Stefan Weil via 4 participants 5 messages Aug 9, 2025 – Aug 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chardev/baum: Fix compiler warning for Windows builds

Compiler warning:

../chardev/baum.c:657:25: warning: comparison between pointer and integer

Use brlapi_fileDescriptor instead of int for brlapi_fd and BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1.

---

This is a rather old patch which I now use since more than two years to support Braille with QEMU on Windows.

It's a hack (because Windows uses a pointer (64 bit) which is assigned to an int (32 bit), but it seems to work.

Regards,
Stefan

 chardev/baum.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
chardev/baum.c +2 -2
index f3e8cd27f0..5c3587dda5 100644
@@ -94,7 +94,7 @@ struct BaumChardev {
     Chardev parent;
 
     brlapi_handle_t *brlapi;
-    int brlapi_fd;
+    brlapi_fileDescriptor brlapi_fd;
     unsigned int x, y;
     bool deferred_init;
 
@@ -654,7 +654,7 @@ static void baum_chr_open(Chardev *chr,
     baum->brlapi = handle;
 
     baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
-    if (baum->brlapi_fd == -1) {
+    if (baum->brlapi_fd == BRLAPI_INVALID_FILE_DESCRIPTOR) {
         error_setg(errp, "brlapi__openConnection: %s",
                    brlapi_strerror(brlapi_error_location()));
         g_free(handle);
Signature · 1 line
2.47.2
#1 lore raw
Quoted 7 lines · Stefan Weil via

Compiler warning:

../chardev/baum.c:657:25: warning: comparison between pointer and integer

Use brlapi_fileDescriptor instead of int for brlapi_fd and BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1.

Quoted 8 lines

---

This is a rather old patch which I now use since more than two years to support Braille with QEMU on Windows.

It's a hack (because Windows uses a pointer (64 bit) which is assigned to an int (32 bit), but it seems to work.

Would a code comment pointing out the hack be useful?

Quoted 29 lines

Regards,
Stefan

 chardev/baum.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
chardev/baum.c +2 -2
index f3e8cd27f0..5c3587dda5 100644
@@ -94,7 +94,7 @@ struct BaumChardev {
     Chardev parent;
 
     brlapi_handle_t *brlapi;
-    int brlapi_fd;
+    brlapi_fileDescriptor brlapi_fd;
     unsigned int x, y;
     bool deferred_init;
 
@@ -654,7 +654,7 @@ static void baum_chr_open(Chardev *chr,
     baum->brlapi = handle;
 
     baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
-    if (baum->brlapi_fd == -1) {
+    if (baum->brlapi_fd == BRLAPI_INVALID_FILE_DESCRIPTOR) {
         error_setg(errp, "brlapi__openConnection: %s",
                    brlapi_strerror(brlapi_error_location()));
         g_free(handle);
#2 lore raw

Am 09.08.25 um 08:20 schrieb Markus Armbruster:

Quoted 12 lines
Quoted 10 lines · Stefan Weil via

Compiler warning:

../chardev/baum.c:657:25: warning: comparison between pointer and integer

Use brlapi_fileDescriptor instead of int for brlapi_fd and BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1.

---

Quoted 6 lines
Quoted 5 lines

This is a rather old patch which I now use since more than two years to support Braille with QEMU on Windows.

It's a hack (because Windows uses a pointer (64 bit) which is assigned to an int (32 bit), but it seems to work.

Would a code comment pointing out the hack be useful?

Maybe. Michael, feel free to add such a comment if you take the patch.

Note that there is also a compiler warning for qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum):

warning: passing argument 1 of ‘qemu_set_fd_handler’ makes integer from pointer without a cast [-Wint-conversion]

That would be a good place for the comment.

Stefan

Reviewed-by on v1 1/1
#3 lore raw
In reply to Stefan Weil via

Stefan Weil, le sam. 09 août 2025 08:13:02 +0200, a ecrit:

Quoted 8 lines

Compiler warning:

../chardev/baum.c:657:25: warning: comparison between pointer and integer

Use brlapi_fileDescriptor instead of int for brlapi_fd and BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1.

Thanks!

Quoted 4 lines

---

This is a rather old patch which I now use since more than two years to support Braille with QEMU on Windows.

Just curious: what do you use this Braille support for?

Samuel

Quoted 35 lines

It's a hack (because Windows uses a pointer (64 bit) which is assigned to an int (32 bit), but it seems to work.

Regards,
Stefan

 chardev/baum.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
chardev/baum.c +2 -2
index f3e8cd27f0..5c3587dda5 100644
@@ -94,7 +94,7 @@ struct BaumChardev {
     Chardev parent;
 
     brlapi_handle_t *brlapi;
-    int brlapi_fd;
+    brlapi_fileDescriptor brlapi_fd;
     unsigned int x, y;
     bool deferred_init;
 
@@ -654,7 +654,7 @@ static void baum_chr_open(Chardev *chr,
     baum->brlapi = handle;
 
     baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
-    if (baum->brlapi_fd == -1) {
+    if (baum->brlapi_fd == BRLAPI_INVALID_FILE_DESCRIPTOR) {
         error_setg(errp, "brlapi__openConnection: %s",
                    brlapi_strerror(brlapi_error_location()));
         g_free(handle);
Signature · 1 line
2.47.2
Signature · 7 lines
Samuel
/*
 * Oops. The kernel tried to access some bad page. We'll have to
 * terminate things with extreme prejudice.
*/
die_if_kernel("Oops", regs, error_code);
(From linux/arch/i386/mm/fault.c)				   
#4 lore raw
In reply to Stefan Weil via
Quoted 7 lines · Stefan Weil via

Compiler warning:

../chardev/baum.c:657:25: warning: comparison between pointer and integer

Use brlapi_fileDescriptor instead of int for brlapi_fd and BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1.

Quoted 8 lines

---

This is a rather old patch which I now use since more than two years to support Braille with QEMU on Windows.

It's a hack (because Windows uses a pointer (64 bit) which is assigned to an int (32 bit), but it seems to work.

Queued to the trivial-patches tree, with the following addition:

chardev/baum.c +0 -0
index 5c3587dda5..ad68321504 100644
@@ -665,6 +665,10 @@ static void baum_chr_open(Chardev *chr,
 
     baum->cellCount_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, 

baum_cellCount_timer_cb, baum);

+ /*

+     * On Windows, brlapi_fd is a pointer, which is being used here
+     * as an integer, but in practice it seems to work
+     */
     qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);

}

Thanks,

/mjt