@@ -1794,20 +1794,18 @@ static void dump_marks_helper(FILE *f,
17941794static void dump_marks (void )
17951795{
17961796 static struct lock_file mark_lock ;
1797- int mark_fd ;
17981797 FILE * f ;
17991798
18001799 if (!export_marks_file )
18011800 return ;
18021801
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 ) {
18051803 failure |= error ("Unable to write marks file %s: %s" ,
18061804 export_marks_file , strerror (errno ));
18071805 return ;
18081806 }
18091807
1810- f = fdopen ( mark_fd , "w" );
1808+ f = fdopen_lock_file ( & mark_lock , "w" );
18111809 if (!f ) {
18121810 int saved_errno = errno ;
18131811 rollback_lock_file (& mark_lock );
@@ -1816,22 +1814,7 @@ static void dump_marks(void)
18161814 return ;
18171815 }
18181816
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-
18261817 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-
18351818 if (commit_lock_file (& mark_lock )) {
18361819 failure |= error ("Unable to commit marks file %s: %s" ,
18371820 export_marks_file , strerror (errno ));
0 commit comments