[PATCH] libosmocore[master]: NOT FOR MERGE: jenkins: check whether value_string check works

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.org
Wed Mar 1 14:26:45 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1944

to look at the new patch set (#5).

NOT FOR MERGE: jenkins: check whether value_string check works

this one should FAIL, two terminators were removed

Change-Id: If16b49af4d2f035004d90fc86f99376ab2f9fbe7
---
M contrib/jenkins.sh
A contrib/verify_value_string_arrays_are_terminated.py
M src/gsm/gsm0808.c
3 files changed, 37 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/1944/5

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 108a73a..656f02f 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -2,6 +2,8 @@
 
 set -ex
 
+./contrib/verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+
 autoreconf --install --force
 ./configure --enable-static --enable-sanitize
 $MAKE $PARALLEL_MAKE check \
diff --git a/contrib/verify_value_string_arrays_are_terminated.py b/contrib/verify_value_string_arrays_are_terminated.py
new file mode 100755
index 0000000..13c609e
--- /dev/null
+++ b/contrib/verify_value_string_arrays_are_terminated.py
@@ -0,0 +1,35 @@
+#!/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
+
+ws = r'\s*' + '\n' + r'*\s*'
+
+value_string_array_re = re.compile(
+  r'((\bstruct\s+value_string\b[^{;]*?)' + ws + '=[^{;]*{[^;]*}\s*;)',
+  re.MULTILINE | re.DOTALL)
+
+members = r'(\.(value|str)' + ws + '=' + ws + ')?'
+terminator_re = re.compile('{' + ws + members + '(0|NULL)' + ws + ','
+                               + ws + members + '(0|NULL)' + ws + '}')
+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)
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 4035f46..b7c4895 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -529,7 +529,6 @@
 	{ BSS_MAP_MSG_LCLS_CONNECT_CTRL_ACK,	"CLS-CONNECT-CONTROL-ACK" },
 	{ BSS_MAP_MSG_LCLS_NOTIFICATION,	"LCLS-NOTIFICATION" },
 
-	{ 0, NULL }
 };
 
 const char *gsm0808_bssmap_name(uint8_t msg_type)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If16b49af4d2f035004d90fc86f99376ab2f9fbe7
Gerrit-PatchSet: 5
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list