From 506195754c948948a4940928969ffb07584ae845 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 13 Jan 2021 12:09:58 -0500 Subject: 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) : 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 --- gdb/auto-load.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'gdb') 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) -- cgit v1.1