tools: Fix pylint 3.3.4 errors
This newer pylint produces errors about variables possibly being used before being set. Adjust the code to pass these checks. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
@@ -106,6 +106,9 @@ class Entry_fdtmap(Entry):
|
|||||||
Returns:
|
Returns:
|
||||||
FDT map binary data
|
FDT map binary data
|
||||||
"""
|
"""
|
||||||
|
fsw = libfdt.FdtSw()
|
||||||
|
fsw.finish_reservemap()
|
||||||
|
|
||||||
def _AddNode(node):
|
def _AddNode(node):
|
||||||
"""Add a node to the FDT map"""
|
"""Add a node to the FDT map"""
|
||||||
for pname, prop in node.props.items():
|
for pname, prop in node.props.items():
|
||||||
@@ -134,8 +137,6 @@ class Entry_fdtmap(Entry):
|
|||||||
|
|
||||||
# Build a new tree with all nodes and properties starting from that
|
# Build a new tree with all nodes and properties starting from that
|
||||||
# node
|
# node
|
||||||
fsw = libfdt.FdtSw()
|
|
||||||
fsw.finish_reservemap()
|
|
||||||
with fsw.add_node(''):
|
with fsw.add_node(''):
|
||||||
fsw.property_string('image-node', node.name)
|
fsw.property_string('image-node', node.name)
|
||||||
_AddNode(node)
|
_AddNode(node)
|
||||||
|
@@ -62,6 +62,7 @@ class Entry_image_header(Entry):
|
|||||||
|
|
||||||
def _GetHeader(self):
|
def _GetHeader(self):
|
||||||
image_pos = self.GetSiblingImagePos('fdtmap')
|
image_pos = self.GetSiblingImagePos('fdtmap')
|
||||||
|
offset = None
|
||||||
if image_pos == False:
|
if image_pos == False:
|
||||||
self.Raise("'image_header' section must have an 'fdtmap' sibling")
|
self.Raise("'image_header' section must have an 'fdtmap' sibling")
|
||||||
elif image_pos is None:
|
elif image_pos is None:
|
||||||
|
@@ -112,6 +112,8 @@ class Entry_pre_load(Entry_collection):
|
|||||||
# Compute the signature
|
# Compute the signature
|
||||||
if padding_name is None:
|
if padding_name is None:
|
||||||
padding_name = "pkcs-1.5"
|
padding_name = "pkcs-1.5"
|
||||||
|
padding = None
|
||||||
|
padding_args = None
|
||||||
if padding_name == "pss":
|
if padding_name == "pss":
|
||||||
salt_len = key.size_in_bytes() - hash_image.digest_size - 2
|
salt_len = key.size_in_bytes() - hash_image.digest_size - 2
|
||||||
padding = pss
|
padding = pss
|
||||||
|
@@ -126,6 +126,7 @@ class Entry_ti_board_config(Entry_section):
|
|||||||
size = 2
|
size = 2
|
||||||
else:
|
else:
|
||||||
size = 4
|
size = 4
|
||||||
|
br = None
|
||||||
if type(val) == int:
|
if type(val) == int:
|
||||||
br = val.to_bytes(size, byteorder='little')
|
br = val.to_bytes(size, byteorder='little')
|
||||||
return br
|
return br
|
||||||
|
@@ -84,6 +84,7 @@ class Entry_x509_cert(Entry_collection):
|
|||||||
input_fname = tools.get_output_filename('input.%s' % uniq)
|
input_fname = tools.get_output_filename('input.%s' % uniq)
|
||||||
config_fname = tools.get_output_filename('config.%s' % uniq)
|
config_fname = tools.get_output_filename('config.%s' % uniq)
|
||||||
tools.write_file(input_fname, input_data)
|
tools.write_file(input_fname, input_data)
|
||||||
|
stdout = None
|
||||||
if type == 'generic':
|
if type == 'generic':
|
||||||
stdout = self.openssl.x509_cert(
|
stdout = self.openssl.x509_cert(
|
||||||
cert_fname=output_fname,
|
cert_fname=output_fname,
|
||||||
|
@@ -6381,6 +6381,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
ename, prop = entry_m.group(1), entry_m.group(3)
|
ename, prop = entry_m.group(1), entry_m.group(3)
|
||||||
entry, entry_name, prop_name = image.LookupEntry(entries,
|
entry, entry_name, prop_name = image.LookupEntry(entries,
|
||||||
name, msg)
|
name, msg)
|
||||||
|
expect_val = None
|
||||||
if prop_name == 'offset':
|
if prop_name == 'offset':
|
||||||
expect_val = entry.offset
|
expect_val = entry.offset
|
||||||
elif prop_name == 'image_pos':
|
elif prop_name == 'image_pos':
|
||||||
|
@@ -406,10 +406,13 @@ def CheckSetHashValue(node, get_data_func):
|
|||||||
hash_node = node.FindNode('hash')
|
hash_node = node.FindNode('hash')
|
||||||
if hash_node:
|
if hash_node:
|
||||||
algo = hash_node.props.get('algo').value
|
algo = hash_node.props.get('algo').value
|
||||||
|
data = None
|
||||||
if algo == 'sha256':
|
if algo == 'sha256':
|
||||||
m = hashlib.sha256()
|
m = hashlib.sha256()
|
||||||
m.update(get_data_func())
|
m.update(get_data_func())
|
||||||
data = m.digest()
|
data = m.digest()
|
||||||
|
if data is None:
|
||||||
|
raise ValueError(f"Node '{node.path}': Unknown hash algorithm '{algo}'")
|
||||||
for n in GetUpdateNodes(hash_node):
|
for n in GetUpdateNodes(hash_node):
|
||||||
n.SetData('value', data)
|
n.SetData('value', data)
|
||||||
|
|
||||||
|
@@ -1095,14 +1095,13 @@ class Builder:
|
|||||||
diff = result[name]
|
diff = result[name]
|
||||||
if name.startswith('_'):
|
if name.startswith('_'):
|
||||||
continue
|
continue
|
||||||
if diff != 0:
|
colour = self.col.RED if diff > 0 else self.col.GREEN
|
||||||
color = self.col.RED if diff > 0 else self.col.GREEN
|
|
||||||
msg = ' %s %+d' % (name, diff)
|
msg = ' %s %+d' % (name, diff)
|
||||||
if not printed_target:
|
if not printed_target:
|
||||||
tprint('%10s %-15s:' % ('', result['_target']),
|
tprint('%10s %-15s:' % ('', result['_target']),
|
||||||
newline=False)
|
newline=False)
|
||||||
printed_target = True
|
printed_target = True
|
||||||
tprint(msg, colour=color, newline=False)
|
tprint(msg, colour=colour, newline=False)
|
||||||
if printed_target:
|
if printed_target:
|
||||||
tprint()
|
tprint()
|
||||||
if show_bloat:
|
if show_bloat:
|
||||||
@@ -1353,6 +1352,7 @@ class Builder:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
col = None
|
||||||
if line[0] == '+':
|
if line[0] == '+':
|
||||||
col = self.col.GREEN
|
col = self.col.GREEN
|
||||||
elif line[0] == '-':
|
elif line[0] == '-':
|
||||||
|
@@ -279,6 +279,9 @@ def MicrocodeTool():
|
|||||||
|
|
||||||
if (not not options.mcfile) != (not not options.mcfile):
|
if (not not options.mcfile) != (not not options.mcfile):
|
||||||
parser.error("You must specify either header files or a microcode file, not both")
|
parser.error("You must specify either header files or a microcode file, not both")
|
||||||
|
date = None
|
||||||
|
microcodes = None
|
||||||
|
license_text = None
|
||||||
if options.headerfile:
|
if options.headerfile:
|
||||||
date, license_text, microcodes = ParseHeaderFiles(options.headerfile)
|
date, license_text, microcodes = ParseHeaderFiles(options.headerfile)
|
||||||
elif options.mcfile:
|
elif options.mcfile:
|
||||||
|
Reference in New Issue
Block a user