* [PATCH][gdb] Improve early exits for env var in debuginfod-support.c
@ 2020-11-16 11:16 Tom de Vries
2020-11-18 15:43 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2020-11-16 11:16 UTC (permalink / raw)
To: gdb-patches
Hi,
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.
Any comments?
Thanks,
- Tom
[gdb] Improve early exits for env var in debuginfod-support.c
gdb/ChangeLog:
2020-11-16 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'".
---
gdb/debuginfod-support.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
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<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 ();
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][gdb] Improve early exits for env var in debuginfod-support.c
2020-11-16 11:16 [PATCH][gdb] Improve early exits for env var in debuginfod-support.c Tom de Vries
@ 2020-11-18 15:43 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2020-11-18 15:43 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
Tom> [gdb] Improve early exits for env var in debuginfod-support.c
Tom> gdb/ChangeLog:
Tom> 2020-11-16 Tom de Vries <tdevries@suse.de>
Tom> * debuginfod-support.c (debuginfod_source_query)
Tom> (debuginfod_debuginfo_query): Also do early exit if
Tom> "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'".
Looks reasonable to me. Thank you.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-18 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 11:16 [PATCH][gdb] Improve early exits for env var in debuginfod-support.c Tom de Vries
2020-11-18 15:43 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox