-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TLV generation cleanup and testing #3297
Conversation
e9b22e4
to
087546d
Compare
Ready for review :-) Ping @niftynei |
087546d
to
fff4099
Compare
43b0599
to
f64ab69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one trivial comment, this is great. Turned out really nice!
Ack f64ab69
tools/gen/header_template
Outdated
*/ | ||
int ${tlv.name}_is_valid(const struct ${tlv.struct_name()} *record); | ||
bool ${tlv.name}_is_valid(const struct ${tlv.struct_name()} *record, | ||
int *err_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t *err_index?
f64ab69
to
b346c5b
Compare
Rebased on top of ACK 7e18a12 |
b346c5b
to
83693bc
Compare
SUPERVERBOSE("Unknown even type in TLV"); | ||
return i; | ||
SUPERVERBOSE("unknown even"); | ||
if (err_index != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this better than if (err_index)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly prefer it since it makes it clearer that we aren't checking a boolean but rather a pointer. I'm pretty sure it results in the same assembly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed: https://godbolt.org/z/tcXEAc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally, i prefer the more concise if (err_index)
; the fact that err_index
's type is a pointer should be clue enough that we're checking for pointer presence
I got this one wrong myself, since the function name implied a boolean result. So I changed it to take the optional err_index as argument.
We are now using the typesafe variant everywhere.
This is the counterpart to the typesafe deserialization function implemented in an earlier commit.
83693bc
to
7e18a12
Compare
As promised in #3278 I went back and modified the
run-tlvstream
tests to use the typesafe TLV parser. Those last uses removed we could also remove the non-typesafe variantfromwire_tlvs
. I'm planning to do the same for thetowire_tlvs
helper and make that typesafe (hence the draft status).Changelog-None