From: Tom de Vries Date: Wed, 18 Nov 2020 21:15:50 +0000 (+0100) Subject: [gdb] Improve early exits for env var in debuginfod-support.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c44191f8e316f2f4d72d78aaca54a1811840dc70;p=binutils-gdb.git [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 * debuginfod-support.c (debuginfod_source_query) (debuginfod_debuginfo_query): Also do early exit if "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'". --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 49b2511cae2..18c8c0dc08e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-11-18 Tom de Vries + + * 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 * gdbtypes.c (update_static_array_size): Fix -Werror=bool-compare diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index ae0f4c6c437..a7c76ab6134 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 *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 *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 ();