This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use an alias to `ptsname_r' in login/tst-ptsname.c


When compiled with `-O3', inlining causes GCC to realize that one of the
tests calls `ptsname_r' with a NULL buffer and error out when compiling
with -Wnonnull.

Declare `ptsname_r_alias' and alias it to `ptsname_r' to avoid this.

ChangeLog:

2017-05-24  Arjun Shankar  <arjun.is@lostca.se>

	* login/tst-ptsname.c (ptsname_r_alias): New declaration.
	(do_single_test): Use ptsname_r_alias instead of ptsname_r.
---
 login/tst-ptsname.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/login/tst-ptsname.c b/login/tst-ptsname.c
index be8744d..dbc8d19 100644
--- a/login/tst-ptsname.c
+++ b/login/tst-ptsname.c
@@ -27,11 +27,16 @@
 #define DEV_TTY		"/dev/tty"
 #define PTSNAME_EINVAL	"./ptsname-einval"
 
+/* When compiled with `-O3', inlining causes GCC to realize that one of the
+   tests calls `ptsname_r' with a NULL buffer and error out when compiling
+   with -Wnonnull. To avoid this, we use an alias instead.  */
+int ptsname_r_alias (int, char *, size_t) __asm__ ("ptsname_r");
+
 static int
 do_single_test (int fd, char *buf, size_t buflen, int expected_err)
 {
 
-  int ret = ptsname_r (fd, buf, buflen);
+  int ret = ptsname_r_alias (fd, buf, buflen);
   int err = errno;
 
   if (expected_err == 0)
-- 
2.9.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]