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 build warnings #1613

Merged
merged 4 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion api/include/opentelemetry/baggage/baggage.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Baggage

Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
Baggage(size_t size) noexcept
: kv_properties_(new opentelemetry::common::KeyValueProperties(size)){};
: kv_properties_(new opentelemetry::common::KeyValueProperties(size))
{}

template <class T>
Baggage(const T &keys_and_values) noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ class NoOpPropagator : public TextMapPropagator
}

/** Noop inject function does nothing */
void Inject(TextMapCarrier & /*carrier*/, const context::Context &context) noexcept override {}
void Inject(TextMapCarrier & /*carrier*/,
const context::Context & /* context */) noexcept override
{}

bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept override
bool Fields(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept override
{
return true;
}
};
} // namespace propagation
} // namespace context
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TextMapCarrier

/* list of all the keys in the carrier.
By default, it returns true without invoking callback */
virtual bool Keys(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept
virtual bool Keys(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RuntimeContextStorage
*/
virtual bool Detach(Token &token) noexcept = 0;

virtual ~RuntimeContextStorage(){};
virtual ~RuntimeContextStorage() {}

protected:
nostd::unique_ptr<Token> CreateToken(const Context &context) noexcept
Expand Down Expand Up @@ -232,7 +232,7 @@ class ThreadLocalContextStorage : public RuntimeContextStorage
{
friend class ThreadLocalContextStorage;

Stack() noexcept : size_(0), capacity_(0), base_(nullptr){};
Stack() noexcept : size_(0), capacity_(0), base_(nullptr) {}

// Pops the top Context off the stack.
void Pop() noexcept
Expand Down
34 changes: 17 additions & 17 deletions api/include/opentelemetry/logs/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class NoopLogger final : public Logger
public:
const nostd::string_view GetName() noexcept override { return "noop logger"; }

void Log(Severity severity,
nostd::string_view body,
const common::KeyValueIterable &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept override
void Log(Severity /* severity */,
nostd::string_view /* body */,
const common::KeyValueIterable & /* attributes */,
trace::TraceId /* trace_id */,
trace::SpanId /* span_id */,
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}
};

Expand All @@ -62,20 +62,20 @@ class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider
nostd::shared_ptr<opentelemetry::logs::NoopLogger>(new opentelemetry::logs::NoopLogger)}
{}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options,
nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") override
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
nostd::string_view /* options */,
nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) override
{
return logger_;
}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") override
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
nostd::span<nostd::string_view> /* args */,
nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) override
{
return logger_;
}
Expand Down
72 changes: 38 additions & 34 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,65 @@ template <class T>
class NoopCounter : public Counter<T>
{
public:
NoopCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit) noexcept
NoopCounter(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
void Add(T value) noexcept override {}
void Add(T value, const opentelemetry::context::Context &context) noexcept override {}
void Add(T value, const common::KeyValueIterable &attributes) noexcept override {}
void Add(T value,
const common::KeyValueIterable &attributes,
const opentelemetry::context::Context &context) noexcept override
void Add(T /* value */) noexcept override {}
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
{}
void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
void Add(T /* value */,
const common::KeyValueIterable & /* attributes */,
const opentelemetry::context::Context & /* context */) noexcept override
{}
};

