-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort a few python dicts for deterministic builds, even with python 3.5 and earlier. #14119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,33 @@ | |
import struct | ||
from elf_helper import ElfHelper, kobject_to_enum | ||
|
||
from collections import OrderedDict | ||
|
||
# Keys in this dictionary are structs which should be recognized as kernel | ||
# objects. Values should either be None, or the name of a Kconfig that | ||
# indicates the presence of this object's definition in case it is not | ||
# available in all configurations. | ||
|
||
kobjects = { | ||
"k_mem_slab": None, | ||
"k_msgq": None, | ||
"k_mutex": None, | ||
"k_pipe": None, | ||
"k_queue": None, | ||
"k_poll_signal": None, | ||
"k_sem": None, | ||
"k_stack": None, | ||
"k_thread": None, | ||
"k_timer": None, | ||
"_k_thread_stack_element": None, | ||
"net_context": "CONFIG_NETWORKING", | ||
"device": None | ||
} | ||
# Regular dictionaries are ordered only with Python 3.6 and | ||
# above. Good summary and pointers to official documents at: | ||
# https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6 | ||
kobjects = OrderedDict ([ | ||
("k_mem_slab", None), | ||
("k_msgq", None), | ||
("k_mutex", None), | ||
("k_pipe", None), | ||
("k_queue", None), | ||
("k_poll_signal", None), | ||
("k_sem", None), | ||
("k_stack", None), | ||
("k_thread", None), | ||
("k_timer", None), | ||
("_k_thread_stack_element", None), | ||
("net_context", "CONFIG_NETWORKING"), | ||
("device", None), | ||
]) | ||
|
||
|
||
|
||
subsystems = [ | ||
"adc_driver_api", | ||
|
@@ -269,10 +276,14 @@ def main(): | |
parse_args() | ||
|
||
if args.gperf_output: | ||
assert args.kernel, "--kernel ELF required for --gperf-output" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe if not args.kernel:
sys.exit("--kernel must be passed if --gperf-output is") would be a bit more purist. It's more of a usage error than a runtime error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a usage error but... a pretty stupid, "trial-and-error" one so I didn't want to spend too many lines of code on it. |
||
eh = ElfHelper(args.kernel, args.verbose, kobjects, subsystems) | ||
syms = eh.get_symbols() | ||
max_threads = syms["CONFIG_MAX_THREAD_BYTES"] * 8 | ||
objs = eh.find_kobjects(syms) | ||
if not objs: | ||
sys.stderr.write("WARNING: zero kobject found in %s\n" | ||
% args.kernel) | ||
|
||
thread_counter = eh.get_thread_counter() | ||
if thread_counter > max_threads: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I missed this earlier, but could get rid of the
.keys()
.x in dict
,for x in dict
,sorted(dict)
, etc., always uses the keys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed but I'd like to keep this particular commit as minimal as possible :-) Not just for aesthetic reasons but also cherry-picking for testing / backporting etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, fine with me.