diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-01-13 12:09:58 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-01-13 12:25:16 -0500 |
commit | 506195754c948948a4940928969ffb07584ae845 (patch) | |
tree | 4a9f67c986a9c57ab4cb2123673c8e8a02f3d8bf /gdb | |
parent | 5bf7e91b2b47295b021ce3a06688d8cfb74e7fab (diff) | |
download | fsf-binutils-gdb-506195754c948948a4940928969ffb07584ae845.zip fsf-binutils-gdb-506195754c948948a4940928969ffb07584ae845.tar.gz fsf-binutils-gdb-506195754c948948a4940928969ffb07584ae845.tar.bz2 |
gdb: bool-ify maybe_add_script_{text,file}
Bool-ify the return type of maybe_add_script_text and
maybe_add_script_file, the loaded parameter and related things.
gdb/ChangeLog:
* auto-load.c (struct loaded_script) <loaded>: Change to bool.
(maybe_add_script_file): Change return type to bool.
(maybe_add_script_text): Change return type and
loaded parameter to bool.
(source_script_file): Adjust.
(execute_script_contents): Adjust.
Change-Id: I59ab5862796fa7d154721b56e2ff8612ad5d734b
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/auto-load.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/gdb/auto-load.c b/gdb/auto-load.c index b6cb79a..b9acb8f 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -563,8 +563,8 @@ struct loaded_script inaccessible), or NULL for loaded_script_texts. */ const char *full_path; - /* Non-zero if this script has been loaded. */ - int loaded; + /* True if this script has been loaded. */ + bool loaded; const struct extension_language_defn *language; }; @@ -650,24 +650,24 @@ get_auto_load_pspace_data_for_loading (struct program_space *pspace) } /* Add script file NAME in LANGUAGE to hash table of PSPACE_INFO. - LOADED 1 if the script has been (is going to) be loaded, 0 otherwise - (such as if it has not been found). + LOADED is true if the script has been (is going to) be loaded, false + otherwise (such as if it has not been found). FULL_PATH is NULL if the script wasn't found. + The result is true if the script was already in the hash table. */ -static int -maybe_add_script_file (struct auto_load_pspace_info *pspace_info, int loaded, +static bool +maybe_add_script_file (struct auto_load_pspace_info *pspace_info, bool loaded, const char *name, const char *full_path, const struct extension_language_defn *language) { struct htab *htab = pspace_info->loaded_script_files.get (); struct loaded_script **slot, entry; - int in_hash_table; entry.name = name; entry.language = language; slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT); - in_hash_table = *slot != NULL; + bool in_hash_table = *slot != NULL; /* If this script is not in the hash table, add it. */ @@ -699,23 +699,23 @@ maybe_add_script_file (struct auto_load_pspace_info *pspace_info, int loaded, } /* Add script contents NAME in LANGUAGE to hash table of PSPACE_INFO. - LOADED 1 if the script has been (is going to) be loaded, 0 otherwise - (such as if it has not been found). + LOADED is true if the script has been (is going to) be loaded, false + otherwise (such as if it has not been found). + The result is true if the script was already in the hash table. */ -static int +static bool maybe_add_script_text (struct auto_load_pspace_info *pspace_info, - int loaded, const char *name, + bool loaded, const char *name, const struct extension_language_defn *language) { struct htab *htab = pspace_info->loaded_script_texts.get (); struct loaded_script **slot, entry; - int in_hash_table; entry.name = name; entry.language = language; slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT); - in_hash_table = *slot != NULL; + bool in_hash_table = *slot != NULL; /* If this script is not in the hash table, add it. */ @@ -891,7 +891,6 @@ source_script_file (struct auto_load_pspace_info *pspace_info, const char *section_name, unsigned int offset, const char *file) { - int in_hash_table; objfile_script_sourcer_func *sourcer; /* Skip this script if support is not compiled in. */ @@ -941,11 +940,10 @@ source_script_file (struct auto_load_pspace_info *pspace_info, section_name, offset); } - in_hash_table = maybe_add_script_file (pspace_info, bool (opened), file, - (opened - ? opened->full_path.get () - : NULL), - language); + bool in_hash_table + = maybe_add_script_file (pspace_info, bool (opened), file, + (opened ? opened->full_path.get (): NULL), + language); /* If this file is not currently loaded, load it. */ if (opened && !in_hash_table) @@ -967,7 +965,6 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info, objfile_script_executor_func *executor; const char *newline, *script_text; const char *name; - int in_hash_table; /* The first line of the script is the name of the script. It must not contain any kind of space character. */ @@ -1029,7 +1026,8 @@ of file %ps."), ext_lang_name (language), name, section_name, objfile_name (objfile)); - in_hash_table = maybe_add_script_text (pspace_info, is_safe, name, language); + bool in_hash_table + = maybe_add_script_text (pspace_info, is_safe, name, language); /* If this file is not currently loaded, load it. */ if (is_safe && !in_hash_table) |