diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-06 15:24:24 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-06 15:24:24 +0000 |
commit | 5d4123dccd2a24383e09a0d08bb9ea11e849b14b (patch) | |
tree | 93fdd91271bc27e634bffdb53c15783f8bdb3b0e /libgcc | |
parent | 43ac2f2f6bd2bf1281103b4bef4fafaed627039f (diff) | |
download | gcc-5d4123dccd2a24383e09a0d08bb9ea11e849b14b.tar.gz |
PR libgcc/71400
* libgcov-driver-system.c (__gcov_error_file): Disable if IN_GCOV_TOOL.
(get_gcov_error_file): Check __gcov_error_file before trying to
initialize it.
(gcov_error): Always use get_gcov_error_file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237135 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 9 | ||||
-rw-r--r-- | libgcc/libgcov-driver-system.c | 26 |
2 files changed, 21 insertions, 14 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index a003c5171fb..544ea65f102 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,12 @@ +2016-06-05 Aaron Conole <aconole@redhat.com> + Nathan Sidwell <nathan@acm.org> + + PR libgcc/71400 + * libgcov-driver-system.c (__gcov_error_file): Disable if IN_GCOV_TOOL. + (get_gcov_error_file): Check __gcov_error_file before trying to + initialize it. + (gcov_error): Always use get_gcov_error_file. + 2016-06-02 Aaron Conole <aconole@redhat.com> * libgcov-driver-system.c (__gcov_error_file): New. diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c index ff8a521690b..e617afabee1 100644 --- a/libgcc/libgcov-driver-system.c +++ b/libgcc/libgcov-driver-system.c @@ -23,31 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +#if !IN_GCOV_TOOL /* Configured via the GCOV_ERROR_FILE environment variable; it will either be stderr, or a file of the user's choosing. Non-static to prevent multiple gcov-aware shared objects from instantiating their own copies. */ FILE *__gcov_error_file = NULL; +#endif /* A utility function to populate the __gcov_error_file pointer. This should NOT be called outside of the gcov system driver code. */ static FILE * -get_gcov_error_file(void) +get_gcov_error_file (void) { -#if !IN_GCOV_TOOL +#if IN_GCOV_TOOL return stderr; #else - char *gcov_error_filename = getenv ("GCOV_ERROR_FILE"); - - if (gcov_error_filename) + if (!__gcov_error_file) { - FILE *openfile = fopen (gcov_error_filename, "a"); - if (openfile) - __gcov_error_file = openfile; + const char *gcov_error_filename = getenv ("GCOV_ERROR_FILE"); + + if (gcov_error_filename) + __gcov_error_file = fopen (gcov_error_filename, "a"); + if (!__gcov_error_file) + __gcov_error_file = stderr; } - if (!__gcov_error_file) - __gcov_error_file = stderr; return __gcov_error_file; #endif } @@ -60,11 +61,8 @@ gcov_error (const char *fmt, ...) int ret; va_list argp; - if (!__gcov_error_file) - __gcov_error_file = get_gcov_error_file (); - va_start (argp, fmt); - ret = vfprintf (__gcov_error_file, fmt, argp); + ret = vfprintf (get_gcov_error_file (), fmt, argp); va_end (argp); return ret; } |