From e8a9d3dc04b3a70e1c8e4194739a574187b75765 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 15 Jul 2018 16:54:03 +0200 Subject: [PATCH] Fix code assuming struct winsize fields are size_t. --- regress/regress.c | 2 +- sh/sh.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/regress/regress.c b/regress/regress.c index 93972071..5f63e6aa 100644 --- a/regress/regress.c +++ b/regress/regress.c @@ -55,7 +55,7 @@ void tenth_last_column(void) tcgetwincurpos(1, &wcp); if ( wcp.wcp_col - ws.ws_col < 10 ) printf("\n"); - printf("\e[%zuG", ws.ws_col - 10); + printf("\e[%zuG", (size_t) (ws.ws_col - 10)); fflush(stdout); } diff --git a/sh/sh.c b/sh/sh.c index 3ff1cc62..07e4f408 100644 --- a/sh/sh.c +++ b/sh/sh.c @@ -95,9 +95,9 @@ void update_env(void) struct winsize ws; if ( tcgetwinsize(0, &ws) == 0 ) { - snprintf(str, sizeof(str), "%zu", ws.ws_col); + snprintf(str, sizeof(str), "%zu", (size_t) ws.ws_col); setenv("COLUMNS", str, 1); - snprintf(str, sizeof(str), "%zu", ws.ws_row); + snprintf(str, sizeof(str), "%zu", (size_t) ws.ws_row); setenv("LINES", str, 1); } }