[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] test-open: avoid compilation error with -D_FORTIFY_SOURCE=2

From: Paul Eggert
Subject: Re: [PATCH] test-open: avoid compilation error with -D_FORTIFY_SOURCE=2
Date: Thu, 05 Dec 2013 09:25:27 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 12/04/2013 11:51 AM, Paul Eggert wrote:
> or we can change the test case to not tickle the bug.

I did the latter, as follows.  Maybe at some point this
should be filed as a bug against glibc, since the bug occurs
even with _FORTIFY_SOURCE defined to 1 and that isn't supposed
to break conforming programs.

 ChangeLog         |  9 +++++++++
 tests/test-open.h | 11 ++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index cdf69fa..1f2b13c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-12-05  Paul Eggert  <address@hidden>
+    open-tests: port to glibc with _FORTIFY_SOURCE and -O1
+    Problem reported by Daiki Ueno in:
+    http://lists.gnu.org/archive/html/bug-gnulib/2013-06/msg00052.html
+    * tests/test-open.h (__always_inline):
+    New macro, if not already defined.
+    (test_open): Use it.
 2013-12-04  Eric Blake  <address@hidden>
     include_next: minimize code duplication
diff --git a/tests/test-open.h b/tests/test-open.h
index babb239..ff44b3e 100644
--- a/tests/test-open.h
+++ b/tests/test-open.h
@@ -16,13 +16,22 @@
 /* Written by Bruno Haible <address@hidden>, 2007.  */
+/* Make test_open always inline if we're using Fortify, which defines
+   __always_inline to do that.  Do nothing otherwise.  This works
+   around a glibc bug whereby 'open' cannot be used as a function
+   pointer when _FORTIFY_SOURCE is positive.  */
+#ifndef __always_inline
+#define __always_inline
 /* This file is designed to test both open(n,buf[,mode]) and
    openat(AT_FDCWD,n,buf[,mode]).  FUNC is the function to test.
    Assumes that BASE and ASSERT are already defined, and that
    appropriate headers are already included.  If PRINT, warn before
    skipping symlink tests with status 77.  */
-static int
+static int __always_inline
 test_open (int (*func) (char const *, int, ...), bool print)
   int fd;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]