Skip to content

Commit 8960194

Browse files
Omit all deprecated definitions rather than a hard-coded lists
Rather than hard-coding a list of deprecated aliases, assume that anything that's deprecated is an alias or otherwise not desired.
1 parent cff5bd3 commit 8960194

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

scripts/generate_psa_constants.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,24 @@ def __init__(self):
183183
_define_directive_re = re.compile(r'\s*#\s*define\s+(\w+)' +
184184
r'(?:\s+|\((\w+)\)\s*)' +
185185
r'(.+)')
186+
_deprecated_definition_re = re.compile('\s*MBEDTLS_DEPRECATED')
186187

187188
def read_line(self, line):
188189
m = re.match(self._define_directive_re, line)
189190
if not m:
190191
return
191192
name, parameter, expansion = m.groups()
192193
expansion = re.sub(r'/\*.*?\*/|//.*', r' ', expansion)
194+
if re.match(self._deprecated_definition_re, expansion):
195+
# Skip deprecated values, which are assumed to be
196+
# backward compatibility aliases that share
197+
# numerical values with non-deprecated values.
198+
return
193199
if name.endswith('_FLAG') or name.endswith('MASK'):
194200
# Macro only to build actual values
195201
return
196202
elif (name.startswith('PSA_ERROR_') or name == 'PSA_SUCCESS') \
197203
and not parameter:
198-
if name in [
199-
'PSA_ERROR_UNKNOWN_ERROR',
200-
'PSA_ERROR_OCCUPIED_SLOT',
201-
'PSA_ERROR_EMPTY_SLOT',
202-
'PSA_ERROR_INSUFFICIENT_CAPACITY',
203-
]:
204-
# Ad hoc skipping of deprecated error codes, which share
205-
# numerical values with non-deprecated error codes
206-
return
207-
208204
self.statuses.add(name)
209205
elif name.startswith('PSA_KEY_TYPE_') and not parameter:
210206
self.key_types.add(name)

0 commit comments

Comments
 (0)