diff options
author | Samuel Just <sjust@redhat.com> | 2019-09-18 21:17:25 +0200 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2019-09-19 09:16:23 +0200 |
commit | bb2bd5f42a558dd47519e275413d246d917b9316 (patch) | |
tree | 0b9e8e21645d4eebe714c126c2ef0c0e6b508ee1 /src/crimson | |
parent | Merge pull request #30410 from tchaikov/wip-debian-g++ (diff) | |
download | ceph-bb2bd5f42a558dd47519e275413d246d917b9316.tar.xz ceph-bb2bd5f42a558dd47519e275413d246d917b9316.zip |
crimson/net: avoid warning about signed comparison with enum classes
Signed-off-by: Samuel Just <sjust@redhat.com>
Diffstat (limited to 'src/crimson')
-rw-r--r-- | src/crimson/net/Interceptor.h | 7 | ||||
-rw-r--r-- | src/crimson/net/Protocol.h | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/crimson/net/Interceptor.h b/src/crimson/net/Interceptor.h index 7bc07cc9b84..6bea23a3962 100644 --- a/src/crimson/net/Interceptor.h +++ b/src/crimson/net/Interceptor.h @@ -12,7 +12,7 @@ namespace ceph::net { -enum class custom_bp_t { +enum class custom_bp_t : uint8_t { BANNER_WRITE = 0, BANNER_READ, BANNER_PAYLOAD_READ, @@ -20,13 +20,14 @@ enum class custom_bp_t { SOCKET_ACCEPTED }; inline const char* get_bp_name(custom_bp_t bp) { + uint8_t index = static_cast<uint8_t>(bp); static const char *const bp_names[] = {"BANNER_WRITE", "BANNER_READ", "BANNER_PAYLOAD_READ", "SOCKET_CONNECTING", "SOCKET_ACCEPTED"}; - assert(static_cast<int>(bp) < std::size(bp_names)); - return bp_names[static_cast<int>(bp)]; + assert(index < std::size(bp_names)); + return bp_names[index]; } enum class bp_type_t { diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index 6287d198cfd..ea7c5d02949 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -76,7 +76,7 @@ class Protocol { protected: // write_state is changed with state atomically, indicating the write // behavior of the according state. - enum class write_state_t { + enum class write_state_t : uint8_t { none, delay, open, @@ -84,12 +84,13 @@ class Protocol { }; static const char* get_state_name(write_state_t state) { + uint8_t index = static_cast<uint8_t>(state); static const char *const state_names[] = {"none", "delay", "open", "drop"}; - assert(static_cast<int>(state) < std::size(state_names)); - return state_names[static_cast<int>(state)]; + assert(index < std::size(state_names)); + return state_names[index]; } void set_write_state(const write_state_t& state) { |