From 04215ce6a7477a39d3db43eb3a5e4939e21093d9 Mon Sep 17 00:00:00 2001 From: Nick Owens Date: Fri, 9 May 2025 09:01:48 -0700 Subject: main: suppress -Werror=unused-result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 14.2 + glibc 2.40 produces this warning, converted to an error, which fails the build. setup.c: In function ‘setup_interactively’: setup.c:149:32: error: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 149 | (void) fgets(buf, sizeof(buf), stdin); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.c: In function ‘print_setup_as_args’: main.c:454:24: error: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 454 | (void) fgets(buf, sizeof(buf), stdin); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/main.c | 5 ++++- src/setup.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 28f897f..e4b0cbc 100644 --- a/src/main.c +++ b/src/main.c @@ -451,7 +451,10 @@ static int print_setup_as_args(setup_t *setup, int wait) if (r < 0) goto _out_video; - (void) fgets(buf, sizeof(buf), stdin); + if (fgets(buf, sizeof(buf), stdin) == NULL) { + r = -EBADF; + goto _out_video; + } } _out_video: diff --git a/src/setup.c b/src/setup.c index 7b5cecb..95387e3 100644 --- a/src/setup.c +++ b/src/setup.c @@ -146,7 +146,8 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se if (feof(stdin)) return -EIO; - (void) fgets(buf, sizeof(buf), stdin); + if (fgets(buf, sizeof(buf), stdin) == NULL) + return -EIO; } if (*buf == '\n') { -- cgit v1.2.3