@@ -1794,20 +1794,18 @@ static void dump_marks_helper(FILE *f,
1794
1794
static void dump_marks (void )
1795
1795
{
1796
1796
static struct lock_file mark_lock ;
1797
- int mark_fd ;
1798
1797
FILE * f ;
1799
1798
1800
1799
if (!export_marks_file )
1801
1800
return ;
1802
1801
1803
- mark_fd = hold_lock_file_for_update (& mark_lock , export_marks_file , 0 );
1804
- if (mark_fd < 0 ) {
1802
+ if (hold_lock_file_for_update (& mark_lock , export_marks_file , 0 ) < 0 ) {
1805
1803
failure |= error ("Unable to write marks file %s: %s" ,
1806
1804
export_marks_file , strerror (errno ));
1807
1805
return ;
1808
1806
}
1809
1807
1810
- f = fdopen ( mark_fd , "w" );
1808
+ f = fdopen_lock_file ( & mark_lock , "w" );
1811
1809
if (!f ) {
1812
1810
int saved_errno = errno ;
1813
1811
rollback_lock_file (& mark_lock );
@@ -1816,22 +1814,7 @@ static void dump_marks(void)
1816
1814
return ;
1817
1815
}
1818
1816
1819
- /*
1820
- * Since the lock file was fdopen()'ed, it should not be close()'ed.
1821
- * Assign -1 to the lock file descriptor so that commit_lock_file()
1822
- * won't try to close() it.
1823
- */
1824
- mark_lock .fd = -1 ;
1825
-
1826
1817
dump_marks_helper (f , 0 , marks );
1827
- if (ferror (f ) || fclose (f )) {
1828
- int saved_errno = errno ;
1829
- rollback_lock_file (& mark_lock );
1830
- failure |= error ("Unable to write marks file %s: %s" ,
1831
- export_marks_file , strerror (saved_errno ));
1832
- return ;
1833
- }
1834
-
1835
1818
if (commit_lock_file (& mark_lock )) {
1836
1819
failure |= error ("Unable to commit marks file %s: %s" ,
1837
1820
export_marks_file , strerror (errno ));
0 commit comments