1
0
mirror of https://github.com/systemd/systemd synced 2024-07-01 07:34:28 +00:00

varlink: yet another fix around handling of IDL comments

Skip over them when validating a message against the IDL.

Add test case that tests this.
This commit is contained in:
Lennart Poettering 2024-06-21 17:05:26 +02:00 committed by Yu Watanabe
parent af6e88432f
commit 57b41f15e5
2 changed files with 11 additions and 1 deletions

View File

@ -1782,6 +1782,9 @@ static int varlink_idl_validate_symbol(const VarlinkSymbol *symbol, sd_json_vari
for (const VarlinkField *field = symbol->fields; field->field_type != _VARLINK_FIELD_TYPE_END_MARKER; field++) {
if (field->field_type == _VARLINK_FIELD_COMMENT)
continue;
assert(field->field_type == VARLINK_ENUM_VALUE);
if (streq_ptr(field->name, s)) {
@ -1810,6 +1813,9 @@ static int varlink_idl_validate_symbol(const VarlinkSymbol *symbol, sd_json_vari
for (const VarlinkField *field = symbol->fields; field->field_type != _VARLINK_FIELD_TYPE_END_MARKER; field++) {
if (field->field_type == _VARLINK_FIELD_COMMENT)
continue;
if (field->field_direction != direction)
continue;

View File

@ -279,7 +279,11 @@ TEST(validate_json) {
/* This one has (nested) enonymous enums and structs */
static const char text[] =
"interface validate.test\n"
"method Mymethod ( a:string, b:int, c:?bool, d:[]int, e:?[string]bool, f:?(piff, paff), g:(f:float) ) -> ()\n";
"method Mymethod ( \n"
"# piff \n"
"a:string,\n"
"#paff\n"
"b:int, c:?bool, d:[]int, e:?[string]bool, f:?(piff, paff), g:(f:float) ) -> ()\n";
assert_se(varlink_idl_parse(text, NULL, NULL, &parsed) >= 0);
test_parse_format_one(parsed);