utils: fix sw_match()

The SW_match function takes a given status word and compares it against
a pattern that may contain wildcards (x or ?). This works by creating a
masked version of the SW using a pattern first (each hex digit is
replaced by a wildcard charafter if the pattern has a wildcard in the
same position). Once this is done, the resulting masked version is
compared at the pattern. However, the current implementation can not
work, since it compares the input SW against the pattern to decide
wihich chrafters should be masked. The input SW never contains wildcard
charafters.

Change-Id: I805ad32160fcfcb8628bf919b64f7eee0fe03c7e
Related: OS#4963
This commit is contained in:
Philipp Maier 2021-03-22 20:39:24 +01:00 committed by laforge
parent 05f42ee929
commit 78e32f2b36
1 changed files with 3 additions and 2 deletions

View File

@ -787,12 +787,13 @@ def sw_match(sw, pattern):
sw_lower = sw.lower()
sw_masked = ""
for i in range(0, 4):
if sw_lower[i] == '?':
if pattern[i] == '?':
sw_masked = sw_masked + '?'
elif sw_lower[i] == 'x':
elif pattern[i] == 'x':
sw_masked = sw_masked + 'x'
else:
sw_masked = sw_masked + sw_lower[i]
# Compare the masked version against the pattern
return sw_masked == pattern
def tabulate_str_list(str_list, width = 79, hspace = 2, lspace = 1, align_left = True):