Skip to content

Commit 5fb125e

Browse files
committed
unix rtlib: Check ioctl(TIOCGWINSZ) result
It should be a bit cleaner this way. (cherry picked from commit 953eabf)
1 parent 064acc9 commit 5fb125e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/rtlib/unix/hinit.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,16 @@ void fb_hRecheckConsoleSize( int requery_cursorpos )
182182
/* Try to query the terminal size */
183183
/* Try TIOCGWINSZ */
184184
struct winsize win = { 0, 0, 0, 0 };
185-
ioctl( STDOUT_FILENO, TIOCGWINSZ, &win );
185+
if( ioctl( STDOUT_FILENO, TIOCGWINSZ, &win ) != 0 ) {
186186
#ifdef HOST_LINUX
187-
if( win.ws_row == 0 || win.ws_col == 0 ) {
188187
/* Try an escape sequence */
189188
int r, c;
190189
if( fb_hTermQuery( SEQ_QUERY_WINDOW, &r, &c ) ) {
191190
win.ws_row = r;
192191
win.ws_col = c;
193192
}
194-
}
195193
#endif
194+
}
196195

197196
/* Fallback to defaults if all above queries failed */
198197
/* Besides probably being correct, this also means we don't have to

0 commit comments

Comments
 (0)