[PATCH] osmo-ci[master]: Add value string termination check from libosmcore

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/.

Max gerrit-no-reply at lists.osmocom.org
Tue Jun 27 09:23:08 UTC 2017


Review at  https://gerrit.osmocom.org/3065

Add value string termination check from libosmcore

The script by Neels Hofmeyr <nhofmeyr at sysmocom.de> has actually nothing
to with libosmocore itself - it's a generic build-time check used by
jenkins so it should be part of this repo to avoid extra checkout of
libosmocore just for this check script.

Change-Id: I079218b61f512975ec5bfc7dc23503ec369cbb5a
---
A scripts/verify_value_string_arrays_are_terminated.py
1 file changed, 33 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/65/3065/1

diff --git a/scripts/verify_value_string_arrays_are_terminated.py b/scripts/verify_value_string_arrays_are_terminated.py
new file mode 100755
index 0000000..020bb4d
--- /dev/null
+++ b/scripts/verify_value_string_arrays_are_terminated.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# vim: expandtab tabstop=2 shiftwidth=2 nocin
+
+'''
+Usage:
+  verify_value_string_arrays_are_terminated.py PATH [PATH [...]]
+
+e.g.
+libosmocore/contrib/verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+'''
+
+import re
+import sys
+import codecs
+
+value_string_array_re = re.compile(
+  r'((\bstruct\s+value_string\b[^{;]*?)\s*=[^{;]*{[^;]*}\s*;)',
+  re.MULTILINE | re.DOTALL)
+
+members = r'(\.(value|str)\s*=\s*)?'
+terminator_re = re.compile('{\s*' + members + '(0|NULL)\s*,'
+                           '\s*' + members + '(0|NULL)\s*}')
+errors_found = 0
+
+for f in sys.argv[1:]:
+  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):
+      print('ERROR: file contains unterminated value_string %r: %r'
+            % (name, f))
+      errors_found += 1
+
+sys.exit(errors_found)

-- 
To view, visit https://gerrit.osmocom.org/3065
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I079218b61f512975ec5bfc7dc23503ec369cbb5a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list