@samitouri / QOSamiQemu / commits / dfec6f920e

minikconf: small cleanups and dead code removal

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo Bonzini committed Apr 24, 2026 at 10:03 UTC dfec6f920ede1e4275ec34621c386ed88dddb7f2
1 file changed +10 -11
scripts/minikconf.py
+10 -11
@@ -108,7 +108,7 @@ class KconfigData:
108 return self.name
109
110 def has_value(self):
111 - return not (self.value is None)
111 + return self.value is not None
112 def set_value(self, val, clause):
113 self.clauses_for_var.append(clause)
114 if self.has_value() and self.value != val:
@@ -158,7 +158,7 @@ class KconfigData:
158 KconfigData.Clause.__init__(self, dest)
159 self.value = value
160 self.cond = cond
161 - if not (self.cond is None):
161 + if self.cond is not None:
162 self.cond.add_edges_to(self.dest)
163 def __str__(self):
164 value = 'y' if self.value else 'n'
@@ -212,7 +212,7 @@ class KconfigData:
212 def check_undefined(self):
213 undef = False
214 for i in self.referenced_vars:
215 - if not (i in self.defined_vars):
215 + if i not in self.defined_vars:
216 print("undefined symbol %s" % (i), file=sys.stderr)
217 undef = True
218 return undef
@@ -220,7 +220,6 @@ class KconfigData:
220 def compute_config(self):
221 if self.check_undefined():
222 raise KconfigDataError("there were undefined symbols")
223 - return None
223
224 debug_print("Input:")
225 for clause in self.clauses:
@@ -270,7 +269,7 @@ class KconfigData:
269
270 # var is a string with the variable's name.
271 def do_var(self, var):
273 - if (var in self.referenced_vars):
272 + if var in self.referenced_vars:
273 return self.referenced_vars[var]
274
275 var_obj = self.referenced_vars[var] = KconfigData.Var(var)
@@ -339,9 +338,9 @@ class KconfigParserError(Exception):
338 class KconfigParser:
339
340 @classmethod
342 - def parse(self, fp, mode=None):
341 + def parse(cls, fp, mode=None):
342 data = KconfigData(mode or defconfig)
344 - parser = KconfigParser(data)
343 + parser = cls(data)
344 parser.parse_file(fp)
345 return data
346
@@ -352,9 +351,10 @@ class KconfigParser:
351 self.abs_fname = os.path.abspath(fp.name)
352 self.fname = fp.name
353 self.data.previously_included.append(self.abs_fname)
355 - self.src = fp.read()
356 - if self.src == '' or self.src[-1] != '\n':
357 - self.src += '\n'
354 + src = fp.read()
355 + if src == '' or src[-1] != '\n':
356 + src += '\n'
357 + self.src = src
358 self.cursor = 0
359 self.line = 1
360 self.line_pos = 0
@@ -534,7 +534,6 @@ class KconfigParser:
534 # properties: properties property
535 # | /* empty */
536 def parse_properties(self, var):
537 - had_default = False
537 while self.tok == TOK_DEFAULT or self.tok == TOK_DEPENDS or \
538 self.tok == TOK_SELECT or self.tok == TOK_BOOL or \
539 self.tok == TOK_IMPLY: