From beaf220f394984c97395b079eab260b225ee5378 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 29 Oct 2020 18:06:04 +0100 Subject: tiocswinsz: fix compilation error on e.g. ppc64 On some platforms, TIOCSWINSZ has a very large value, > 0x80000000. On some platforms, the `request` argument to `ioctl(3)` is an `int`. For platforms where both of the above is true, gcc will warn (and error out if compiled with `-Werror`) on: ioctl(fd, TIOCSWINSZ, ...) To silence this warning, we need to cast `TIOCSWINSZ` to an integer. However, doing this on platforms where `request` is an `unsigned long` will result in `TIOCSWINSZ` being sign-extended (and thus we end up with an invalid value). It seems that casting to `unsigned int` works in both cases; it silences the long -> int conversion warning, while also preserving the correct value in all cases. --- terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 303a4015..b9e4528a 100644 --- a/terminal.c +++ b/terminal.c @@ -928,7 +928,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, goto close_fds; } - if (ioctl(ptmx, TIOCSWINSZ, + if (ioctl(ptmx, (unsigned int)TIOCSWINSZ, &(struct winsize){.ws_row = 24, .ws_col = 80}) < 0) { LOG_ERRNO("failed to set initial TIOCSWINSZ"); -- cgit v1.3