This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10065 )
Change subject: scripts/verify_log_statements.py: on parse error, print file
......................................................................
scripts/verify_log_statements.py: on parse error, print file
If string eval encounters an uncovered parse error, it's useful to know which
file it happened in.
Change-Id: I5fe9a3bbdbfb8a995f24596bf09e70ca5bb3fe8a
---
M scripts/verify_log_statements.py
1 file changed, 45 insertions(+), 42 deletions(-)
Approvals:
Neels Hofmeyr: Looks good to me, approved; Verified
diff --git a/scripts/verify_log_statements.py b/scripts/verify_log_statements.py
index 567a96a..9a9cd1b 100755
--- a/scripts/verify_log_statements.py
+++ b/scripts/verify_log_statements.py
@@ -63,59 +63,62 @@
if not (f.endswith('.h') or f.endswith('.c') or f.endswith('.cpp')):
return []
- errors_found = []
+ try:
+ errors_found = []
- file_content = codecs.open(f, "r", "utf-8").read()
+ file_content = codecs.open(f, "r", "utf-8").read()
- for log in log_statement_re.finditer(file_content):
- quoted = log.group(2)
+ for log in log_statement_re.finditer(file_content):
+ quoted = log.group(2)
- # Skip 'LOG("bla" fmt )' strings that typically appear as #defines.
- if fmt_re.match(quoted):
- if debug:
- errors_found.append(error_found(f, log.start(), 'Skipping define', log.group(0)))
- continue
+ # Skip 'LOG("bla" fmt )' strings that typically appear as #defines.
+ if fmt_re.match(quoted):
+ if debug:
+ errors_found.append(error_found(f, log.start(), 'Skipping define', log.group(0)))
+ continue
- # Drop PRI* parts of 'LOG("bla %"PRIu64" foo")'
- for n in (16,32,64):
- quoted = quoted.replace('PRIu' + str(n), '')
- quoted = quoted.replace('PRId' + str(n), '')
- quoted = ''.join(osmo_stringify_re.split(quoted))
+ # Drop PRI* parts of 'LOG("bla %"PRIu64" foo")'
+ for n in (16,32,64):
+ quoted = quoted.replace('PRIu' + str(n), '')
+ quoted = quoted.replace('PRId' + str(n), '')
+ quoted = ''.join(osmo_stringify_re.split(quoted))
- # Use py eval to join separate string constants: drop any tabs/newlines
- # that are not in quotes, between separate string constants.
- try:
- quoted = eval('(' + quoted + '\n)' )
- except:
- # hopefully eval broke because of some '## args' macro def
- if debug:
- ignored.append(error_found(f, log.start(), 'Ignoring', log.group(0)))
- continue
+ # Use py eval to join separate string constants: drop any tabs/newlines
+ # that are not in quotes, between separate string constants.
+ try:
+ quoted = eval('(' + quoted + '\n)' )
+ except:
+ # hopefully eval broke because of some '## args' macro def
+ if debug:
+ ignored.append(error_found(f, log.start(), 'Ignoring', log.group(0)))
+ continue
- # check for errors...
+ # check for errors...
- # final newline
- if not quoted.endswith('\n'):
- errors_found.append(error_found(f, log.start(), 'Missing final newline', log.group(0)))
+ # final newline
+ if not quoted.endswith('\n'):
+ errors_found.append(error_found(f, log.start(), 'Missing final newline', log.group(0)))
- # disallowed chars and extra newlines
- for c in quoted[:-1]:
- if not c.isprintable() and not c == '\t':
- if c == '\n':
- msg = 'Extraneous newline'
- else:
- msg = 'Illegal char'
- errors_found.append(error_found(f, log.start(), msg + ' %r' % c, log.group(0)))
+ # disallowed chars and extra newlines
+ for c in quoted[:-1]:
+ if not c.isprintable() and not c == '\t':
+ if c == '\n':
+ msg = 'Extraneous newline'
+ else:
+ msg = 'Illegal char'
+ errors_found.append(error_found(f, log.start(), msg + ' %r' % c, log.group(0)))
- if not error_found:
- return []
+ if not error_found:
+ return []
- line_idx = make_line_idx(file_content)
- for r, line in zip(errors_found, char_pos_2_line(line_idx, [rr.charpos for rr in errors_found])):
- r.line = line
+ line_idx = make_line_idx(file_content)
+ for r, line in zip(errors_found, char_pos_2_line(line_idx, [rr.charpos for rr in errors_found])):
+ r.line = line
- return errors_found
-
+ return errors_found
+ except:
+ print("ERROR WHILE PROCESSING %r" % f, file=sys.stderr)
+ raise
all_errors_found = []
for f in args:
--
To view, visit https://gerrit.osmocom.org/10065
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5fe9a3bbdbfb8a995f24596bf09e70ca5bb3fe8a
Gerrit-Change-Number: 10065
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180719/c94fb600/attachment.htm>