template <class T>
class NoopHistogram : public Histogram<T>
{
public:
NoopHistogram(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit) noexcept
NoopHistogram(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
void Record(T /* value */,
const opentelemetry::context::Context & /* context */) noexcept override
{}
void Record(T value, const opentelemetry::context::Context &context) noexcept override {}
void Record(T value,
const common::KeyValueIterable &attributes,
const opentelemetry::context::Context &context) noexcept override
void Record(T /* value */,
const common::KeyValueIterable & /* attributes */,
const opentelemetry::context::Context & /* context */) noexcept override
{}
};

template <class T>
class NoopUpDownCounter : public UpDownCounter<T>
{
public:
NoopUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit) noexcept
NoopUpDownCounter(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
void Add(T /* value */) noexcept override {}
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
{}
void Add(T value) noexcept override {}
void Add(T value, const opentelemetry::context::Context &context) noexcept override {}
void Add(T value, const common::KeyValueIterable &attributes) noexcept override {}
void Add(T value,
const common::KeyValueIterable &attributes,
const opentelemetry::context::Context &context) noexcept override
void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
void Add(T /* value */,
const common::KeyValueIterable & /* attributes */,
const opentelemetry::context::Context & /* context */) noexcept override
{}
};

class NoopObservableInstrument : public ObservableInstrument
{
public:
NoopObservableInstrument(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit) noexcept
NoopObservableInstrument(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}

void AddCallback(ObservableCallbackPtr, void *state) noexcept override {}
void RemoveCallback(ObservableCallbackPtr, void *state) noexcept override {}
void AddCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
void RemoveCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
};

/**
Expand Down Expand Up @@ -194,9 +198,9 @@ class NoopMeterProvider final : public MeterProvider
public:
NoopMeterProvider() : meter_{nostd::shared_ptr<Meter>(new NoopMeter)} {}

nostd::shared_ptr<Meter> GetMeter(nostd::string_view library_name,
nostd::string_view library_version,
nostd::string_view schema_url) noexcept override
nostd::shared_ptr<Meter> GetMeter(nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) noexcept override
{
return meter_;
}
Expand All @@ -206,4 +210,4 @@ class NoopMeterProvider final : public MeterProvider
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
18 changes: 11 additions & 7 deletions api/include/opentelemetry/nostd/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class string_view
if (result == 0)
result = size() == v.size() ? 0 : (size() < v.size() ? -1 : 1);
return result;
};
}

int compare(size_type pos1, size_type count1, string_view v) const
{
return substr(pos1, count1).compare(v);
};
}

int compare(size_type pos1,
size_type count1,
Expand All @@ -95,19 +95,19 @@ class string_view
size_type count2) const
{
return substr(pos1, count1).compare(v.substr(pos2, count2));
};
}

int compare(const char *s) const { return compare(string_view(s)); };
int compare(const char *s) const { return compare(string_view(s)); }

int compare(size_type pos1, size_type count1, const char *s) const
{
return substr(pos1, count1).compare(string_view(s));
};
}

int compare(size_type pos1, size_type count1, const char *s, size_type count2) const
{
return substr(pos1, count1).compare(string_view(s, count2));
};
}

size_type find(char ch, size_type pos = 0) const noexcept
{
Expand Down Expand Up @@ -138,9 +138,13 @@ class string_view
inline bool operator==(string_view lhs, string_view rhs) noexcept
{
return lhs.length() == rhs.length() &&
# if _MSC_VER == 1900
# if defined(_MSC_VER)
# if _MSC_VER == 1900
// Avoid SCL error in Visual Studio 2015
(std::memcmp(lhs.data(), rhs.data(), lhs.length()) == 0);
# else
std::equal(lhs.data(), lhs.data() + lhs.length(), rhs.data());
# endif
# else
std::equal(lhs.data(), lhs.data() + lhs.length(), rhs.data());
# endif
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
}

template <class T, size_t N>
size_t size(T (&array)[N]) noexcept
size_t size(T (&/* array */)[N]) noexcept
{
return N;
}
Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/trace/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class NoopTracerProvider final : public opentelemetry::trace::TracerProvider
{}

nostd::shared_ptr<opentelemetry::trace::Tracer> GetTracer(
nostd::string_view library_name,
nostd::string_view library_version,
nostd::string_view schema_url) noexcept override
nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) noexcept override
{
return tracer_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NullSpanContext : public SpanContextKeyValueIterable
return true;
}

size_t size() const noexcept override { return 0; };
size_t size() const noexcept override { return 0; }
};

} // namespace trace
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/trace_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class TraceState
}

private:
TraceState() : kv_properties_(new opentelemetry::common::KeyValueProperties()){};
TraceState(size_t size) : kv_properties_(new opentelemetry::common::KeyValueProperties(size)){};
TraceState() : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
TraceState(size_t size) : kv_properties_(new opentelemetry::common::KeyValueProperties(size)) {}

static nostd::string_view TrimString(nostd::string_view str, size_t left, size_t right)
{
Expand Down
6 changes: 4 additions & 2 deletions api/test/baggage/baggage_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void BM_ExtractBaggageHavingTenEntries(benchmark::State &state)
auto baggage = Baggage::FromHeader(header_with_custom_entries(kNumEntries));
while (state.KeepRunning())
{
baggage->GetAllEntries([](nostd::string_view key, nostd::string_view value) { return true; });
baggage->GetAllEntries(
[](nostd::string_view /* key */, nostd::string_view /* value */) { return true; });
}
}
BENCHMARK(BM_ExtractBaggageHavingTenEntries);
Expand All @@ -66,7 +67,8 @@ void BM_ExtractBaggageWith180Entries(benchmark::State &state)
auto baggage = Baggage::FromHeader(header_with_custom_entries(Baggage::kMaxKeyValuePairs));
while (state.KeepRunning())
{
baggage->GetAllEntries([](nostd::string_view key, nostd::string_view value) { return true; });
baggage->GetAllEntries(
[](nostd::string_view /* key */, nostd::string_view /* value */) { return true; });
}
}
BENCHMARK(BM_ExtractBaggageWith180Entries);
Expand Down
34 changes: 17 additions & 17 deletions api/test/logs/logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,33 @@ class TestLogger : public Logger
{
const nostd::string_view GetName() noexcept override { return "test logger"; }

void Log(Severity severity,
string_view body,
const common::KeyValueIterable &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept override
void Log(Severity /* severity */,
string_view /* body */,
const common::KeyValueIterable & /* attributes */,
trace::TraceId /* trace_id */,
trace::SpanId /* span_id */,
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}
};

// Define a basic LoggerProvider class that returns an instance of the logger class defined above
class TestProvider : public LoggerProvider
{
nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options,
nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") override
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
nostd::string_view /* options */,
nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) override
{
return shared_ptr<Logger>(new TestLogger());
}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") override
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
nostd::span<nostd::string_view> /* args */,
nostd::string_view /* library_name */,
nostd::string_view /* library_version */,
nostd::string_view /* schema_url */) override
{
return shared_ptr<Logger>(new TestLogger());
}
Expand Down
Loading