Skip to content

Modify TLS Alert enum names#3246

Closed
randombit wants to merge 1 commit intomasterfrom
jack/camel-case-alert-names
Closed

Modify TLS Alert enum names#3246
randombit wants to merge 1 commit intomasterfrom
jack/camel-case-alert-names

Conversation

@randombit
Copy link
Copy Markdown
Owner

A handful of alert types that it seemed likely applications would special case on (like close notify and protocol version problems) have the old names retained as deprecated variants. For the rest only the new name is available.

@randombit randombit requested a review from reneme February 1, 2023 22:47
@randombit
Copy link
Copy Markdown
Owner Author

Been a while since I've seen GCC ICE

Comment on lines +74 to +75
typedef AlertType Type;
using enum AlertType;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems that using enum is not understood by MinGW and the baremetal job:

build/include/botan/tls_alert.h:75:13: error: expected nested-name-specifier before ‘enum’
   75 |       using enum AlertType;
      |             ^~~~

Why not stay with the current construction of having a plain enum nested inside class Alert? Isn't that the same "smart-enum" idiom we used in other places?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, my gut feeling is that this is why GCC is ICE-ing. Which it still does, by the way.

For instance in the GCC sanitizer job:

/home/runner/work/botan/botan/build/build/include/botan/asio_stream.h:628:47: internal compiler error: in tsubst_copy, at cp/pt.c:16822
  628 |                if(alert.type() == TLS::Alert::CloseNotify)
      |                                   ~~~~~~~~~~~~^~~~~~~~~~~
[...]

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Why not stay with the current construction of having a plain enum nested inside class Alert? Isn't that the same "smart-enum" idiom we used in other places?

It is, but that's only because I just found out about using enum in C++20. If it works I plan to modify at least some of the other enumerations similarly. Having the enumeration being an enum class prevents certain errors, for example adding two enumerations is valid for plain enum but invalid for enum class.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It seems that using enum is not understood by MinGW and the baremetal job:

It appears both of these are actually GCC 10!

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Which it still does, by the way.

I missed the case in asio that triggers the ICE

@randombit randombit force-pushed the jack/camel-case-alert-names branch from 782b02c to f5c4a87 Compare February 2, 2023 23:54
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Base: 88.10% // Head: 88.10% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (782b02c) compared to base (65cb7cd).
Patch coverage: 64.82% of modified lines in pull request are covered.

❗ Current head 782b02c differs from pull request most recent head f5c4a87. Consider uploading reports for the commit f5c4a87 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3246   +/-   ##
=======================================
  Coverage   88.10%   88.10%           
=======================================
  Files         609      609           
  Lines       68257    68263    +6     
  Branches     6804     6808    +4     
=======================================
+ Hits        60136    60145    +9     
  Misses       5278     5278           
+ Partials     2843     2840    -3     
Impacted Files Coverage Δ
src/cli/tls_http_server.cpp 82.62% <0.00%> (ø)
src/cli/tls_proxy.cpp 82.35% <0.00%> (+0.53%) ⬆️
src/lib/tls/msg_session_ticket.cpp 79.48% <0.00%> (ø)
src/lib/tls/tls12/msg_certificate_12.cpp 76.31% <0.00%> (ø)
src/lib/tls/tls12/msg_server_kex.cpp 85.43% <0.00%> (ø)
src/lib/tls/tls13/tls_transcript_hash_13.cpp 94.25% <0.00%> (ø)
src/lib/tls/tls_callbacks.cpp 74.68% <0.00%> (ø)
src/lib/tls/tls_extensions_cert_status_req.cpp 79.62% <0.00%> (ø)
src/lib/tls/tls_version.cpp 80.00% <0.00%> (ø)
src/tests/test_tls.cpp 89.74% <ø> (ø)
... and 36 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
Collaborator

@reneme reneme left a comment

Choose a reason for hiding this comment

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

Build failure will be fixed with #3250.

@randombit randombit force-pushed the jack/camel-case-alert-names branch from f5c4a87 to 021cfb4 Compare February 6, 2023 22:43
randombit added a commit that referenced this pull request Feb 7, 2023
@randombit
Copy link
Copy Markdown
Owner Author

Merged the wrong commit - this has landed

@randombit randombit closed this Feb 7, 2023
@randombit randombit deleted the jack/camel-case-alert-names branch February 7, 2023 22:56
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