[1/6] Fix latent bug in ser_windows_send_break

Message ID 20230912-serial-exceptions-v1-1-af5097485390@adacore.com
State New
Headers
Series Fix error messages from serial code |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Sept. 12, 2023, 4:27 p.m. UTC
  The ClearCommBreak documentation says:

    If the function fails, the return value is zero.

ser_windows_send_break inverts this check.  This has never been
noticed because the caller doesn't check the result.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770
---
 gdb/ser-mingw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index c0aa5d8d0b9..806f3999385 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -137,7 +137,7 @@  ser_windows_send_break (struct serial *scb)
   /* Delay for 250 milliseconds.  */
   Sleep (250);
 
-  if (ClearCommBreak (h))
+  if (ClearCommBreak (h) == 0)
     return -1;
 
   return 0;