From 2a7af98480d82907ce7199c4f9510e0201273773 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 26 Apr 2022 10:08:16 -0700 Subject: [PATCH] Add explicit type cast in baggage UrlDecode --- api/include/opentelemetry/baggage/baggage.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/include/opentelemetry/baggage/baggage.h b/api/include/opentelemetry/baggage/baggage.h index 7f904f09a7..259fd7f3b6 100644 --- a/api/include/opentelemetry/baggage/baggage.h +++ b/api/include/opentelemetry/baggage/baggage.h @@ -249,7 +249,9 @@ class Baggage }; auto from_hex = [](char c) -> char { - return std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10; + // c - '0' produces integer type which could trigger error/warning when casting to char, + // but the cast is safe here. + return static_cast(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10); }; std::string ret;