verify_*.py: Ignore UTF-8 decoding errors

Some of our source files are inherited from other sources, particularly
for microcontroller firmware projects.  We cannot assume they're all
clean UTF-8.  Let's ignore any decoder errors when verifying log
statements and value_string arrays.

Closes: OS#4334
Change-Id: I1e19f4bc6bee46481c6ea743e8334bd4485909be
changes/38/16638/1
Harald Welte 3 years ago
parent bcd5a7b927
commit 8d0605c4fb
  1. 2
      scripts/verify_log_statements.py
  2. 2
      scripts/verify_value_string_arrays_are_terminated.py

@ -66,7 +66,7 @@ def check_file(f):
try:
errors_found = []
file_content = codecs.open(f, "r", "utf-8").read()
file_content = codecs.open(f, "r", "utf-8", errors='ignore').read()
for log in log_statement_re.finditer(file_content):
quoted = log.group(2)

@ -27,7 +27,7 @@ def check_file(f):
global errors_found
if not (f.endswith('.h') or f.endswith('.c') or f.endswith('.cpp')):
return
arrays = value_string_array_re.findall(codecs.open(f, "r", "utf-8").read())
arrays = value_string_array_re.findall(codecs.open(f, "r", "utf-8", errors='ignore').read())
for array_def, name in arrays:
if not terminator_re.search(array_def):
print('ERROR: file contains unterminated value_string %r: %r'

Loading…
Cancel
Save