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