aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-12-02 16:36:34 +0000
committerOle Tr�an <otroan@employees.org>2021-12-08 09:39:21 +0000
commit0eb83f484cc74b7ab4e26f6811a3e98442a25e7d (patch)
tree9d82ca16b6aba91f9c3c4d65420e694909a6d585 /src/tools
parent074f3970c6d68d30878e5a2a3a80904182f15e89 (diff)
api: improve REPLY_MACRO safety
Improve vppapigen to generate per-message #define indicating whether said message is dynamically sized (due to VLA or string) or not. Use these #defines in REPLY_MACROs to prevent improper usage. Fix existing improper REPLY_MACRO* usage. Type: improvement Change-Id: Ia77aaf9f6cf3ed68ea21075a4cc8deda78a68651 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index d0f63fbdb0c..1e18a83e65e 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -24,6 +24,7 @@ VAT2 tests.
'''
import datetime
+import itertools
import os
import time
import sys
@@ -1256,7 +1257,7 @@ def generate_include_types(s, module, stream):
filename = i.filename.replace('plugins/', '')
write('#include <{}_types.h>\n'.format(filename))
- for o in s['types'] + s['Define']:
+ for o in itertools.chain(s['types'], s['Define']):
tname = o.__class__.__name__
if tname == 'Using':
if 'length' in o.alias:
@@ -1315,6 +1316,7 @@ def generate_include_types(s, module, stream):
.format(b, o.name))
write('} vl_api_%s_t;\n' % o.name)
+ write(f'#define VL_API_{o.name.upper()}_IS_CONSTANT_SIZE ({0 if o.vla else 1})\n\n')
for t in s['Define']:
write('#define VL_API_{ID}_CRC "{n}_{crc:08x}"\n'