-
Notifications
You must be signed in to change notification settings - Fork 902
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
dual_open: correct silent enum conversions #4146
dual_open: correct silent enum conversions #4146
Conversation
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.
Nice. Just needs a small change.
channeld/channeld.c
Outdated
case REMOTE: | ||
role = TX_ACCEPTER; | ||
break; | ||
default: |
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.
FYI, adding a default
totally undoes the reason for using a switch
statement here, which is to fail to compile if/when the number of enums changes.
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.
There is already a third alternative (NUM_SIDE
), the purpose of this switch was to assert that we are never passed NUM_SIDE
(or, as unlikely as it could be, a new alternative value) since it does not make sense for the 2-alternatives enum.
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.
Yeah, NUM_SIDES should be a #define, not within the enum. This is the pattern we used elsewhere.
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 checked this. NUM_SIDES
is a #define, and has been since 2618ef1
6830218
to
aec52a2
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.
Updated with suggested changes.
channeld/channeld.c
Outdated
case REMOTE: | ||
role = TX_ACCEPTER; | ||
break; | ||
default: |
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 checked this. NUM_SIDES
is a #define, and has been since 2618ef1
aec52a2
to
51e7dcf
Compare
ACK 51e7dcf |
We were silently converting a side enum (3 variants) to a tx_role enum (2 variants). Signed-off-by: Antoine Poinsot <[email protected]>
51e7dcf
to
1c3cb34
Compare
ACK 1c3cb34 Thanks for taking care of updating this. Had to rebase on master to build properly. |
Could someone restart https://travis-ci.org/github/ElementsProject/lightning/jobs/740598643 ? The failure seems (very) unrelated and I can no longer do it |
We were silently converting a side enum (3 variants) to a tx_role enum
(2 variants).
Signed-off-by: Antoine Poinsot [email protected]
Changelog-None