From 39e226e9230ba87e04952c94dc5541879a8e51c9 Mon Sep 17 00:00:00 2001 From: Alexander Sieg Date: Thu, 7 May 2020 22:40:57 +0200 Subject: [PATCH] changes requested by code review --- client.c | 4 ---- fdm.c | 2 +- main.c | 4 ---- server.c | 4 ---- shm.c | 18 ++++++++---------- slave.c | 6 ++++++ terminal.c | 3 +-- 7 files changed, 16 insertions(+), 25 deletions(-) diff --git a/client.c b/client.c index d605c13f..16de33c9 100644 --- a/client.c +++ b/client.c @@ -10,11 +10,7 @@ #include #include -#if __linux__ -#include -#elif __FreeBSD__ #include -#endif #define LOG_MODULE "foot-client" #define LOG_ENABLE_DBG 0 diff --git a/fdm.c b/fdm.c index d35db6a9..d053a376 100644 --- a/fdm.c +++ b/fdm.c @@ -98,7 +98,7 @@ bool fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data) { #if defined(_DEBUG) -#ifdef __FreeBSD__ +#ifndef __FreeBSD__ int flags = fcntl(fd, F_GETFL); if (!(flags & O_NONBLOCK)) { LOG_ERR("FD=%d is in blocking mode", fd); diff --git a/main.c b/main.c index c4e4b599..ecd6a517 100644 --- a/main.c +++ b/main.c @@ -10,11 +10,7 @@ #include #include -#if __linux__ -#include -#elif __FreeBSD__ #include -#endif #include #include diff --git a/server.c b/server.c index cda0bdfd..181f2eea 100644 --- a/server.c +++ b/server.c @@ -8,11 +8,7 @@ #include #include -#if __linux__ -#include -#elif __FreeBSD__ #include -#endif #include diff --git a/shm.c b/shm.c index 0f5f33b2..77b68586 100644 --- a/shm.c +++ b/shm.c @@ -53,9 +53,7 @@ static off_t max_pool_size = 512 * 1024 * 1024; static tll(struct buffer) buffers; static bool can_punch_hole = false; -#ifdef __linux__ static bool can_punch_hole_initialized = false; -#endif #undef MEASURE_SHM_ALLOCS #if defined(MEASURE_SHM_ALLOCS) @@ -280,9 +278,11 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, goto err; } -#ifdef __linux__ if (!can_punch_hole_initialized) { can_punch_hole_initialized = true; +#ifdef __FreeBSD__ + can_punch_hole = false; +#else can_punch_hole = fallocate( pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0; @@ -291,10 +291,8 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, "fallocate(FALLOC_FL_PUNCH_HOLE) not " "supported (%s): expect lower performance", strerror(errno)); } - } -#elif __FreeBSD__ - can_punch_hole = false; #endif + } if (scrollable && !can_punch_hole) { initial_offset = 0; @@ -395,7 +393,7 @@ shm_can_scroll(const struct buffer *buf) #endif } -#ifdef __linux__ +#ifndef __FreeBSD__ static bool wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset) { @@ -432,7 +430,7 @@ wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset) } #endif -#ifdef __linux__ +#ifndef __FreeBSD__ static bool shm_scroll_forward(struct wl_shm *shm, struct buffer *buf, int rows, int top_margin, int top_keep_rows, @@ -538,7 +536,7 @@ err: } #endif -#ifdef __linux__ +#ifndef __FreeBSD__ static bool shm_scroll_reverse(struct wl_shm *shm, struct buffer *buf, int rows, int top_margin, int top_keep_rows, @@ -641,7 +639,7 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows, { #ifdef __FreeBSD__ return false; -#elif __linux__ +#else if (!shm_can_scroll(buf)) return false; diff --git a/slave.c b/slave.c index edd8e2cb..308717e1 100644 --- a/slave.c +++ b/slave.c @@ -10,6 +10,7 @@ #include #include +#include #include #define LOG_MODULE "slave" @@ -93,6 +94,11 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell) goto err; } + if (ioctl(pts, TIOCSCTTY, 0) < 0) { + LOG_ERRNO("failed to configure controlling terminal"); + goto err; + } + if (dup2(pts, STDIN_FILENO) == -1 || dup2(pts, STDOUT_FILENO) == -1 || dup2(pts, STDERR_FILENO) == -1) diff --git a/terminal.c b/terminal.c index 2d6564b1..79e046b3 100644 --- a/terminal.c +++ b/terminal.c @@ -2,10 +2,9 @@ #if __linux__ #include -#elif __FreeBSD__ +#endif #include #include -#endif #include #include #include