From patchwork Thu Nov 3 11:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 59825 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F1063858425 for ; Thu, 3 Nov 2022 11:29:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1063858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667474971; bh=If7rQA9NWcDvsYH6oESz1GMwQd9mNjo3T6S6X4rnJEs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kHURKW1Q+I9vD2ofyyastmGh+Dk6OQe6bLp++Q67N68YVO+2JquHP6mQ9BWl1fVoJ 7k/0QSgPDkHhDlT1jBMfroHjuUeaPPn2d7FTTtbb9NuOelPIy+DhDlnJjLgD5sAL19 69hrdsfZXEXo11PFCjg+o+alz0+XWn3KMLYHD/Nc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 54D7D3858D37 for ; Thu, 3 Nov 2022 11:29:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54D7D3858D37 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-ouh7G1xAPMeWXKm4N7w53Q-1; Thu, 03 Nov 2022 07:29:07 -0400 X-MC-Unique: ouh7G1xAPMeWXKm4N7w53Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 01B811C0A104 for ; Thu, 3 Nov 2022 11:29:07 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 681611415123 for ; Thu, 3 Nov 2022 11:29:06 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] scripts/glibcelf.py: Properly report parsing failures Date: Thu, 03 Nov 2022 12:29:05 +0100 Message-ID: <87r0ykff9a.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Without this change, parse failures result in an exception: Traceback (most recent call last): File "tst-glibcelf.py", line 23, in import glibcelf File "/path/to/git/scripts/glibcelf.py", line 226, in _elf_h = _parse_elf_h() File "/path/to/git/scripts/glibcelf.py", line 221, in _parse_elf_h result = glibcpp.macro_eval(glibcpp.macro_definitions(tokens), reporter) File "/path/to/git/scripts/glibcpp.py", line 379, in macro_eval reporter.error(md.line, 'macro {} redefined'.format(md.name)) File "/path/to/git/scripts/glibcelf.py", line 214, in error errors += 1 UnboundLocalError: local variable 'errors' referenced before assignment --- scripts/glibcelf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872 diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py index 420cb21943..59aab56ecf 100644 --- a/scripts/glibcelf.py +++ b/scripts/glibcelf.py @@ -211,7 +211,7 @@ def _parse_elf_h(): self.errors = 0 def error(self, line, message): - errors += 1 + self.errors += 1 print('{}:{}: error: {}'.format(path, line, message)) def note(self, line, message):