Skip to content

Commit 1a37ae9

Browse files
authored
Fix Clang 13.0.1 and GCC 12.0.1 Compiler Warnings (#8690)
This cherry-picks two commits from master: Fix Clang 13.0.1 compiler warnings (#8685) This fixes a couple compiler warnings raised by Clang 13.0.1. (cherry picked from commit 96ce993) Fix warnings from GCC 12.0.1 (#8684) This patch fixes warnings generated by GCC 12.0.1. The warnings involved the use of the deprecated std::binary_function, std::unary_function, and std::iterator interfaces. The use of these was considered more confusing than explicitly declaring the associated types. Therefore this patch replaces the use of these deprecated interfaces with the declaration of the associated types. (cherry picked from commit 0ae34d4)
1 parent 3c4d7e3 commit 1a37ae9

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

example/plugins/cpp-api/boom/boom.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,16 @@ GlobalPlugin *plugin;
9898
// Functor that decides whether the HTTP error can be rewritten or not.
9999
// Rewritable codes are: 2xx, 3xx, 4xx, 5xx and 6xx.
100100
// 1xx is NOT rewritable!
101-
class IsRewritableCode : public std::unary_function<std::string, bool>
101+
class IsRewritableCode
102102
{ // could probably be replaced with mem_ptr_fun()..
103103
private:
104104
int current_code_;
105105
std::string current_code_string_;
106106

107107
public:
108+
using argument_type = std::string;
109+
using result_type = bool;
110+
108111
explicit IsRewritableCode(int current_code) : current_code_(current_code)
109112
{
110113
std::ostringstream oss;

include/tscore/IntrusivePtr.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,13 @@ template <typename T> class IntrusivePtrDefaultPolicy
330330
static void finalize(T *t);
331331

332332
/// Strict weak order for STL containers.
333-
class Order : public std::binary_function<IntrusivePtr<T>, IntrusivePtr<T>, bool>
333+
class Order
334334
{
335335
public:
336+
using first_argument_type = IntrusivePtr<T>;
337+
using second_argument_type = IntrusivePtr<T>;
338+
using result_type = bool;
339+
336340
/// Default constructor.
337341
Order() {}
338342
/// Compare by raw pointer.

include/tscpp/api/Headers.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ class HeaderField;
109109
/**
110110
* @brief A header field value iterator iterates through all header fields.
111111
*/
112-
class header_field_value_iterator : public std::iterator<std::forward_iterator_tag, int>
112+
class header_field_value_iterator
113113
{
114114
private:
115115
HeaderFieldValueIteratorState *state_;
116116

117117
public:
118+
using iterator_category = std::forward_iterator_tag;
119+
using value_type = int;
120+
118121
/**
119122
* Constructor for header_field_value_iterator, this shouldn't need to be used directly.
120123
* @param bufp the TSMBuffer associated with the headers
@@ -169,13 +172,16 @@ class header_field_value_iterator : public std::iterator<std::forward_iterator_t
169172
/**
170173
* @brief A header field iterator is an iterator that dereferences to a HeaderField.
171174
*/
172-
class header_field_iterator : public std::iterator<std::forward_iterator_tag, int>
175+
class header_field_iterator
173176
{
174177
private:
175178
HeaderFieldIteratorState *state_;
176179
header_field_iterator(void *hdr_buf, void *hdr_loc, void *field_loc);
177180

178181
public:
182+
using iterator_category = std::forward_iterator_tag;
183+
using value_type = int;
184+
179185
~header_field_iterator();
180186

181187
/**

iocore/net/quic/QUICFrame.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ class QUICAckFrame : public QUICFrame
204204
class AckBlockSection
205205
{
206206
public:
207-
class const_iterator : public std::iterator<std::input_iterator_tag, QUICAckFrame::AckBlock>
207+
class const_iterator
208208
{
209209
public:
210+
using iterator_category = std::input_iterator_tag;
211+
using value_type = QUICAckFrame::AckBlock;
212+
210213
const_iterator(uint8_t index, const std::vector<QUICAckFrame::AckBlock> *ack_blocks);
211214

212215
const QUICAckFrame::AckBlock &

iocore/net/quic/QUICVersionNegotiator.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ QUICVersionNegotiator::negotiate(const QUICPacket &packet)
4646
case QUICPacketType::VERSION_NEGOTIATION: {
4747
const QUICVersionNegotiationPacketR &vn_packet = static_cast<const QUICVersionNegotiationPacketR &>(packet);
4848
uint16_t n_supported_version = vn_packet.nversions();
49-
uint16_t len = 0;
5049

5150
for (int i = 0; i < n_supported_version; ++i) {
5251
QUICVersion version = vn_packet.supported_version(i);
53-
len += sizeof(QUICVersion);
5452

5553
if (QUICTypeUtil::is_supported_version(version)) {
5654
this->_status = QUICVersionNegotiationStatus::NEGOTIATED;

src/tscore/HostLookup.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,11 @@ struct CharIndexBlock {
231231
class CharIndex
232232
{
233233
public:
234-
struct iterator : public std::iterator<std::forward_iterator_tag, HostBranch, int> {
234+
struct iterator {
235+
using iterator_category = std::forward_iterator_tag;
236+
using value_type = HostBranch;
237+
using difference_type = int;
238+
235239
using self_type = iterator;
236240

237241
struct State {

src/wccp/WccpMeta.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ template <bool VALUE> struct TEST_IF_TRUE : public TEST_RESULT<TEST_BOOL<VALUE>>
5454
};
5555

5656
// Helper for assigning a value to all instances in a container.
57-
template <typename T, typename R, typename A1> struct TsAssignMember : public std::binary_function<T, A1, R> {
57+
template <typename T, typename R, typename A1> struct TsAssignMember {
58+
using first_argument_type = T;
59+
using second_argument_type = A1;
60+
using result_type = R;
61+
5862
R T::*_m;
5963
A1 _arg1;
6064
TsAssignMember(R T::*m, A1 const &arg1) : _m(m), _arg1(arg1) {}

0 commit comments

Comments
 (0)