Skip to content

Commit

Permalink
Remove unused variables. Use constants for array sizes.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomRoSystems committed Jan 28, 2021
1 parent 643602b commit 1a8bb3c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions api/include/opentelemetry/trace/propagation/b3_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ static const int kTraceFlagHexStrLength = 1;

// The B3PropagatorExtractor class provides an interface that enables extracting context from
// headers of HTTP requests. HTTP frameworks and clients can integrate with B3Propagator by
// providing the object containing the headers, and a getter function for the extraction.
// Based on:
// providing the object containing the headers, and a getter function for the extraction. Based on:
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#b3-extract
template <typename T>
class B3PropagatorExtractor : public HTTPTextFormat<T>
Expand Down Expand Up @@ -77,15 +76,13 @@ class B3PropagatorExtractor : public HTTPTextFormat<T>
static TraceId GenerateTraceIdFromString(nostd::string_view trace_id)
{
uint8_t buf[kTraceIdHexStrLength / 2];
uint8_t *b_ptr = buf;
GenerateBuffFromHexStrPad0(trace_id, sizeof(buf), buf);
return TraceId(buf);
}

static SpanId GenerateSpanIdFromString(nostd::string_view span_id)
{
uint8_t buf[kSpanIdHexStrLength / 2];
uint8_t *b_ptr = buf;
GenerateBuffFromHexStrPad0(span_id, sizeof(buf), buf);
return SpanId(buf);
}
Expand Down Expand Up @@ -136,15 +133,15 @@ class B3PropagatorExtractor : public HTTPTextFormat<T>
{
if (c >= '0' && c <= '9')
{
return (int)(c - '0');
return (int8_t)(c - '0');
}
else if (c >= 'a' && c <= 'f')
{
return (int)(c - 'a' + 10);
return (int8_t)(c - 'a' + 10);
}
else if (c >= 'A' && c <= 'F')
{
return (int)(c - 'A' + 10);
return (int8_t)(c - 'A' + 10);
}
else
{
Expand Down Expand Up @@ -221,9 +218,9 @@ class B3Propagator : public B3PropagatorExtractor<T>
{
return;
}
char trace_id[32];
char trace_id[kTraceIdHexStrLength];
TraceId(span_context.trace_id()).ToLowerBase16(trace_id);
char span_id[16];
char span_id[kSpanIdHexStrLength];
SpanId(span_context.span_id()).ToLowerBase16(span_id);
char trace_flags[2];
TraceFlags(span_context.trace_flags()).ToLowerBase16(trace_flags);
Expand Down

0 comments on commit 1a8bb3c

Please sign in to comment.