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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9544 )
Change subject: verify_value_string_arrays_are_terminated.py: allow dir args and no args
......................................................................
verify_value_string_arrays_are_terminated.py: allow dir args and no args
So far we call with a $(find . -name "*.[hc]") argument list, which might
become too long at some point. Rather include dir walking in the script itself
and allow passing dir arguments as well.
This is backwards compatible, calling with above file args still works.
Change-Id: I36456383906b6295c798b82aa131dda21f8efc02
---
M scripts/verify_value_string_arrays_are_terminated.py
1 file changed, 18 insertions(+), 2 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved; Verified
diff --git a/scripts/verify_value_string_arrays_are_terminated.py b/scripts/verify_value_string_arrays_are_terminated.py
index ad936a5..9f0ad82 100755
--- a/scripts/verify_value_string_arrays_are_terminated.py
+++ b/scripts/verify_value_string_arrays_are_terminated.py
@@ -3,7 +3,7 @@
'''
Usage:
- verify_value_string_arrays_are_terminated.py PATH [PATH [...]]
+ verify_value_string_arrays_are_terminated.py [ROOT_DIR|PATH] [...]
e.g.
libosmocore/contrib/verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
@@ -12,6 +12,7 @@
import re
import sys
import codecs
+import os.path
value_string_array_re = re.compile(
r'((\bstruct\s+value_string\b[^{;]*?)\s*=[^{;]*{[^;]*}\s*;)',
@@ -22,7 +23,10 @@
'\s*' + members + '(0|NULL)\s*}')
errors_found = 0
-for f in sys.argv[1:]:
+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())
for array_def, name in arrays:
if not terminator_re.search(array_def):
@@ -30,4 +34,16 @@
% (name, f))
errors_found += 1
+args = sys.argv[1:]
+if not args:
+ args = ['.']
+
+for f in args:
+ if os.path.isdir(f):
+ for parent_path, subdirs, files in os.walk(f, None, None):
+ for ff in files:
+ check_file(os.path.join(parent_path, ff))
+ else:
+ check_file(f)
+
sys.exit(errors_found)
--
To view, visit https://gerrit.osmocom.org/9544
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: I36456383906b6295c798b82aa131dda21f8efc02
Gerrit-Change-Number: 9544
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180705/00861792/attachment.htm>