aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-11-18 22:15:50 +0100
committerTom de Vries <tdevries@suse.de>2020-11-18 22:15:50 +0100
commitc44191f8e316f2f4d72d78aaca54a1811840dc70 (patch)
tree5b4deba13c27352b4f91391c91b05ba2e3632c8c
parent7cb2893dfab189edce07144259db882a34e8c93b (diff)
downloadgdb-c44191f8e316f2f4d72d78aaca54a1811840dc70.zip
gdb-c44191f8e316f2f4d72d78aaca54a1811840dc70.tar.gz
gdb-c44191f8e316f2f4d72d78aaca54a1811840dc70.tar.bz2
[gdb] Improve early exits for env var in debuginfod-support.c
There's an early exit in libdebuginfod's debuginfod_query_server, which checks both for: - getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL, and - (getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'. In debuginfod_source_query and debuginfod_debuginfo_query (which both end up calling debuginfod_query_server) there are also early exits checking the same env var, but those just check for NULL. Make the early exit tests in debuginfod-support.c match those in libdebuginfod. gdb/ChangeLog: 2020-11-18 Tom de Vries <tdevries@suse.de> * debuginfod-support.c (debuginfod_source_query) (debuginfod_debuginfo_query): Also do early exit if "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'".
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/debuginfod-support.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 49b2511..18c8c0d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2020-11-18 Tom de Vries <tdevries@suse.de>
+ * debuginfod-support.c (debuginfod_source_query)
+ (debuginfod_debuginfo_query): Also do early exit if
+ "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'".
+
+2020-11-18 Tom de Vries <tdevries@suse.de>
+
* gdbtypes.c (update_static_array_size): Fix -Werror=bool-compare
warning.
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index ae0f4c6..a7c76ab 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -111,7 +111,8 @@ debuginfod_source_query (const unsigned char *build_id,
const char *srcpath,
gdb::unique_xmalloc_ptr<char> *destname)
{
- if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL)
+ const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR);
+ if (urls_env_var == NULL || urls_env_var[0] == '\0')
return scoped_fd (-ENOSYS);
debuginfod_client_up c = debuginfod_init ();
@@ -147,7 +148,8 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname)
{
- if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL)
+ const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR);
+ if (urls_env_var == NULL || urls_env_var[0] == '\0')
return scoped_fd (-ENOSYS);
debuginfod_client_up c = debuginfod_init ();