[PATCH 2/2] Do not bother passing optional argument to WriteConsoleA.

2020-03-08 Thread Hans-Bernhard Broeker
Passing a pointer to a local variable to WriteConsoleA is
not actually needed if we're not going to do anything with
what WriteConsoleA would put in there.

For the wpbuf class the pointer argument was made optional,
so it can be just left out; other call places now pass a
NULL pointer instead.  The local variables `wn' and `n'
are no unused, so they go away.
---
 winsup/cygwin/fhandler_console.cc | 51 ++-
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc 
b/winsup/cygwin/fhandler_console.cc
index 9d7a9e9ea..1c376291f 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2015,7 +2015,6 @@ fhandler_console::char_command (char c)
   if (wincap.has_con_24bit_colors () && !con_is_legacy)
 {
   /* For xterm compatible mode */
-  DWORD wn;
   switch (c)
{
 #if 0 /* These sequences, which are supported by real xterm, are
@@ -2044,17 +2043,17 @@ fhandler_console::char_command (char c)
  wpbuf.put (c);
  if (wincap.has_con_esc_rep ())
/* Just send the sequence */
-   wpbuf.send (get_output_handle (), );
+   wpbuf.send (get_output_handle ());
  else if (last_char && last_char != '\n')
for (int i = 0; i < con.args[0]; i++)
- WriteConsoleA (get_output_handle (), _char, 1, , 0);
+ WriteConsoleA (get_output_handle (), _char, 1, 0, 0);
  break;
case 'r': /* DECSTBM */
  con.scroll_region.Top = con.args[0] ? con.args[0] - 1 : 0;
  con.scroll_region.Bottom = con.args[1] ? con.args[1] - 1 : -1;
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  break;
case 'L': /* IL */
  if (wincap.has_con_broken_il_dl ())
@@ -2072,27 +2071,27 @@ fhandler_console::char_command (char c)
   srBottom - (n-1) - con.b.srWindow.Top + 1,
   y + 1 - con.b.srWindow.Top, x + 1);
  WriteConsoleA (get_output_handle (),
-buf, strlen (buf), , 0);
+buf, strlen (buf), 0, 0);
}
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  wpbuf.put ('T');
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  __small_sprintf (buf, "\033[%d;%dr",
   srTop + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  __small_sprintf (buf, "\033[%d;%dH",
   y + 1 - con.b.srWindow.Top, x + 1);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
}
  else
{
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
}
  break;
case 'M': /* DL */
@@ -2105,22 +2104,22 @@ fhandler_console::char_command (char c)
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  wpbuf.put ('S');
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  __small_sprintf (buf, "\033[%d;%dr",
   srTop + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  __small_sprintf (buf, "\033[%d;%dH",
   y + 1 - con.b.srWindow.Top, x + 1);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
}
  else
{
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());

[PATCH 2/2] Do not bother passing optional argument to WriteConsoleA.

2020-03-08 Thread Hans-Bernhard Bröker

Passing a pointer to a local variable to WriteConsoleA is
not actually needed if we're not going to do anything with
what WriteConsoleA would put in there.

For the wpbuf class the pointer argument was made optional,
so it can be just left out; other call places now pass a
NULL pointer instead.  The local variables `wn' and `n'
are no unused, so they go away.
---
 winsup/cygwin/fhandler_console.cc | 51 ++-
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc 
b/winsup/cygwin/fhandler_console.cc

index 9d7a9e9ea..1c376291f 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2015,7 +2015,6 @@ fhandler_console::char_command (char c)
   if (wincap.has_con_24bit_colors () && !con_is_legacy)
 {
   /* For xterm compatible mode */
-  DWORD wn;
   switch (c)
{
 #if 0 /* These sequences, which are supported by real xterm, are
@@ -2044,17 +2043,17 @@ fhandler_console::char_command (char c)
  wpbuf.put (c);
  if (wincap.has_con_esc_rep ())
/* Just send the sequence */
-   wpbuf.send (get_output_handle (), );
+   wpbuf.send (get_output_handle ());
  else if (last_char && last_char != '\n')
for (int i = 0; i < con.args[0]; i++)
- WriteConsoleA (get_output_handle (), _char, 1, , 0);
+ WriteConsoleA (get_output_handle (), _char, 1, 0, 0);
  break;
case 'r': /* DECSTBM */
  con.scroll_region.Top = con.args[0] ? con.args[0] - 1 : 0;
  con.scroll_region.Bottom = con.args[1] ? con.args[1] - 1 : -1;
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  break;
case 'L': /* IL */
  if (wincap.has_con_broken_il_dl ())
@@ -2072,27 +2071,27 @@ fhandler_console::char_command (char c)
   srBottom - (n-1) - con.b.srWindow.Top + 1,
   y + 1 - con.b.srWindow.Top, x + 1);
  WriteConsoleA (get_output_handle (),
-buf, strlen (buf), , 0);
+buf, strlen (buf), 0, 0);
}
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  wpbuf.put ('T');
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  __small_sprintf (buf, "\033[%d;%dr",
   srTop + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  __small_sprintf (buf, "\033[%d;%dH",
   y + 1 - con.b.srWindow.Top, x + 1);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
}
  else
{
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
}
  break;
case 'M': /* DL */
@@ -2105,22 +2104,22 @@ fhandler_console::char_command (char c)
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  wpbuf.put ('S');
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());
  __small_sprintf (buf, "\033[%d;%dr",
   srTop + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
  __small_sprintf (buf, "\033[%d;%dH",
   y + 1 - con.b.srWindow.Top, x + 1);
- WriteConsoleA (get_output_handle (), buf, strlen (buf), , 0);
+ WriteConsoleA (get_output_handle (), buf, strlen (buf), 0, 0);
}
  else
{
  wpbuf.put (c);
  /* Just send the sequence */
- wpbuf.send (get_output_handle (), );
+ wpbuf.send (get_output_handle ());