Skip to content
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

Merged
merged 6 commits into from
Dec 3, 2019

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Nov 26, 2019

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 variant fromwire_tlvs. I'm planning to do the same for the towire_tlvs helper and make that typesafe (hence the draft status).

Changelog-None

@cdecker cdecker changed the title TLV generation cleanuo and testing TLV generation cleanup and testing Nov 28, 2019
@cdecker cdecker force-pushed the tlv-gen-cleanup branch 2 times, most recently from e9b22e4 to 087546d Compare November 29, 2019 16:47
@cdecker cdecker marked this pull request as ready for review November 29, 2019 19:29
@cdecker cdecker requested a review from niftynei November 29, 2019 19:29
@cdecker
Copy link
Member Author

cdecker commented Nov 29, 2019

Ready for review :-)

Ping @niftynei

@cdecker cdecker self-assigned this Nov 29, 2019
@cdecker cdecker added this to the 0.7.4 milestone Nov 29, 2019
Copy link
Contributor

@rustyrussell rustyrussell left a 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

*/
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t *err_index?

@cdecker
Copy link
Member Author

cdecker commented Dec 2, 2019

Rebased on top of master and fixed the type error pointed out by @rustyrussell. Re-applying ack.

ACK 7e18a12

SUPERVERBOSE("Unknown even type in TLV");
return i;
SUPERVERBOSE("unknown even");
if (err_index != NULL)
Copy link
Contributor

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) ?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.
@rustyrussell rustyrussell merged commit db92c2a into ElementsProject:master Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants