From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: login_tty tests: Avoid gcc warnings
Date: Sat, 27 Apr 2024 02:25:28 +0200 [thread overview]
Message-ID: <7466571.8Z0E1hoOst@nimes> (raw)
Compiling a testdir on Ubuntu 24.04, I see these gcc 13.2 warnings:
../../gltests/test-login_tty.c:66:11: warning: ignoring return value of 'freopen' declared with attribute 'warn_unused_result' [-Wunused-result]
../../gltests/test-login_tty.c:79:17: warning: ignoring return value of 'freopen' declared with attribute 'warn_unused_result' [-Wunused-result]
../../gltests/test-login_tty.c:90:17: warning: ignoring return value of 'freopen' declared with attribute 'warn_unused_result' [-Wunused-result]
This patch fixes them. The module 'ignore-value' is needed, since a simple
cast to void has no effect on the warnings.
2024-04-26 Bruno Haible <bruno@clisp.org>
login_tty tests: Avoid gcc warnings.
* tests/test-login_tty.c: Include ignore-value.h.
(main): Ignore the results of the freopen calls.
* modules/login_tty-tests (Depends-on): Add ignore-value.
diff --git a/modules/login_tty-tests b/modules/login_tty-tests
index 306b0ebe12..aaad143c10 100644
--- a/modules/login_tty-tests
+++ b/modules/login_tty-tests
@@ -4,6 +4,7 @@ tests/test-login_tty.c
Depends-on:
openpty
tcgetsid
+ignore-value
configure.ac:
diff --git a/tests/test-login_tty.c b/tests/test-login_tty.c
index 6f3b25c6d4..ac3b405893 100644
--- a/tests/test-login_tty.c
+++ b/tests/test-login_tty.c
@@ -26,6 +26,8 @@
#include <termios.h>
#include <unistd.h>
+#include "ignore-value.h"
+
int
main ()
{
@@ -63,7 +65,7 @@ main ()
for (fd = 0; fd < 3; fd++)
if (!(tcgetpgrp (fd) == getpid ()))
{
- freopen ("err", "w+", stderr);
+ ignore_value (freopen ("err", "w+", stderr));
fprintf (stderr, "tcgetpgrp(%d) = %ld whereas getpid() = %ld\n",
fd, (long) tcgetpgrp (fd), (long) getpid ());
fflush (stderr);
@@ -76,7 +78,7 @@ main ()
{
if (!(errno == ENOSYS))
{
- freopen ("err", "w+", stderr);
+ ignore_value (freopen ("err", "w+", stderr));
fprintf (stderr, "tcgetsid(%d) = -1 and errno = %d\n",
fd, errno);
fflush (stderr);
@@ -87,7 +89,7 @@ main ()
{
if (!(sid == getpid ()))
{
- freopen ("err", "w+", stderr);
+ ignore_value (freopen ("err", "w+", stderr));
fprintf (stderr, "tcgetsid(%d) = %ld whereas getpid() = %ld\n",
fd, (long) tcgetsid (fd), (long) getpid ());
fflush (stderr);
reply other threads:[~2024-04-27 0:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7466571.8Z0E1hoOst@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).