Skip to content

Commit cd39475

Browse files
committed
Bug#33086882: USE NODISCARD INSTEAD OF WARN_UNUSED_RESULT
Use the standard [[nodiscard]] attribute instead of MY_ATTRIBUTE((warn_unused_result)), which is only understood by GCC and clang. Change-Id: I4e43de3aad428c84d9f87c54b65ba82063d8ef92
1 parent 5d886df commit cd39475

File tree

146 files changed

+2574
-3211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2574
-3211
lines changed

include/priority_queue.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include <utility>
3434
#include <vector>
3535

36-
#include "my_compiler.h"
37-
3836
#include "template_utils.h"
3937

4038
#if defined(EXTRA_CODE_FOR_UNIT_TESTING)
@@ -392,8 +390,7 @@ class Priority_queue : public Less {
392390
@param n number of elements.
393391
@retval true if out-of-memory, false otherwise.
394392
*/
395-
MY_ATTRIBUTE((warn_unused_result))
396-
bool reserve(size_type n) {
393+
[[nodiscard]] bool reserve(size_type n) {
397394
assert(n <= m_container.max_size());
398395
try {
399396
m_container.reserve(n);

router/src/harness/include/mysql/harness/stdx/attribute.h

-9
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,4 @@
4545
#define STDX_NONNULL
4646
#endif
4747

48-
// STDX_NODISCARD
49-
#if __has_cpp_attribute(nodiscard)
50-
#define STDX_NODISCARD [[nodiscard]]
51-
#elif __has_cpp_attribute(gnu::warn_unused_result)
52-
#define STDX_NODISCARD [[gnu::warn_unused_result]]
53-
#else
54-
#define STDX_NODISCARD
55-
#endif
56-
5748
#endif

router/tests/helpers/router_component_test.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ class RouterComponentTest : public ProcessManager, public ::testing::Test {
6363
* @return bool value indicating if the pattern was found in the log file or
6464
* not
6565
*/
66-
STDX_NODISCARD
67-
bool wait_log_contains(const ProcessWrapper &process,
68-
const std::string &pattern,
69-
std::chrono::milliseconds timeout);
66+
[[nodiscard]] bool wait_log_contains(const ProcessWrapper &process,
67+
const std::string &pattern,
68+
std::chrono::milliseconds timeout);
7069

7170
/** @brief Sleep for a duration given as a parameter. The duration is
7271
* increased 10 times for the run with VALGRIND.

router/tests/helpers/router_test_helpers.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ void init_windows_sockets();
174174
*
175175
* @returns true if the selected port accepts connections, false otherwise
176176
*/
177-
STDX_NODISCARD
178-
bool wait_for_port_ready(
177+
[[nodiscard]] bool wait_for_port_ready(
179178
uint16_t port, std::chrono::milliseconds timeout = kDefaultPortReadyTimeout,
180179
const std::string &hostname = "127.0.0.1");
181180

@@ -185,8 +184,7 @@ bool wait_for_port_ready(
185184
*
186185
* @returns true if the selected port is available, false otherwise
187186
*/
188-
STDX_NODISCARD
189-
bool is_port_available(const uint16_t port);
187+
[[nodiscard]] bool is_port_available(const uint16_t port);
190188

191189
/**
192190
* Wait until the port is not available (is used by any application).
@@ -197,8 +195,7 @@ bool is_port_available(const uint16_t port);
197195
* @return false if the port is still available after the timeout expiry,
198196
* true otherwise.
199197
*/
200-
STDX_NODISCARD
201-
bool wait_for_port_not_available(
198+
[[nodiscard]] bool wait_for_port_not_available(
202199
const uint16_t port,
203200
std::chrono::milliseconds timeout = std::chrono::seconds(10));
204201

@@ -211,8 +208,7 @@ bool wait_for_port_not_available(
211208
* @return false if the port is still not available after the timeout expiry,
212209
* true otherwise.
213210
*/
214-
STDX_NODISCARD
215-
bool wait_for_port_available(
211+
[[nodiscard]] bool wait_for_port_available(
216212
const uint16_t port,
217213
std::chrono::milliseconds timeout = std::chrono::seconds(10));
218214

0 commit comments

Comments
 (0)