[PATCH trivial] chardev/baum.c: fix error return check for windows

Michael Tokarev posted 1 patch 3 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250809054654.562361-1-mjt@tls.msk.ru
Maintainers: Samuel Thibault <samuel.thibault@ens-lyon.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Michael Tokarev <mjt@tls.msk.ru>, Laurent Vivier <laurent@vivier.eu>
chardev/baum.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH trivial] chardev/baum.c: fix error return check for windows
Posted by Michael Tokarev 3 months, 1 week ago
Commit 3736506e25ac7bb "meson: Fix brlapi compile test for
Windows builds" fixed brlapi configure-time test to use
BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1, b/c on windows,
it is not -1.  But the same test is used at run time when
initing brlapi in chardev/baum.c.  Fix this one too.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 chardev/baum.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chardev/baum.c b/chardev/baum.c
index f3e8cd27f0..ecbcd2e5c6 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -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
Re: [PATCH trivial] chardev/baum.c: fix error return check for windows
Posted by Michael Tokarev 3 months, 1 week ago
On 09.08.2025 08:46, Michael Tokarev wrote:
> Commit 3736506e25ac7bb "meson: Fix brlapi compile test for
> Windows builds" fixed brlapi configure-time test to use
> BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1, b/c on windows,
> it is not -1.  But the same test is used at run time when
> initing brlapi in chardev/baum.c.  Fix this one too.

This patch need "a bit" more work.  Because brlapi_fd is an int
instead of brlapi_fileDescriptor, which is trivial to fix too.
But also, this fd is used for qemu_set_fd_handler(), which is
more interesting.

We had a similar situation in slirp a while back.

> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>   chardev/baum.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/chardev/baum.c b/chardev/baum.c
> index f3e8cd27f0..ecbcd2e5c6 100644
> --- a/chardev/baum.c
> +++ b/chardev/baum.c
> @@ -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);
Re: [PATCH trivial] chardev/baum.c: fix error return check for windows
Posted by Stefan Weil via 3 months, 1 week ago
Am 09.08.25 um 07:59 schrieb Michael Tokarev:

> On 09.08.2025 08:46, Michael Tokarev wrote:
>> Commit 3736506e25ac7bb "meson: Fix brlapi compile test for
>> Windows builds" fixed brlapi configure-time test to use
>> BRLAPI_INVALID_FILE_DESCRIPTOR instead of -1, b/c on windows,
>> it is not -1.  But the same test is used at run time when
>> initing brlapi in chardev/baum.c.  Fix this one too.
>
> This patch need "a bit" more work.  Because brlapi_fd is an int
> instead of brlapi_fileDescriptor, which is trivial to fix too.
> But also, this fd is used for qemu_set_fd_handler(), which is
> more interesting.
>
> We had a similar situation in slirp a while back.


Hi Michael,

I just have sent the patch which I use since 2023.

Thanks

Stefan