@@ -501,12 +501,12 @@ class Kconfig(object):
501501 """
502502 __slots__ = (
503503 "_choices" ,
504- "_print_undef_assign" ,
505- "_print_redun_assign" ,
506- "_print_warnings" ,
507504 "_set_re_match" ,
508505 "_unset_re_match" ,
509- "_warn_no_prompt" ,
506+ "_warn_for_no_prompt" ,
507+ "_warn_for_redun_assign" ,
508+ "_warn_for_undef_assign" ,
509+ "_warnings_enabled" ,
510510 "config_prefix" ,
511511 "const_syms" ,
512512 "defconfig_list" ,
@@ -561,6 +561,9 @@ def __init__(self, filename="Kconfig", warn=True):
561561 stderr. This can be changed later with
562562 Kconfig.enable/disable_warnings(). It is provided as a constructor
563563 argument since warnings might be generated during parsing.
564+
565+ See the other Kconfig.enable_*_warnings() functions as well, which
566+ enable or suppress certain warnings when warnings are enabled.
564567 """
565568 self .srctree = os .environ .get ("srctree" )
566569
@@ -581,9 +584,9 @@ def __init__(self, filename="Kconfig", warn=True):
581584 _RE_ASCII ).match
582585
583586
584- self ._print_warnings = warn
585- self ._print_undef_assign = False
586- self ._print_redun_assign = True
587+ self ._warnings_enabled = warn
588+ self ._warn_for_undef_assign = False
589+ self ._warn_for_redun_assign = True
587590
588591 self .syms = {}
589592 self .const_syms = {}
@@ -687,7 +690,7 @@ def __init__(self, filename="Kconfig", warn=True):
687690 # Build Symbol._dependents for all symbols
688691 self ._build_dep ()
689692
690- self ._warn_no_prompt = True
693+ self ._warn_for_no_prompt = True
691694
692695 @property
693696 def mainmenu_text (self ):
@@ -737,15 +740,15 @@ def load_config(self, filename, replace=True):
737740 """
738741 # Disable the warning about assigning to symbols without prompts. This
739742 # is normal and expected within a .config file.
740- self ._warn_no_prompt = False
743+ self ._warn_for_no_prompt = False
741744
742- # This stub only exists to make sure _warn_no_prompt gets reenabled
745+ # This stub only exists to make sure _warn_for_no_prompt gets reenabled
743746 try :
744747 self ._load_config (filename , replace )
745748 except UnicodeDecodeError as e :
746749 _decoding_error (e , filename )
747750 finally :
748- self ._warn_no_prompt = True
751+ self ._warn_for_no_prompt = True
749752
750753 def _load_config (self , filename , replace ):
751754 with self ._open (filename ) as f :
@@ -1283,7 +1286,7 @@ def unset_values(self):
12831286 Resets the user values of all symbols, as if Kconfig.load_config() or
12841287 Symbol.set_value() had never been called.
12851288 """
1286- self ._warn_no_prompt = False
1289+ self ._warn_for_no_prompt = False
12871290 try :
12881291 # set_value() already rejects undefined symbols, and they don't
12891292 # need to be invalidated (because their value never changes), so we
@@ -1294,46 +1297,49 @@ def unset_values(self):
12941297 for choice in self ._choices :
12951298 choice .unset_value ()
12961299 finally :
1297- self ._warn_no_prompt = True
1300+ self ._warn_for_no_prompt = True
12981301
12991302 def enable_warnings (self ):
13001303 """
13011304 See Kconfig.__init__().
13021305 """
1303- self ._print_warnings = True
1306+ self ._warnings_enabled = True
13041307
13051308 def disable_warnings (self ):
13061309 """
13071310 See Kconfig.__init__().
13081311 """
1309- self ._print_warnings = False
1312+ self ._warnings_enabled = False
13101313
13111314 def enable_undef_warnings (self ):
13121315 """
13131316 Enables warnings for assignments to undefined symbols. Printed to
13141317 stderr. Disabled by default since they tend to be spammy for Kernel
13151318 configurations (and mostly suggests cleanups).
13161319 """
1317- self ._print_undef_assign = True
1320+ self ._warn_for_undef_assign = True
13181321
13191322 def disable_undef_warnings (self ):
13201323 """
13211324 See enable_undef_assign().
13221325 """
1323- self ._print_undef_assign = False
1326+ self ._warn_for_undef_assign = False
13241327
13251328 def enable_redun_warnings (self ):
13261329 """
1327- Enables warnings for redundant assignments to symbols. Printed to
1328- stderr. Enabled by default.
1330+ Enables warnings for duplicated assignments in .config files that all
1331+ set the same value.
1332+
1333+ These warnings are enabled by default. Disabling them might be helpful
1334+ in certain cases when merging configurations.
13291335 """
1330- self ._print_redun_assign = True
1336+ self ._warn_for_redun_assign = True
13311337
13321338 def disable_redun_warnings (self ):
13331339 """
13341340 See enable_redun_warnings().
13351341 """
1336- self ._print_redun_assign = False
1342+ self ._warn_for_redun_assign = False
13371343
13381344 def __repr__ (self ):
13391345 """
@@ -1346,11 +1352,11 @@ def __repr__(self):
13461352 "srctree not set" if self .srctree is None else
13471353 'srctree "{}"' .format (self .srctree ),
13481354 'config symbol prefix "{}"' .format (self .config_prefix ),
1349- "warnings " + ("enabled" if self ._print_warnings else "disabled" ),
1355+ "warnings " + ("enabled" if self ._warnings_enabled else "disabled" ),
13501356 "undef. symbol assignment warnings " +
1351- ("enabled" if self ._print_undef_assign else "disabled" ),
1357+ ("enabled" if self ._warn_for_undef_assign else "disabled" ),
13521358 "redundant symbol assignment warnings " +
1353- ("enabled" if self ._print_redun_assign else "disabled" )
1359+ ("enabled" if self ._warn_for_redun_assign else "disabled" )
13541360 )))
13551361
13561362 #
@@ -2529,14 +2535,14 @@ def _parse_error(self, msg):
25292535 def _warn (self , msg , filename = None , linenr = None ):
25302536 # For printing general warnings
25312537
2532- if self ._print_warnings :
2538+ if self ._warnings_enabled :
25332539 _stderr_msg ("warning: " + msg , filename , linenr )
25342540
25352541 def _warn_undef_assign (self , msg , filename = None , linenr = None ):
25362542 # See the class documentation
25372543
2538- if self ._print_undef_assign :
2539- _stderr_msg ( "warning: " + msg , filename , linenr )
2544+ if self ._warn_for_undef_assign :
2545+ self . _warn ( msg , filename , linenr )
25402546
25412547 def _warn_undef_assign_load (self , name , val , filename , linenr ):
25422548 # Special version for load_config()
@@ -2548,8 +2554,8 @@ def _warn_undef_assign_load(self, name, val, filename, linenr):
25482554 def _warn_redun_assign (self , msg , filename = None , linenr = None ):
25492555 # See the class documentation
25502556
2551- if self ._print_redun_assign :
2552- _stderr_msg ( "warning: " + msg , filename , linenr )
2557+ if self ._warn_for_redun_assign :
2558+ self . _warn ( msg , filename , linenr )
25532559
25542560class Symbol (object ):
25552561 """
@@ -3364,7 +3370,7 @@ def _rec_invalidate_if_has_prompt(self):
33643370 self ._rec_invalidate ()
33653371 return
33663372
3367- if self .kconfig ._warn_no_prompt :
3373+ if self .kconfig ._warn_for_no_prompt :
33683374 self .kconfig ._warn (_name_and_loc (self ) + " has no prompt, meaning "
33693375 "user values have no effect on it" )
33703376
0 commit comments