Skip to content

Commit 4307862

Browse files
authored
[CODE HEALTH] Fix clang-tidy bugprone warnings (#3933)
1 parent 86e5c6d commit 4307862

File tree

6 files changed

+18
-31
lines changed

6 files changed

+18
-31
lines changed

api/include/opentelemetry/plugin/detail/utility.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ try
2929
}
3030
#if __EXCEPTIONS
3131
catch (const std::bad_alloc &)
32-
{}
32+
{
33+
return;
34+
}
3335
#endif
3436
} // namespace detail
3537
} // namespace plugin

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client_options.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414
#include <ostream>
1515
#include <string>
1616

17-
// forward declare google::protobuf::Message
18-
namespace google
19-
{
20-
namespace protobuf
21-
{
22-
class Message;
23-
}
24-
} // namespace google
25-
2617
OPENTELEMETRY_BEGIN_NAMESPACE
2718
namespace exporter
2819
{

exporters/otlp/src/otlp_grpc_client.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ template <class StubType, class RequestType, class ResponseType>
162162
static sdk::common::ExportResult InternalDelegateAsyncExport(
163163
const std::shared_ptr<OtlpGrpcClientAsyncData> &async_data,
164164
StubType *stub,
165-
std::unique_ptr<grpc::ClientContext> &&context,
166-
std::unique_ptr<google::protobuf::Arena> &&arena,
167-
RequestType &&request,
165+
std::unique_ptr<grpc::ClientContext> context,
166+
std::unique_ptr<google::protobuf::Arena> arena,
167+
RequestType request,
168168
std::function<bool(opentelemetry::sdk::common::ExportResult,
169169
std::unique_ptr<google::protobuf::Arena> &&,
170170
const RequestType &,
171-
ResponseType *)> &&result_callback,
171+
ResponseType *)> result_callback,
172172
int32_t export_data_count,
173173
const char *export_data_name) noexcept
174174
{
@@ -188,11 +188,14 @@ static sdk::common::ExportResult InternalDelegateAsyncExport(
188188

189189
std::shared_ptr<OtlpGrpcAsyncCallData<RequestType, ResponseType>> call_data =
190190
std::make_shared<OtlpGrpcAsyncCallData<RequestType, ResponseType>>();
191-
call_data->arena.swap(arena);
192-
call_data->result_callback.swap(result_callback);
191+
call_data->arena = std::move(arena);
192+
call_data->result_callback = std::move(result_callback);
193193

194-
call_data->request = google::protobuf::Arena::Create<RequestType>(
195-
call_data->arena.get(), std::forward<RequestType>(request));
194+
call_data->request = google::protobuf::Arena::Create<RequestType>(call_data->arena.get());
195+
if (call_data->request != nullptr)
196+
{
197+
call_data->request->Swap(&request);
198+
}
196199
call_data->response = google::protobuf::Arena::Create<ResponseType>(call_data->arena.get());
197200

198201
if (call_data->request == nullptr || call_data->response == nullptr)
@@ -210,7 +213,7 @@ static sdk::common::ExportResult InternalDelegateAsyncExport(
210213

211214
return opentelemetry::sdk::common::ExportResult::kFailure;
212215
}
213-
call_data->grpc_context.swap(context);
216+
call_data->grpc_context = std::move(context);
214217

215218
call_data->grpc_async_callback = [](OtlpGrpcAsyncCallDataBase *base_call_data) {
216219
OtlpGrpcAsyncCallData<RequestType, ResponseType> *real_call_data =

sdk/include/opentelemetry/sdk/common/global_log_handler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ OPENTELEMETRY_END_NAMESPACE
143143
{ \
144144
using opentelemetry::sdk::common::internal_log::GlobalLogHandler; \
145145
using opentelemetry::sdk::common::internal_log::LogHandler; \
146-
if (level > GlobalLogHandler::GetLogLevel()) \
146+
if ((level) > GlobalLogHandler::GetLogLevel()) \
147147
{ \
148148
break; \
149149
} \
@@ -153,8 +153,9 @@ OPENTELEMETRY_END_NAMESPACE
153153
break; \
154154
} \
155155
std::stringstream tmp_stream; \
156+
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
156157
tmp_stream << message; \
157-
log_handler->Handle(level, __FILE__, __LINE__, tmp_stream.str().c_str(), attributes); \
158+
log_handler->Handle((level), __FILE__, __LINE__, tmp_stream.str().c_str(), attributes); \
158159
} while (false);
159160

160161
#define OTEL_INTERNAL_LOG_GET_3RD_ARG(arg1, arg2, arg3, ...) arg3

sdk/include/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
# include "opentelemetry/version.h"
1818

1919
OPENTELEMETRY_BEGIN_NAMESPACE
20-
namespace common
21-
{
22-
class OrderedAttributeMap;
23-
} // namespace common
24-
2520
namespace context
2621
{
2722
class Context;

sdk/include/opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
# include "src/common/random.h"
1818

1919
OPENTELEMETRY_BEGIN_NAMESPACE
20-
namespace common
21-
{
22-
class OrderedAttributeMap;
23-
} // namespace common
24-
2520
namespace context
2621
{
2722
class Context;

0 commit comments

Comments
 (0)