Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
api: improve api string safety
[vpp.git]
/
src
/
tools
/
vppapigen
/
vppapigen_c.py
diff --git
a/src/tools/vppapigen/vppapigen_c.py
b/src/tools/vppapigen/vppapigen_c.py
index
e15a141
..
46f60de
100644
(file)
--- a/
src/tools/vppapigen/vppapigen_c.py
+++ b/
src/tools/vppapigen/vppapigen_c.py
@@
-136,10
+136,9
@@
class Printfun():
if o.modern_vla:
write(' if (vl_api_string_len(&a->{f}) > 0) {{\n'
.format(f=o.fieldname))
if o.modern_vla:
write(' if (vl_api_string_len(&a->{f}) > 0) {{\n'
.format(f=o.fieldname))
- write(' s = format(s, "\\n%U{f}: %
.*s
", '
+ write(' s = format(s, "\\n%U{f}: %
U
", '
'format_white_space, indent, '
'format_white_space, indent, '
- 'vl_api_string_len(&a->{f}) - 1, '
- 'vl_api_from_api_string(&a->{f}));\n'.format(f=o.fieldname))
+ 'vl_api_format_string, (&a->{f}));\n'.format(f=o.fieldname))
write(' } else {\n')
write(' s = format(s, "\\n%U{f}:", '
'format_white_space, indent);\n'.format(f=o.fieldname))
write(' } else {\n')
write(' s = format(s, "\\n%U{f}:", '
'format_white_space, indent);\n'.format(f=o.fieldname))
@@
-586,6
+585,10
@@
def generate_include_types(s, module, stream):
write('} vl_api_%s_t;\n' % o.name)
write('} vl_api_%s_t;\n' % o.name)
+ for t in s['Define']:
+ write('#define VL_API_{ID}_CRC "{n}_{crc:08x}"\n'
+ .format(n=t.name, ID=t.name.upper(), crc=t.crc))
+
write("\n#endif\n")
write("\n#endif\n")
@@
-608,7
+611,7
@@
def generate_c_boilerplate(services, defines, file_crc, module, stream):
write(hdr.format(module=module))
write('static u16\n')
write('setup_message_id_table (void) {\n')
write(hdr.format(module=module))
write('static u16\n')
write('setup_message_id_table (void) {\n')
- write(' api_main_t *am =
&
api_main;\n')
+ write(' api_main_t *am =
my_
api_main;\n')
write(' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", VL_MSG_FIRST_AVAILABLE);\n'
.format(module, crc=file_crc))
write(' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", VL_MSG_FIRST_AVAILABLE);\n'
.format(module, crc=file_crc))