Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more clang and gcc warnings #1658

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/kv_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,4 @@ class KeyValueProperties
size_t Size() const noexcept { return num_entries_; }
};
} // namespace common
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ class CompositePropagator : public TextMapPropagator
};
} // namespace propagation
} // namespace context
OPENTELEMETRY_END_NAMESPACE;
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class NoopUpDownCounter : public UpDownCounter<T>
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
~NoopUpDownCounter() = default;
~NoopUpDownCounter() override = default;
void Add(T /* value */) noexcept override {}
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
{}
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/std/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
}

template <class T, std::size_t N>
std::size_t size(T (&array)[N]) noexcept
std::size_t size(T (&/* array */)[N]) noexcept
{
return N;
}
Expand Down
18 changes: 9 additions & 9 deletions api/include/opentelemetry/std/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,58 +146,58 @@ template <std::size_t I, class... Types>
constexpr std::variant_alternative_t<I, std::variant<Types...>> &get(std::variant<Types...> &v)
{
return std::get<I, Types...>(v);
};
}

template <std::size_t I, class... Types>
constexpr std::variant_alternative_t<I, std::variant<Types...>> &&get(std::variant<Types...> &&v)
{
return std::get<I, Types...>(std::forward<decltype(v)>(v));
};
}

template <std::size_t I, class... Types>
constexpr const std::variant_alternative_t<I, std::variant<Types...>> &get(
const std::variant<Types...> &v)
{
return std::get<I, Types...>(v);
};
}

template <std::size_t I, class... Types>
constexpr const std::variant_alternative_t<I, std::variant<Types...>> &&get(
const std::variant<Types...> &&v)
{
return std::get<I, Types...>(std::forward<decltype(v)>(v));
};
}

template <class T, class... Types>
constexpr T &get(std::variant<Types...> &v)
{
return std::get<T, Types...>(v);
};
}

template <class T, class... Types>
constexpr T &&get(std::variant<Types...> &&v)
{
return std::get<T, Types...>(std::forward<decltype(v)>(v));
};
}

template <class T, class... Types>
constexpr const T &get(const std::variant<Types...> &v)
{
return std::get<T, Types...>(v);
};
}

template <class T, class... Types>
constexpr const T &&get(const std::variant<Types...> &&v)
{
return std::get<T, Types...>(std::forward<decltype(v)>(v));
};
}

template <class _Callable, class... _Variants>
constexpr auto visit(_Callable &&_Obj, _Variants &&... _Args)
{
return std::visit<_Callable, _Variants...>(static_cast<_Callable &&>(_Obj),
static_cast<_Variants &&>(_Args)...);
};
}

#endif

Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ inline context::Context SetSpan(opentelemetry::context::Context &context,
}

} // namespace trace
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/span_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ struct EndSpanOptions
};

} // namespace trace
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/span_startoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ struct StartSpanOptions
};

} // namespace trace
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion api/test/metrics/noop_sync_instrument_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ TEST(UpDownCountr, Record)
counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{});
}

