* [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
@ 2025-08-09 6:13 ` Stefan Weil via
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil via @ 2025-08-09 6:13 UTC (permalink / raw)
To: Paolo Bonzini, Marc-André Lureau, Samuel Thibault,
Michael Tokarev, rent Vivier
Cc: qemu-devel, qemu-trivial, Stefan Weil
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.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
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(-)
diff --git a/chardev/baum.c b/chardev/baum.c
index f3e8cd27f0..5c3587dda5 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -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.47.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
2025-08-09 6:13 ` Stefan Weil via
(?)
@ 2025-08-09 6:20 ` Markus Armbruster
2025-08-09 6:27 ` Stefan Weil via
-1 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2025-08-09 6:20 UTC (permalink / raw)
To: Stefan Weil via
Cc: Paolo Bonzini, Marc-André Lureau, Samuel Thibault,
Michael Tokarev, rent Vivier, Stefan Weil, qemu-trivial
Stefan Weil via <qemu-devel@nongnu.org> writes:
> 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.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> 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?
> Regards,
> Stefan
>
>
> chardev/baum.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/baum.c b/chardev/baum.c
> index f3e8cd27f0..5c3587dda5 100644
> --- a/chardev/baum.c
> +++ b/chardev/baum.c
> @@ -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);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
2025-08-09 6:20 ` Markus Armbruster
@ 2025-08-09 6:27 ` Stefan Weil via
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil via @ 2025-08-09 6:27 UTC (permalink / raw)
To: Markus Armbruster, Stefan Weil via
Cc: Paolo Bonzini, Marc-André Lureau, Samuel Thibault,
Michael Tokarev, rent Vivier, qemu-trivial
Am 09.08.25 um 08:20 schrieb Markus Armbruster:
> Stefan Weil via <qemu-devel@nongnu.org> writes:
>
>> 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.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
@ 2025-08-09 6:27 ` Stefan Weil via
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil via @ 2025-08-09 6:27 UTC (permalink / raw)
To: Markus Armbruster, Stefan Weil via
Cc: Paolo Bonzini, Marc-André Lureau, Samuel Thibault,
Michael Tokarev, rent Vivier, qemu-trivial
Am 09.08.25 um 08:20 schrieb Markus Armbruster:
> Stefan Weil via <qemu-devel@nongnu.org> writes:
>
>> 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.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
2025-08-09 6:13 ` Stefan Weil via
(?)
(?)
@ 2025-08-10 7:29 ` Samuel Thibault
-1 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2025-08-10 7:29 UTC (permalink / raw)
To: Stefan Weil
Cc: Paolo Bonzini, Marc-André Lureau, Michael Tokarev,
rent Vivier, qemu-devel, qemu-trivial
Stefan Weil, le sam. 09 août 2025 08:13:02 +0200, a ecrit:
> 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.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Thanks!
> ---
>
> 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
> 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(-)
>
> diff --git a/chardev/baum.c b/chardev/baum.c
> index f3e8cd27f0..5c3587dda5 100644
> --- a/chardev/baum.c
> +++ b/chardev/baum.c
> @@ -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.47.2
>
--
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)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH trivial] chardev/baum: Fix compiler warning for Windows builds
2025-08-09 6:13 ` Stefan Weil via
` (2 preceding siblings ...)
(?)
@ 2025-08-10 7:55 ` Michael Tokarev
-1 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2025-08-10 7:55 UTC (permalink / raw)
To: Stefan Weil, Paolo Bonzini, Marc-André Lureau,
Samuel Thibault, rent Vivier
Cc: qemu-devel, qemu-trivial
On 09.08.2025 09:13, Stefan Weil via wrote:
> 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.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> 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:
diff --git a/chardev/baum.c b/chardev/baum.c
index 5c3587dda5..ad68321504 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread