diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-03 21:55:36 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-03 21:55:36 +0000 |
commit | ca3f7d34b92de52ed1d7fb915ebb2972343903a8 (patch) | |
tree | 56c293d9a7d1082965a2520340f25ea9f57db71f /gcc/gcov-io.c | |
parent | 02636da31efc7369d7ebe5a4bb190627ca8150ac (diff) | |
download | gcc-ca3f7d34b92de52ed1d7fb915ebb2972343903a8.tar.gz |
PR gcov-profile/58602
* gcc/gcov-io.c (gcov_open): Open with truncation when mode<0
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207441 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcov-io.c')
-rw-r--r-- | gcc/gcov-io.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index b710f596e37..5ef82f68372 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); } |