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
This commit is contained in:
Harald Welte 2019-12-17 13:17:54 +01:00
parent bcd5a7b927
commit 8d0605c4fb
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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'