From 25c4015d4addb9e046e4f0b8cdd0c8de452eca96 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 16 Sep 2021 11:22:33 -0500 Subject: [PATCH] fix: 'enumerated and non-enumerated type' warnings (#1810) Simple change to silence warnings, changes the offending enums to be constexprs. There is still more cleanup work to update other enums; this just addresses the ones causing compiler warnings --- libtransmission/peer-msgs.cc | 9 +++++++-- libtransmission/resume.cc | 8 +++++--- libtransmission/torrent-magnet.h | 7 ++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libtransmission/peer-msgs.cc b/libtransmission/peer-msgs.cc index bed9ad1db..8fa77e243 100644 --- a/libtransmission/peer-msgs.cc +++ b/libtransmission/peer-msgs.cc @@ -66,8 +66,6 @@ enum UT_PEX_ID = 1, UT_METADATA_ID = 3, /* */ - MAX_PEX_PEER_COUNT = 50, - /* */ MIN_CHOKE_PERIOD_SEC = 10, /* idle seconds before we send a keepalive */ KEEPALIVE_INTERVAL_SECS = 100, @@ -97,6 +95,13 @@ enum METADATA_MSG_TYPE_REJECT = 2 }; +namespace +{ + +constexpr int MAX_PEX_PEER_COUNT = 50; + +} // unnamed namespace + enum { AWAITING_BT_LENGTH, diff --git a/libtransmission/resume.cc b/libtransmission/resume.cc index 8d6c93a79..15f499c9c 100644 --- a/libtransmission/resume.cc +++ b/libtransmission/resume.cc @@ -23,10 +23,12 @@ #include "utils.h" /* tr_buildPath */ #include "variant.h" -enum +namespace { - MAX_REMEMBERED_PEERS = 200 -}; + +constexpr int MAX_REMEMBERED_PEERS = 200; + +} // unnamed namespace static char* getResumeFilename(tr_torrent const* tor, enum tr_metainfo_basename_format format) { diff --git a/libtransmission/torrent-magnet.h b/libtransmission/torrent-magnet.h index 0d63e5ed7..deb34de89 100644 --- a/libtransmission/torrent-magnet.h +++ b/libtransmission/torrent-magnet.h @@ -15,11 +15,8 @@ #include #include -enum -{ - /* defined by BEP #9 */ - METADATA_PIECE_SIZE = (1024 * 16) -}; +// defined by BEP #9 +inline constexpr int METADATA_PIECE_SIZE = 1024 * 16; void* tr_torrentGetMetadataPiece(tr_torrent* tor, int piece, size_t* len);