@@ -3567,15 +3567,21 @@ config_file_t *open_default_config_file(void)
35673567 /* WARN here to make sure user has a good chance of seeing it. */
35683568 RARCH_ERR ("[Config] Failed to create new config file in: \"%s\".\n" ,
35693569 conf_path );
3570- goto error ;
3570+ if (conf )
3571+ config_file_free (conf );
3572+ return NULL ;
35713573 }
35723574
35733575 RARCH_LOG ("[Config] Created new config file in: \"%s\".\n" , conf_path );
35743576 }
35753577#elif defined(OSX )
35763578 if (!fill_pathname_application_data (application_data ,
35773579 sizeof (application_data )))
3578- goto error ;
3580+ {
3581+ if (conf )
3582+ config_file_free (conf );
3583+ return NULL ;
3584+ }
35793585
35803586 /* Group config file with menu configs, remaps, etc: */
35813587 strlcat (application_data , "/config" , sizeof (application_data ));
@@ -3600,7 +3606,9 @@ config_file_t *open_default_config_file(void)
36003606 /* WARN here to make sure user has a good chance of seeing it. */
36013607 RARCH_ERR ("[Config] Failed to create new config file in: \"%s\".\n" ,
36023608 conf_path );
3603- goto error ;
3609+ if (conf )
3610+ config_file_free (conf );
3611+ return NULL ;
36043612 }
36053613
36063614 RARCH_LOG ("[Config] Created new config file in: \"%s\".\n" , conf_path );
@@ -3661,7 +3669,9 @@ config_file_t *open_default_config_file(void)
36613669 /* WARN here to make sure user has a good chance of seeing it. */
36623670 RARCH_ERR ("[Config] Failed to create new config file in: \"%s\".\n" ,
36633671 conf_path );
3664- goto error ;
3672+ if (conf )
3673+ config_file_free (conf );
3674+ return NULL ;
36653675 }
36663676
36673677 RARCH_LOG ("[Config] Created new config file in: \"%s\".\n" ,
@@ -3671,16 +3681,9 @@ config_file_t *open_default_config_file(void)
36713681#endif
36723682
36733683 if (!conf )
3674- goto error ;
3675-
3684+ return NULL ;
36763685 path_set (RARCH_PATH_CONFIG , conf_path );
3677-
36783686 return conf ;
3679-
3680- error :
3681- if (conf )
3682- config_file_free (conf );
3683- return NULL ;
36843687}
36853688
36863689#ifdef RARCH_CONSOLE
@@ -5280,8 +5283,8 @@ void config_get_autoconf_profile_filename(
52805283 "~" , "#" , "%" , "&" , "*" , "{" , "}" , "\\" , ":" , "[" , "]" , "?" , "/" , "|" , "\'" , "\"" ,
52815284 NULL
52825285 };
5286+ size_t i ;
52835287 size_t _len ;
5284- unsigned i ;
52855288
52865289 settings_t * settings = config_st ;
52875290 const char * autoconf_dir = settings -> paths .directory_autoconfig ;
@@ -5290,7 +5293,7 @@ void config_get_autoconf_profile_filename(
52905293 char * sanitised_name = NULL ;
52915294
52925295 if (string_is_empty (device_name ))
5293- goto end ;
5296+ return ;
52945297
52955298 /* Get currently set joypad driver */
52965299 joypad_driver = input_config_get_device_joypad_driver (user );
@@ -5303,7 +5306,7 @@ void config_get_autoconf_profile_filename(
53035306 joypad_driver = joypad_driver_fallback ;
53045307
53055308 if (string_is_empty (joypad_driver ))
5306- goto end ;
5309+ return ;
53075310 }
53085311
53095312 sanitised_name = strdup (device_name );
@@ -5317,10 +5320,9 @@ void config_get_autoconf_profile_filename(
53175320 char * tmp = strstr (sanitised_name ,
53185321 invalid_filename_chars [i ]);
53195322
5320- if (tmp )
5321- * tmp = '_' ;
5322- else
5323+ if (!tmp )
53235324 break ;
5325+ * tmp = '_' ;
53245326 }
53255327 }
53265328
@@ -5333,10 +5335,8 @@ void config_get_autoconf_profile_filename(
53335335 else
53345336 _len = fill_pathname_join_special (s , joypad_driver , sanitised_name , len );
53355337 strlcpy (s + _len , ".cfg" , len - _len );
5336-
5337- end :
5338- if (sanitised_name )
5339- free (sanitised_name );
5338+ free (sanitised_name );
5339+ sanitised_name = NULL ;
53405340}
53415341
53425342/**
@@ -5360,7 +5360,7 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
53605360 const char * joypad_driver = NULL ;
53615361
53625362 if (string_is_empty (device_name ))
5363- goto end ;
5363+ return false ;
53645364
53655365 /* Get currently set joypad driver */
53665366 joypad_driver = input_config_get_device_joypad_driver (user );
@@ -5371,9 +5371,8 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
53715371 * current input device then use the value
53725372 * from the settings struct as a fallback */
53735373 joypad_driver = joypad_driver_fallback ;
5374-
53755374 if (string_is_empty (joypad_driver ))
5376- goto end ;
5375+ return false ;
53775376 }
53785377
53795378 /* Generate autoconfig file path */
@@ -5384,7 +5383,11 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
53845383 if ( !(conf = config_file_new_from_path_to_string (autoconf_file ))
53855384 && !(conf = config_file_new_alloc ())
53865385 )
5387- goto end ;
5386+ {
5387+ if (conf )
5388+ config_file_free (conf );
5389+ return false;
5390+ }
53885391
53895392 /* Update config file */
53905393 config_set_string (conf , "input_driver" ,
@@ -5408,22 +5411,17 @@ bool config_save_autoconf_profile(const char *device_name, unsigned user)
54085411 const struct retro_keybind * bind = & input_config_binds [user ][i ];
54095412 if (bind -> valid )
54105413 {
5411- save_keybind_joykey (
5412- conf , "input" , input_config_bind_map_get_base (i ),
5413- bind , false);
5414- save_keybind_axis (
5415- conf , "input" , input_config_bind_map_get_base (i ),
5416- bind , false);
5414+ save_keybind_joykey (conf , "input" ,
5415+ input_config_bind_map_get_base (i ), bind , false);
5416+ save_keybind_axis (conf , "input" ,
5417+ input_config_bind_map_get_base (i ), bind , false);
54175418 }
54185419 }
54195420
54205421 RARCH_LOG ("[Autoconf] Writing autoconf file for device \"%s\" to \"%s\".\n" , device_name , autoconf_file );
54215422 ret = config_file_write (conf , autoconf_file , false);
5422-
5423- end :
54245423 if (conf )
54255424 config_file_free (conf );
5426-
54275425 return ret ;
54285426}
54295427
@@ -6525,7 +6523,6 @@ void config_save_file_salamander(void)
65256523{
65266524 config_file_t * conf = NULL ;
65276525 const char * libretro_path = path_get (RARCH_PATH_CORE );
6528- bool success = false;
65296526 char config_path [PATH_MAX_LENGTH ];
65306527
65316528 config_path [0 ] = '\0' ;
@@ -6543,17 +6540,18 @@ void config_save_file_salamander(void)
65436540 if ( !(conf = config_file_new_from_path_to_string (config_path ))
65446541 && !(conf = config_file_new_alloc ())
65456542 )
6546- goto end ;
6543+ {
6544+ if (conf )
6545+ config_file_free (conf );
6546+ return ;
6547+ }
65476548
65486549 /* Update config file */
65496550 config_set_path (conf , "libretro_path" , libretro_path );
65506551
65516552 /* Save config file
65526553 * > Only one entry - no need to sort */
6553- success = config_file_write (conf , config_path , false);
6554-
6555- end :
6556- if (success )
6554+ if (config_file_write (conf , config_path , false))
65576555 RARCH_LOG ("[Config] Saving salamander config to: \"%s\".\n" ,
65586556 config_path );
65596557 else
@@ -6569,9 +6567,7 @@ bool input_config_bind_map_get_valid(unsigned bind_index)
65696567{
65706568 const struct input_bind_map * keybind =
65716569 (const struct input_bind_map * )INPUT_CONFIG_BIND_MAP_GET (bind_index );
6572- if (!keybind )
6573- return false;
6574- return keybind -> valid ;
6570+ return (keybind && keybind -> valid );
65756571}
65766572
65776573unsigned input_config_bind_map_get_meta (unsigned bind_index )
@@ -6642,8 +6638,7 @@ void input_config_set_autoconfig_binds(unsigned port, void *data)
66426638 config_file_t * config = (config_file_t * )data ;
66436639 struct retro_keybind * binds = NULL ;
66446640
6645- if ( (port >= MAX_USERS )
6646- || !config )
6641+ if ((port >= MAX_USERS ) || !config )
66476642 return ;
66486643
66496644 binds = input_autoconf_binds [port ];
@@ -6664,14 +6659,12 @@ void input_config_set_autoconfig_binds(unsigned port, void *data)
66646659 }
66656660}
66666661
6667- void input_config_parse_mouse_button (
6668- char * s ,
6662+ void input_config_parse_mouse_button (char * s ,
66696663 void * conf_data , const char * prefix ,
66706664 const char * btn , void * bind_data )
66716665{
66726666 int val ;
6673- char tmp [64 ];
6674- char key [64 ];
6667+ char tmp [64 ], key [64 ];
66756668 config_file_t * conf = (config_file_t * )conf_data ;
66766669 struct retro_keybind * bind = (struct retro_keybind * )bind_data ;
66776670
@@ -6731,16 +6724,15 @@ void input_config_parse_mouse_button(
67316724 }
67326725}
67336726
6734- void input_config_parse_joy_axis (
6735- char * s ,
6727+ void input_config_parse_joy_axis (char * s ,
67366728 void * conf_data , const char * prefix ,
67376729 const char * axis , void * bind_data )
67386730{
67396731 char tmp [64 ];
67406732 char key [64 ];
6741- config_file_t * conf = (config_file_t * )conf_data ;
6742- struct retro_keybind * bind = (struct retro_keybind * )bind_data ;
6743- struct config_entry_list * tmp_a = NULL ;
6733+ config_file_t * conf = (config_file_t * )conf_data ;
6734+ struct retro_keybind * bind = (struct retro_keybind * )bind_data ;
6735+ struct config_entry_list * tmp_a = NULL ;
67446736
67456737 tmp [0 ] = '\0' ;
67466738
@@ -6824,13 +6816,12 @@ void input_config_parse_joy_button(
68246816 void * data , const char * prefix ,
68256817 const char * btn , void * bind_data )
68266818{
6827- char tmp [64 ];
6828- char key [64 ];
6829- config_file_t * conf = (config_file_t * )data ;
6830- struct retro_keybind * bind = (struct retro_keybind * )bind_data ;
6831- struct config_entry_list * tmp_a = NULL ;
6819+ char tmp [64 ], key [64 ];
6820+ config_file_t * conf = (config_file_t * )data ;
6821+ struct retro_keybind * bind = (struct retro_keybind * )bind_data ;
6822+ struct config_entry_list * tmp_a = NULL ;
68326823
6833- tmp [0 ] = '\0' ;
6824+ tmp [0 ] = '\0' ;
68346825
68356826 fill_pathname_join_delim (key , s , "btn" , '_' , sizeof (key ));
68366827
0 commit comments