[newlib-cygwin/main] Cygwin: sys/termios.h: define struct winsize before using it
Corinna Vinschen
corinna@sourceware.org
Fri Jul 18 09:00:30 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=73600d68227e125af24b7de7c3fccbd4eb66ee03
commit 73600d68227e125af24b7de7c3fccbd4eb66ee03
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Jul 18 10:15:30 2025 +0200
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Jul 18 10:53:08 2025 +0200
Cygwin: sys/termios.h: define struct winsize before using it
Long-standing bug in the sys/termios.h file which, for some reason,
has never been encountered before.
STC:
#include <sys/termios.h>
int main()
{
struct winsize win;
tcgetwinsize (0, &win);
}
Result with gcc 12.4.0:
termios-bug.c: In function ‘main’:
termios-bug.c:7:20: warning: passing argument 2 of ‘tcgetwinsize’ from incompatible pointer type [-Wincompatible-pointer-types]
7 | tcgetwinsize (0, &win);
| ^~~~
| |
| struct winsize *
In file included from termios-bug.c:1:
/usr/include/sys/termios.h:304:42: note: expected ‘struct winsize *’ but argument is of type ‘struct winsize *’
304 | int tcgetwinsize(int fd, struct winsize *winsz);
| ~~~~~~~~~~~~~~~~^~~~~
This warning apparently becomes an error with C23.
The reason is that struct winsize is defined in sys/termios.h after
using it as argument type in function declarations. From the compil;er
perspective it's now a different type , regardless of having the same
name.
Move declaration of struct winsize up so it's defined before being used.
Reported-by: Zachary Santer <zsanter@gmail.com>
Suggested-by: Zachary Santer <zsanter@gmail.com>
Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258474.html
Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/include/sys/termios.h | 13 ++++++-------
winsup/cygwin/release/3.6.5 | 5 ++++-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h
index 4c030426cb5f..6cd6407241f0 100644
--- a/winsup/cygwin/include/sys/termios.h
+++ b/winsup/cygwin/include/sys/termios.h
@@ -283,6 +283,12 @@ struct termios
speed_t c_ospeed;
};
+struct winsize
+{
+ unsigned short ws_row, ws_col;
+ unsigned short ws_xpixel, ws_ypixel;
+};
+
#define termio termios
#ifdef __cplusplus
@@ -314,13 +320,6 @@ int tcsetwinsize(int fd, const struct winsize *winsz);
#define cfgetospeed(tp) ((tp)->c_ospeed)
#endif
-/* Extra stuff to make porting stuff easier. */
-struct winsize
-{
- unsigned short ws_row, ws_col;
- unsigned short ws_xpixel, ws_ypixel;
-};
-
#define TIOCGWINSZ (('T' << 8) | 1)
#define TIOCSWINSZ (('T' << 8) | 2)
#define TIOCLINUX (('T' << 8) | 3)
diff --git a/winsup/cygwin/release/3.6.5 b/winsup/cygwin/release/3.6.5
index 471a12a916af..402c8abaeef9 100644
--- a/winsup/cygwin/release/3.6.5
+++ b/winsup/cygwin/release/3.6.5
@@ -1,4 +1,7 @@
Fixes:
------
-Fix two minor bugs in clock and POSIX timer handling.
+- Fix two minor bugs in clock and POSIX timer handling.
+
+- Fix an ordering problem in sys/termios.h.
+ Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258474.html
More information about the Cygwin-cvs
mailing list