[kernel-team] 04/04: kconfigeditor2: Warn about unknown names and invalid values
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Sat Jan 28 03:15:18 UTC 2017
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch master
in repository kernel-team.
commit 8e306d150a404f0b3d2c091eb375446b767c8e0f
Author: Ben Hutchings <ben at decadent.org.uk>
Date: Sat Jan 28 02:40:07 2017 +0000
kconfigeditor2: Warn about unknown names and invalid values
We already put unknown (or automatic) settings in a separate section,
but it's more helpful to also draw attention to them with a warning.
We haven't previously checked for invalid values, which generally
aren't fatal errors for kconfig but will often be resolved in an
unhelpful way. Warn about them too.
---
.../kconfigeditor2/kconfigeditor/kconfig/config.py | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/utils/kconfigeditor2/kconfigeditor/kconfig/config.py b/utils/kconfigeditor2/kconfigeditor/kconfig/config.py
index 062cc2c..5236c16 100644
--- a/utils/kconfigeditor2/kconfigeditor/kconfig/config.py
+++ b/utils/kconfigeditor2/kconfigeditor/kconfig/config.py
@@ -1,5 +1,6 @@
import os
import re
+import sys
from .menu import MenuEntryChoice, MenuEntryConfig
@@ -8,8 +9,11 @@ class File(dict):
def __init__(self, content={}, name=None):
super(File, self).__init__(content)
if name:
+ self.name = name
with open(name) as fd:
self.read(fd)
+ else:
+ self.name = '<unknown>'
def _write(self, menufiles):
processed = set()
@@ -24,6 +28,8 @@ class File(dict):
yield '## file: unknown'
yield '##'
for name in sorted(unprocessed):
+ print("%s: Unknown setting %s" % (self.name, self[name]),
+ file=sys.stderr)
for i in self[name].write():
yield i
yield ''
@@ -67,6 +73,23 @@ class File(dict):
return
if entry.prompt:
+ if entry.type == MenuEntryConfig.TYPE_BOOL:
+ valid = isinstance(value, FileEntryTristate) and \
+ value.value != FileEntryTristate.VALUE_MOD
+ elif entry.type == MenuEntryConfig.TYPE_TRISTATE:
+ valid = isinstance(value, FileEntryTristate)
+ elif entry.type == MenuEntryConfig.TYPE_STRING:
+ valid = re.match(r'"(?:\\.|[^"])*"$', value.value) is not None
+ elif entry.type == MenuEntryConfig.TYPE_INT_DEC:
+ valid = re.match(r'-?(?:0|[1-9]\d*)$', value.value) is not None
+ elif entry.type == MenuEntryConfig.TYPE_INT_HEX:
+ valid = re.match(r'(?:0x)?[0-9a-f]+$', value.value,
+ re.IGNORECASE) is not None
+ else:
+ raise NotImplementedError
+ if not valid:
+ print("%s: Invalid setting %s" % (self.name, value),
+ file=sys.stderr)
processed.add(entry.name)
for i in value.write():
yield i
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/kernel-team.git
More information about the Kernel-svn-changes
mailing list