PR #22456 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22456 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22456.patch
fixup 08d327e When an uchar is set to -1, it will become 255 when read as an int. Duplicate variables for two terminal types can also avoid unused variable warnings. (cherry picked from commit 3f10a054dc8e5af5aeb9450e3bdea1ffcce91dd7) Signed-off-by: nyanmisaka <[email protected]> Signed-off-by: Kacper Michajłow <[email protected]> From b6db764c8636410264afa40a23f3d20bcfc8b0c3 Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Mon, 9 Mar 2026 21:51:03 +0800 Subject: [PATCH] fftools/ffmpeg: fix read_key() always return 255 when there was no input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixup 08d327e When an uchar is set to -1, it will become 255 when read as an int. Duplicate variables for two terminal types can also avoid unused variable warnings. (cherry picked from commit 3f10a054dc8e5af5aeb9450e3bdea1ffcce91dd7) Signed-off-by: nyanmisaka <[email protected]> Signed-off-by: Kacper Michajłow <[email protected]> --- fftools/ffmpeg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index c2c85d46bd..b394243f59 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -253,7 +253,6 @@ void term_init(void) /* read a key without blocking */ static int read_key(void) { - unsigned char ch = -1; #if HAVE_TERMIOS_H int n = 1; struct timeval tv; @@ -265,6 +264,7 @@ static int read_key(void) tv.tv_usec = 0; n = select(1, &rfds, NULL, NULL, &tv); if (n > 0) { + unsigned char ch; n = read(0, &ch, 1); if (n == 1) return ch; @@ -289,6 +289,7 @@ static int read_key(void) } //Read it if(nchars != 0) { + unsigned char ch; if (read(0, &ch, 1) == 1) return ch; return 0; @@ -300,7 +301,7 @@ static int read_key(void) if(kbhit()) return(getch()); #endif - return ch; + return -1; } static int decode_interrupt_cb(void *ctx) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