#endif
#endif
2 changes: 1 addition & 1 deletion examples/common/metrics_foo_library/foo_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::map<std::string, std::string> get_random_attr()
class MeasurementFetcher
{
public:
static void Fetcher(opentelemetry::metrics::ObserverResult observer_result, void *state)
static void Fetcher(opentelemetry::metrics::ObserverResult observer_result, void * /* state */)
{
std::map<std::string, std::string> labels = get_random_attr();
auto labelkv = opentelemetry::common::KeyValueIterableView<decltype(labels)>{labels};
Expand Down
5 changes: 3 additions & 2 deletions examples/http/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback
std::string span_name = request.uri;

// extract context from http header
const HttpTextMapCarrier<std::map<std::string, std::string>> carrier(
(std::map<std::string, std::string> &)request.headers);
std::map<std::string, std::string> &request_headers =
const_cast<std::map<std::string, std::string> &>(request.headers);
const HttpTextMapCarrier<std::map<std::string, std::string>> carrier(request_headers);
auto prop = context::propagation::GlobalTextMapPropagator::GetGlobalPropagator();
auto current_ctx = context::RuntimeContext::GetCurrent();
auto new_context = prop->Extract(carrier, current_ctx);
Expand Down
2 changes: 1 addition & 1 deletion examples/http/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ class HttpServer : public HTTP_SERVER_NS::HttpRequestCallback
~HttpServer() { Stop(); }
};

} // namespace
} // namespace
6 changes: 3 additions & 3 deletions examples/plugin/plugin/factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class FactoryImpl final : public plugin::Factory::FactoryImpl
public:
// opentelemetry::plugin::Factory::FactoryImpl
nostd::unique_ptr<plugin::TracerHandle> MakeTracerHandle(
nostd::string_view tracer_config,
nostd::unique_ptr<char[]> &error_message) const noexcept override
nostd::string_view /* tracer_config */,
nostd::unique_ptr<char[]> & /* error_message */) const noexcept override
{
std::shared_ptr<Tracer> tracer{new (std::nothrow) Tracer{""}};
if (tracer == nullptr)
Expand All @@ -46,4 +46,4 @@ static nostd::unique_ptr<plugin::Factory::FactoryImpl> MakeFactoryImpl(
return nostd::unique_ptr<plugin::Factory::FactoryImpl>{new (std::nothrow) FactoryImpl{}};
}

OPENTELEMETRY_DEFINE_PLUGIN_HOOK(MakeFactoryImpl);
OPENTELEMETRY_DEFINE_PLUGIN_HOOK(MakeFactoryImpl)
2 changes: 1 addition & 1 deletion examples/plugin/plugin/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Span final : public trace::Span
std::cout << "StartSpan: " << name << "\n";
}

~Span() { std::cout << "~Span\n"; }
~Span() override { std::cout << "~Span\n"; }

// opentelemetry::trace::Span
void SetAttribute(nostd::string_view /*name*/,
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/src/jaeger_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void JaegerExporter::InitializeEndpoint()
assert(false);
}

bool JaegerExporter::Shutdown(std::chrono::microseconds timeout) noexcept
bool JaegerExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept
{
const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_);
is_shutdown_ = true;
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/src/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void JaegerRecordable::SetInstrumentationScope(
}

void JaegerRecordable::AddLink(const trace::SpanContext &span_context,
const common::KeyValueIterable &attributes) noexcept
const common::KeyValueIterable & /* attributes */) noexcept
{
// Note: "The Link’s attributes cannot be represented in Jaeger explicitly."
// -- https://opentelemetry.io/docs/reference/specification/trace/sdk_exporters/jaeger/#links
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/src/udp_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UDPTransport : public Transport
static constexpr auto kUDPPacketMaxLength = 65000;

UDPTransport(const std::string &addr, uint16_t port);
virtual ~UDPTransport();
~UDPTransport() override;

int EmitBatch(const thrift::Batch &batch) override;

Expand Down
2 changes: 1 addition & 1 deletion exporters/memory/src/in_memory_span_exporter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> InMemorySpanExporterFac
std::shared_ptr<InMemorySpanData> &data)
{
return Create(data, MAX_BUFFER_SIZE);
};
}

std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> InMemorySpanExporterFactory::Create(
std::shared_ptr<InMemorySpanData> &data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ inline void print_value(const opentelemetry::sdk::common::OwnedAttributeValue &v

} // namespace ostream_common
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion exporters/ostream/src/span_exporter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace trace
std::unique_ptr<trace_sdk::SpanExporter> OStreamSpanExporterFactory::Create()
{
return Create(std::cout);
};
}

std::unique_ptr<trace_sdk::SpanExporter> OStreamSpanExporterFactory::Create(std::ostream &sout)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::MetricExporte
} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ struct OtlpGrpcMetricExporterOptions : public OtlpGrpcExporterOptions

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif
4 changes: 2 additions & 2 deletions exporters/otlp/src/otlp_populate_attribute_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void OtlpPopulateAttributeUtils::PopulateAttribute(
}
else if (nostd::holds_alternative<std::vector<bool>>(value))
{
for (const auto &val : nostd::get<std::vector<bool>>(value))
for (const auto val : nostd::get<std::vector<bool>>(value))
{
attribute->mutable_value()->mutable_array_value()->add_values()->set_bool_value(val);
}
Expand Down Expand Up @@ -242,4 +242,4 @@ void OtlpPopulateAttributeUtils::PopulateAttribute(

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ proto::common::v1::InstrumentationScope OtlpRecordable::GetProtoInstrumentationS
void OtlpRecordable::SetResource(const sdk::resource::Resource &resource) noexcept
{
resource_ = &resource;
};
}

void OtlpRecordable::SetAttribute(nostd::string_view key,
const common::AttributeValue &value) noexcept
Expand Down
6 changes: 3 additions & 3 deletions exporters/prometheus/src/exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PrometheusExporter::PrometheusExporter() : is_shutdown_(false)
}

