194aa3
commit d33705c0b020632274318323931695a99753b5be
194aa3
Author: Florian Weimer <fweimer@redhat.com>
194aa3
Date:   Thu Nov 3 12:24:17 2022 +0100
194aa3
194aa3
    scripts/glibcelf.py: Properly report <elf.h> parsing failures
194aa3
    
194aa3
    Without this change, parse failures result in an exception:
194aa3
    
194aa3
    Traceback (most recent call last):
194aa3
      File "tst-glibcelf.py", line 23, in <module>
194aa3
        import glibcelf
194aa3
      File "/path/to/git/scripts/glibcelf.py", line 226, in <module>
194aa3
        _elf_h = _parse_elf_h()
194aa3
      File "/path/to/git/scripts/glibcelf.py", line 221, in _parse_elf_h
194aa3
        result = glibcpp.macro_eval(glibcpp.macro_definitions(tokens), reporter)
194aa3
      File "/path/to/git/scripts/glibcpp.py", line 379, in macro_eval
194aa3
        reporter.error(md.line, 'macro {} redefined'.format(md.name))
194aa3
      File "/path/to/git/scripts/glibcelf.py", line 214, in error
194aa3
        errors += 1
194aa3
    UnboundLocalError: local variable 'errors' referenced before assignment
194aa3
194aa3
diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
194aa3
index 420cb21943b28bba..59aab56ecf9deb3e 100644
194aa3
--- a/scripts/glibcelf.py
194aa3
+++ b/scripts/glibcelf.py
194aa3
@@ -211,7 +211,7 @@ def _parse_elf_h():
194aa3
             self.errors = 0
194aa3
 
194aa3
         def error(self, line, message):
194aa3
-            errors += 1
194aa3
+            self.errors += 1
194aa3
             print('{}:{}: error: {}'.format(path, line, message))
194aa3
 
194aa3
         def note(self, line, message):