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
This commit is contained in:
Laurent Alfonsi 2014-02-03 14:55:36 -07:00 committed by Jeff Law
parent 85942f45e9
commit 55428cc329
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2014-02-03 Laurent Aflonsi <laurent.alfonsi@st.com>
PR gcov-profile/58602
* gcc/gcov-io.c (gcov_open): Open with truncation when mode<0
2014-02-03 Jan Hubicka <hubicka@ucw.cz>
PR ipa/59831

View File

@ -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);
}