From 55428cc32908fd176450e703d58bb901b75e55db Mon Sep 17 00:00:00 2001 From: Laurent Alfonsi Date: Mon, 3 Feb 2014 14:55:36 -0700 Subject: re PR gcov-profile/58602 (.gcno files not truncated at gcov_close) PR gcov-profile/58602 * gcc/gcov-io.c (gcov_open): Open with truncation when mode<0 From-SVN: r207441 --- gcc/ChangeLog | 5 +++++ gcc/gcov-io.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 118c42e..b46e05a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-02-03 Laurent Aflonsi + + PR gcov-profile/58602 + * gcc/gcov-io.c (gcov_open): Open with truncation when mode<0 + 2014-02-03 Jan Hubicka PR ipa/59831 diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index b710f59..5ef82f6 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -149,9 +149,15 @@ gcov_open (const char *name, int mode) /* pass mode (ignored) for compatibility */ fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR); } - else + else if (mode < 0) + { + /* Write mode - acquire a write-lock. */ + s_flock.l_type = F_WRLCK; + fd = open (name, O_RDWR | O_CREAT | O_TRUNC, 0666); + } + else /* mode == 0 */ { - /* Write mode - acquire a write-lock. */ + /* Read-Write mode - acquire a write-lock. */ s_flock.l_type = F_WRLCK; fd = open (name, O_RDWR | O_CREAT, 0666); } -- cgit v1.1