]> Savannah Git Hosting - gnulib.git/commitdiff
login_tty tests: Avoid gcc warnings.
authorBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2024 00:22:05 +0000 (02:22 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 28 Apr 2024 08:26:54 +0000 (10:26 +0200)
* 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.

ChangeLog
modules/login_tty-tests
tests/test-login_tty.c

index d8ddf140ed649cc251193bbe7d6628edc40c5b6c..de52b89a3a8adf00ceee65c4b4d7df729e352cd1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
 2024-04-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        c32srtombs,mbsrtoc32s,mbsrtowcs,wcsrtombs: pacify GCC 14
index 306b0ebe12973c172a4695302e2bfaeafd6e0496..aaad143c10377604e75113ececc4d835c3fcb053 100644 (file)
@@ -4,6 +4,7 @@ tests/test-login_tty.c
 Depends-on:
 openpty
 tcgetsid
+ignore-value
 
 configure.ac:
 
index 0aa693147a9c86d5f1f8d10b66b9704ea861402a..ac3b405893651b54a22211457499fef3d03aa0ae 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of login_tty() function.
-   Copyright (C) 2010-2023 Free Software Foundation, Inc.
+   Copyright (C) 2010-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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);