From patchwork Tue Jun 20 13:37:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 21134 Received: (qmail 101867 invoked by alias); 20 Jun 2017 13:37:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 101853 invoked by uid 89); 20 Jun 2017 13:37:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Jun 2017 13:37:43 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A047B40F0D for ; Tue, 20 Jun 2017 13:37:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A047B40F0D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A047B40F0D Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB54C709E6; Tue, 20 Jun 2017 13:37:38 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [commit/obvious] Use '::iterator' instead of '::const_iterator' on environ.c (and fix breakage on early versions of libstdc++) Date: Tue, 20 Jun 2017 09:37:37 -0400 Message-Id: <20170620133737.8161-1-sergiodj@redhat.com> X-IsSubscribed: yes Even though C++11 supports modifying containers using a const_iterator (e.g., calling the 'erase' method of a std::vector), early versions of libstdc++ did not implement that. Some of our buildslaves are using these versions (e.g., the AArch64 buildslave uses gcc 4.8.8), and my previous commit causes a breakage on them. The solution is simple: just use a normal iterator, without const. gdb/ChangeLog: 2017-06-20 Sergio Durigan Junior * common/environ.c (gdb_environ::unset): Use '::iterator' instead of '::const_iterator'. --- gdb/ChangeLog | 5 +++++ gdb/common/environ.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 77001fa..f4e2b08 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-06-20 Sergio Durigan Junior + * common/environ.c (gdb_environ::unset): Use '::iterator' instead + of '::const_iterator'. + +2017-06-20 Sergio Durigan Junior + * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/environ-selftests.c'. (SUBDIR_UNITTESTS_OBS): Add 'environ-selftests.o'. diff --git a/gdb/common/environ.c b/gdb/common/environ.c index 20f8aba..2d13957 100644 --- a/gdb/common/environ.c +++ b/gdb/common/environ.c @@ -116,8 +116,8 @@ gdb_environ::unset (const char *var) /* We iterate until '.cend () - 1' because the last element is always NULL. */ - for (std::vector::const_iterator el = m_environ_vector.cbegin (); - el != m_environ_vector.cend () - 1; + for (std::vector::iterator el = m_environ_vector.begin (); + el != m_environ_vector.end () - 1; ++el) if (match_var_in_string (*el, var, len)) {