@@ -2292,10 +2292,11 @@ static int write_error(const char *filename)
22922292 return 4 ;
22932293}
22942294
2295- static int store_write_section (int fd , const char * key )
2295+ static ssize_t write_section (int fd , const char * key )
22962296{
22972297 const char * dot ;
2298- int i , success ;
2298+ int i ;
2299+ ssize_t ret ;
22992300 struct strbuf sb = STRBUF_INIT ;
23002301
23012302 dot = memchr (key , '.' , store .baselen );
@@ -2311,15 +2312,16 @@ static int store_write_section(int fd, const char *key)
23112312 strbuf_addf (& sb , "[%.*s]\n" , store .baselen , key );
23122313 }
23132314
2314- success = write_in_full (fd , sb .buf , sb .len ) == sb . len ;
2315+ ret = write_in_full (fd , sb .buf , sb .len );
23152316 strbuf_release (& sb );
23162317
2317- return success ;
2318+ return ret ;
23182319}
23192320
2320- static int store_write_pair (int fd , const char * key , const char * value )
2321+ static ssize_t write_pair (int fd , const char * key , const char * value )
23212322{
2322- int i , success ;
2323+ int i ;
2324+ ssize_t ret ;
23232325 int length = strlen (key + store .baselen + 1 );
23242326 const char * quote = "" ;
23252327 struct strbuf sb = STRBUF_INIT ;
@@ -2359,10 +2361,10 @@ static int store_write_pair(int fd, const char *key, const char *value)
23592361 }
23602362 strbuf_addf (& sb , "%s\n" , quote );
23612363
2362- success = write_in_full (fd , sb .buf , sb .len ) == sb . len ;
2364+ ret = write_in_full (fd , sb .buf , sb .len );
23632365 strbuf_release (& sb );
23642366
2365- return success ;
2367+ return ret ;
23662368}
23672369
23682370static ssize_t find_beginning_of_line (const char * contents , size_t size ,
@@ -2491,8 +2493,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
24912493 }
24922494
24932495 store .key = (char * )key ;
2494- if (! store_write_section (fd , key ) ||
2495- ! store_write_pair (fd , key , value ))
2496+ if (write_section (fd , key ) < 0 ||
2497+ write_pair (fd , key , value ) < 0 )
24962498 goto write_err_out ;
24972499 } else {
24982500 struct stat st ;
@@ -2602,11 +2604,10 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26022604 /* write the first part of the config */
26032605 if (copy_end > copy_begin ) {
26042606 if (write_in_full (fd , contents + copy_begin ,
2605- copy_end - copy_begin ) <
2606- copy_end - copy_begin )
2607+ copy_end - copy_begin ) < 0 )
26072608 goto write_err_out ;
26082609 if (new_line &&
2609- write_str_in_full (fd , "\n" ) != 1 )
2610+ write_str_in_full (fd , "\n" ) < 0 )
26102611 goto write_err_out ;
26112612 }
26122613 copy_begin = store .offset [i ];
@@ -2615,18 +2616,17 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26152616 /* write the pair (value == NULL means unset) */
26162617 if (value != NULL ) {
26172618 if (store .state == START ) {
2618- if (! store_write_section (fd , key ))
2619+ if (write_section (fd , key ) < 0 )
26192620 goto write_err_out ;
26202621 }
2621- if (! store_write_pair (fd , key , value ))
2622+ if (write_pair (fd , key , value ) < 0 )
26222623 goto write_err_out ;
26232624 }
26242625
26252626 /* write the rest of the config */
26262627 if (copy_begin < contents_sz )
26272628 if (write_in_full (fd , contents + copy_begin ,
2628- contents_sz - copy_begin ) <
2629- contents_sz - copy_begin )
2629+ contents_sz - copy_begin ) < 0 )
26302630 goto write_err_out ;
26312631
26322632 munmap (contents , contents_sz );
@@ -2803,7 +2803,7 @@ int git_config_rename_section_in_file(const char *config_filename,
28032803 continue ;
28042804 }
28052805 store .baselen = strlen (new_name );
2806- if (! store_write_section (out_fd , new_name )) {
2806+ if (write_section (out_fd , new_name ) < 0 ) {
28072807 ret = write_error (get_lock_file_path (lock ));
28082808 goto out ;
28092809 }
@@ -2829,7 +2829,7 @@ int git_config_rename_section_in_file(const char *config_filename,
28292829 if (remove )
28302830 continue ;
28312831 length = strlen (output );
2832- if (write_in_full (out_fd , output , length ) != length ) {
2832+ if (write_in_full (out_fd , output , length ) < 0 ) {
28332833 ret = write_error (get_lock_file_path (lock ));
28342834 goto out ;
28352835 }
0 commit comments