Skip to content

Commit 34247d9

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

scripts/generate_psa_constants.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def __init__(self):
211211
_define_directive_re = re.compile(r'\s*#\s*define\s+(\w+)' +
212212
r'(?:\s+|\((\w+)\)\s*)' +
213213
r'(.+)')
214+
_deprecated_definition_re = re.compile('\s*MBEDTLS_DEPRECATED')
214215

215216
def read_line(self, line):
216217
"""Parse a C header line and record the PSA identifier it defines if any.
@@ -223,20 +224,16 @@ def read_line(self, line):
223224
return
224225
name, parameter, expansion = m.groups()
225226
expansion = re.sub(r'/\*.*?\*/|//.*', r' ', expansion)
227+
if re.match(self._deprecated_definition_re, expansion):
228+
# Skip deprecated values, which are assumed to be
229+
# backward compatibility aliases that share
230+
# numerical values with non-deprecated values.
231+
return
226232
if name.endswith('_FLAG') or name.endswith('MASK'):
227233
# Macro only to build actual values
228234
return
229235
elif (name.startswith('PSA_ERROR_') or name == 'PSA_SUCCESS') \
230236
and not parameter:
231-
if name in ['PSA_ERROR_UNKNOWN_ERROR',
232-
'PSA_ERROR_OCCUPIED_SLOT',
233-
'PSA_ERROR_EMPTY_SLOT',
234-
'PSA_ERROR_INSUFFICIENT_CAPACITY',
235-
]:
236-
# Ad hoc skipping of deprecated error codes, which share
237-
# numerical values with non-deprecated error codes
238-
return
239-
240237
self.statuses.add(name)
241238
elif name.startswith('PSA_KEY_TYPE_') and not parameter:
242239
self.key_types.add(name)

0 commit comments

Comments
 (0)