@@ -2247,10 +2247,11 @@ static int write_error(const char *filename)
22472247 return 4 ;
22482248}
22492249
2250- static int store_write_section (int fd , const char * key )
2250+ static ssize_t write_section (int fd , const char * key )
22512251{
22522252 const char * dot ;
2253- int i , success ;
2253+ int i ;
2254+ ssize_t ret ;
22542255 struct strbuf sb = STRBUF_INIT ;
22552256
22562257 dot = memchr (key , '.' , store .baselen );
@@ -2266,15 +2267,16 @@ static int store_write_section(int fd, const char *key)
22662267 strbuf_addf (& sb , "[%.*s]\n" , store .baselen , key );
22672268 }
22682269
2269- success = write_in_full (fd , sb .buf , sb .len ) == sb . len ;
2270+ ret = write_in_full (fd , sb .buf , sb .len );
22702271 strbuf_release (& sb );
22712272
2272- return success ;
2273+ return ret ;
22732274}
22742275
2275- static int store_write_pair (int fd , const char * key , const char * value )
2276+ static ssize_t write_pair (int fd , const char * key , const char * value )
22762277{
2277- int i , success ;
2278+ int i ;
2279+ ssize_t ret ;
22782280 int length = strlen (key + store .baselen + 1 );
22792281 const char * quote = "" ;
22802282 struct strbuf sb = STRBUF_INIT ;
@@ -2314,10 +2316,10 @@ static int store_write_pair(int fd, const char *key, const char *value)
23142316 }
23152317 strbuf_addf (& sb , "%s\n" , quote );
23162318
2317- success = write_in_full (fd , sb .buf , sb .len ) == sb . len ;
2319+ ret = write_in_full (fd , sb .buf , sb .len );
23182320 strbuf_release (& sb );
23192321
2320- return success ;
2322+ return ret ;
23212323}
23222324
23232325static ssize_t find_beginning_of_line (const char * contents , size_t size ,
@@ -2446,8 +2448,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
24462448 }
24472449
24482450 store .key = (char * )key ;
2449- if (! store_write_section (fd , key ) ||
2450- ! store_write_pair (fd , key , value ))
2451+ if (write_section (fd , key ) < 0 ||
2452+ write_pair (fd , key , value ) < 0 )
24512453 goto write_err_out ;
24522454 } else {
24532455 struct stat st ;
@@ -2557,11 +2559,10 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
25572559 /* write the first part of the config */
25582560 if (copy_end > copy_begin ) {
25592561 if (write_in_full (fd , contents + copy_begin ,
2560- copy_end - copy_begin ) <
2561- copy_end - copy_begin )
2562+ copy_end - copy_begin ) < 0 )
25622563 goto write_err_out ;
25632564 if (new_line &&
2564- write_str_in_full (fd , "\n" ) != 1 )
2565+ write_str_in_full (fd , "\n" ) < 0 )
25652566 goto write_err_out ;
25662567 }
25672568 copy_begin = store .offset [i ];
@@ -2570,18 +2571,17 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
25702571 /* write the pair (value == NULL means unset) */
25712572 if (value != NULL ) {
25722573 if (store .state == START ) {
2573- if (! store_write_section (fd , key ))
2574+ if (write_section (fd , key ) < 0 )
25742575 goto write_err_out ;
25752576 }
2576- if (! store_write_pair (fd , key , value ))
2577+ if (write_pair (fd , key , value ) < 0 )
25772578 goto write_err_out ;
25782579 }
25792580
25802581 /* write the rest of the config */
25812582 if (copy_begin < contents_sz )
25822583 if (write_in_full (fd , contents + copy_begin ,
2583- contents_sz - copy_begin ) <
2584- contents_sz - copy_begin )
2584+ contents_sz - copy_begin ) < 0 )
25852585 goto write_err_out ;
25862586
25872587 munmap (contents , contents_sz );
@@ -2758,7 +2758,7 @@ int git_config_rename_section_in_file(const char *config_filename,
27582758 continue ;
27592759 }
27602760 store .baselen = strlen (new_name );
2761- if (! store_write_section (out_fd , new_name )) {
2761+ if (write_section (out_fd , new_name ) < 0 ) {
27622762 ret = write_error (get_lock_file_path (lock ));
27632763 goto out ;
27642764 }
@@ -2784,7 +2784,7 @@ int git_config_rename_section_in_file(const char *config_filename,
27842784 if (remove )
27852785 continue ;
27862786 length = strlen (output );
2787- if (write_in_full (out_fd , output , length ) != length ) {
2787+ if (write_in_full (out_fd , output , length ) < 0 ) {
27882788 ret = write_error (get_lock_file_path (lock ));
27892789 goto out ;
27902790 }
0 commit comments