diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-01-13 11:44:24 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-01-13 11:44:24 -0500 |
commit | 5e12f48ffbf5eba4524fdbae341f091c7cd0cb72 (patch) | |
tree | 984056816a088262765391f58e72580130f584a4 | |
parent | 54ca900277f2abe483f6c747452a528a0e804b62 (diff) | |
download | binutils-gdb-5e12f48ffbf5eba4524fdbae341f091c7cd0cb72.tar.gz |
gdb: bool-ify file_is_auto_load_safe
Make it return bool and change the advice_printed to bool as well. Move
doc to header file.
gdb/ChangeLog:
* auto-load.h (file_is_auto_load_safe): Change return type to
bool, move comment here.
* auto-load.c (file_is_auto_load_safe): Change return type and
advice_printed to bool. Move comment to header.
Change-Id: Ia7395e7cea8880377800240833316e4be5251d49
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/auto-load.c | 20 | ||||
-rw-r--r-- | gdb/auto-load.h | 12 |
3 files changed, 24 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a4731898d48..d0b78c708d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2021-01-13 Simon Marchi <simon.marchi@polymtl.ca> + * auto-load.h (file_is_auto_load_safe): Change return type to + bool, move comment here. + * auto-load.c (file_is_auto_load_safe): Change return type and + advice_printed to bool. Move comment to header. + +2021-01-13 Simon Marchi <simon.marchi@polymtl.ca> + * jit.c (jit_debug_printf): New, use throughout file. 2021-01-12 Simon Marchi <simon.marchi@polymtl.ca> diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 6aee2f9ca41..7b4cd73ea57 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -461,19 +461,13 @@ filename_is_in_auto_load_safe_path_vec (const char *filename, return 0; } -/* Return 1 if FILENAME is located in one of the directories of - AUTO_LOAD_SAFE_PATH. Otherwise call warning and return 0. FILENAME does - not have to be an absolute path. +/* See auto-load.h. */ - Existence of FILENAME is not checked. Function will still give a warning - even if the caller would quietly skip non-existing file in unsafe - directory. */ - -int +bool file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...) { gdb::unique_xmalloc_ptr<char> filename_real; - static int advice_printed = 0; + static bool advice_printed = false; if (debug_auto_load) { @@ -485,11 +479,11 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...) } if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) - return 1; + return true; auto_load_safe_path_vec_update (); if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) - return 1; + return true; warning (_("File \"%ps\" auto-loading has been declined by your " "`auto-load safe-path' set to \"%s\"."), @@ -531,10 +525,10 @@ For more information about this security protection see the\n\ \tinfo \"(gdb)Auto-loading safe path\"\n"), filename_real.get (), home_config.c_str (), home_config.c_str ()); - advice_printed = 1; + advice_printed = true; } - return 0; + return false; } /* For scripts specified in .debug_gdb_scripts, multiple objfiles may load diff --git a/gdb/auto-load.h b/gdb/auto-load.h index 58cd993d90a..c644b4694ac 100644 --- a/gdb/auto-load.h +++ b/gdb/auto-load.h @@ -44,8 +44,16 @@ extern struct cmd_list_element **auto_load_set_cmdlist_get (void); extern struct cmd_list_element **auto_load_show_cmdlist_get (void); extern struct cmd_list_element **auto_load_info_cmdlist_get (void); -extern int file_is_auto_load_safe (const char *filename, - const char *debug_fmt, ...) +/* Return true if FILENAME is located in one of the directories of + AUTO_LOAD_SAFE_PATH. Otherwise call warning and return false. FILENAME does + not have to be an absolute path. + + Existence of FILENAME is not checked. Function will still give a warning + even if the caller would quietly skip non-existing file in unsafe + directory. */ + +extern bool file_is_auto_load_safe (const char *filename, + const char *debug_fmt, ...) ATTRIBUTE_PRINTF (2, 3); extern int auto_load_gdb_scripts_enabled |