sdk::metrics::AggregationTemporality PrometheusExporter::GetAggregationTemporality(
sdk::metrics::InstrumentType instrument_type) const noexcept
sdk::metrics::InstrumentType /* instrument_type */) const noexcept
{
// Prometheus exporter only support Cumulative
return sdk::metrics::AggregationTemporality::kCumulative;
Expand Down Expand Up @@ -69,7 +69,7 @@ sdk::common::ExportResult PrometheusExporter::Export(
return sdk::common::ExportResult::kSuccess;
}

bool PrometheusExporter::ForceFlush(std::chrono::microseconds timeout) noexcept
bool PrometheusExporter::ForceFlush(std::chrono::microseconds /* timeout */) noexcept
{
return true;
}
Expand All @@ -81,7 +81,7 @@ bool PrometheusExporter::ForceFlush(std::chrono::microseconds timeout) noexcept
* collection to to client an HTTP request being sent,
* so we flush the data.
*/
bool PrometheusExporter::Shutdown(std::chrono::microseconds timeout) noexcept
bool PrometheusExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept
{
is_shutdown_ = true;
return true;
Expand Down
2 changes: 1 addition & 1 deletion exporters/prometheus/src/exporter_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me
metric.label[i++].value = AttributeValueToString(label.second);
}
}
};
}

std::string PrometheusExporterUtils::AttributeValueToString(
const opentelemetry::sdk::common::OwnedAttributeValue &value)
Expand Down
4 changes: 2 additions & 2 deletions exporters/zipkin/src/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ void Recordable::AddEvent(nostd::string_view name,
span_["annotations"].push_back(annotation);
}

void Recordable::AddLink(const trace_api::SpanContext &span_context,
const common::KeyValueIterable &attributes) noexcept
void Recordable::AddLink(const trace_api::SpanContext & /* span_context */,
const common::KeyValueIterable & /* attributes */) noexcept
{
// TODO: Currently not supported by specs:
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md
Expand Down
2 changes: 1 addition & 1 deletion exporters/zipkin/src/zipkin_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void ZipkinExporter::InitializeLocalEndpoint()
local_end_point_["port"] = url_parser_.port_;
}

bool ZipkinExporter::Shutdown(std::chrono::microseconds timeout) noexcept
bool ZipkinExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept
{
const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_);
is_shutdown_ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class HttpClientSync : public opentelemetry::ext::http::client::HttpClientSync
return opentelemetry::ext::http::client::Result(std::move(response), session_state);
}

~HttpClientSync() {}
~HttpClientSync() override {}

private:
nostd::shared_ptr<HttpCurlGlobalInitializer> curl_global_initializer_;
Expand All @@ -274,7 +274,7 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient
public:
// The call (curl_global_init) is not thread safe. Ensure this is called only once.
HttpClient();
~HttpClient();
~HttpClient() override;

std::shared_ptr<opentelemetry::ext::http::client::Session> CreateSession(
nostd::string_view url) noexcept override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# include <gtest/gtest.h>
# include "gmock/gmock.h"

using namespace testing;
OPENTELEMETRY_BEGIN_NAMESPACE
namespace ext
{
Expand Down
3 changes: 2 additions & 1 deletion ext/include/opentelemetry/ext/http/server/http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class HttpRequestCallback

public:
HttpRequestCallback() {}
virtual ~HttpRequestCallback() = default;

HttpRequestCallback &operator=(HttpRequestCallback other)
{
Expand Down Expand Up @@ -175,7 +176,7 @@ class HttpServer : private SocketTools::Reactor::SocketCallback
addListeningPort(port);
}

~HttpServer()
~HttpServer() override
{
for (auto &sock : m_listeningSockets)
{
Expand Down
Loading