]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR gcov-profile/58602
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Feb 2014 21:55:36 +0000 (21:55 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Feb 2014 21:55:36 +0000 (21:55 +0000)
        * 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

gcc/ChangeLog
gcc/gcov-io.c

index 118c42ee83adff7a82ad0e6731d6d81ef961c315..b46e05a58f1c0df0c772aceadfa98b6e875320f5 100644 (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
index b710f596e378be3b65288785f800b129f26d0c03..5ef82f6837200ad8b1227487b0583908ae6dbffb 100644 (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);
     }