Commit ccb6298d authored by Adam Langley's avatar Adam Langley

cbor: comment that |SimpleValue| can be casted via |int|.

The code casts an |int| to a |SimpleValue|. Since |SimpleValue| is an
|enum class|, this is safe. But it might not be for a traditional
|enum|, so add a comment in case it flags for anyone else.

Change-Id: Ifc50115d0ae9b047167f48b3d031b89d4494eda9
Reviewed-on: https://chromium-review.googlesource.com/982609Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548474}
parent 109b7fed
......@@ -236,6 +236,8 @@ base::Optional<CBORValue> CBORReader::DecodeToSimpleValue(
// Since |header.additional_info| <= 24, ReadVariadicLengthInteger also
// provides this bound for |header.value|.
CHECK_LE(header.value, 255u);
// |SimpleValue| is an enum class and so the underlying type is specified to
// be |int|. So this cast is safe.
CBORValue::SimpleValue possibly_unsupported_simple_value =
static_cast<CBORValue::SimpleValue>(static_cast<int>(header.value));
switch (possibly_unsupported_simple_value) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment