From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id J++8MIhfsl9WXAAAWB0awg (envelope-from ) for ; Mon, 16 Nov 2020 06:16:24 -0500 Received: by simark.ca (Postfix, from userid 112) id BAD351F08B; Mon, 16 Nov 2020 06:16:24 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3AA781E58E for ; Mon, 16 Nov 2020 06:16:24 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FD583857C6D; Mon, 16 Nov 2020 11:16:23 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id EE5583857C6D for ; Mon, 16 Nov 2020 11:16:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EE5583857C6D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 11752AD87 for ; Mon, 16 Nov 2020 11:16:20 +0000 (UTC) Date: Mon, 16 Nov 2020 12:16:18 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Improve early exits for env var in debuginfod-support.c Message-ID: <20201116111616.GA3020@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "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 * 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 *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 ();