-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Replace base10 users of StringUtil::atoull with absl::SimpleAtoi #6697
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
Changes from all commits
ae9a25e
d0521e6
c1ef18d
b02b73b
b803210
da9a4ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,6 +154,9 @@ class StringUtil { | |
|
|
||
| /** | ||
| * Convert a string to an unsigned long, checking for error. | ||
| * | ||
| * Consider absl::SimpleAtoi instead if using base 10. | ||
| * | ||
| * @param return true if successful, false otherwise. | ||
| */ | ||
| static bool atoull(const char* str, uint64_t& out, int base = 10); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the remaining use cases of this method?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are all hex conversions. I haven't dug around for the best option yet to replace them, but I plan to do that next as part of ongoing #6580 work. I am also planning to eliminate |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,10 +57,9 @@ void Common::chargeStat(const Upstream::ClusterInfo& cluster, const std::string& | |
| grpc_status->value().getStringView())) | ||
| .inc(); | ||
| uint64_t grpc_status_code; | ||
| const std::string grpc_status_string(grpc_status->value().getStringView()); | ||
| // TODO(dnoe): Migrate to pure string_view (#6580) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dnoe I think this can be removed now? Can you merge into one of your follow ups?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. |
||
| const bool success = | ||
| StringUtil::atoull(grpc_status_string.c_str(), grpc_status_code) && grpc_status_code == 0; | ||
| const bool success = absl::SimpleAtoi(grpc_status->value().getStringView(), &grpc_status_code) && | ||
| grpc_status_code == 0; | ||
| chargeStat(cluster, protocol, grpc_service, grpc_method, success); | ||
| } | ||
|
|
||
|
|
@@ -88,9 +87,7 @@ absl::optional<Status::GrpcStatus> Common::getGrpcStatus(const Http::HeaderMap& | |
| if (!grpc_status_header || grpc_status_header->value().empty()) { | ||
| return absl::optional<Status::GrpcStatus>(); | ||
| } | ||
| // TODO(dnoe): Migrate to pure string_view (#6580) | ||
| std::string grpc_status_header_string(grpc_status_header->value().getStringView()); | ||
| if (!StringUtil::atoull(grpc_status_header_string.c_str(), grpc_status_code) || | ||
| if (!absl::SimpleAtoi(grpc_status_header->value().getStringView(), &grpc_status_code) || | ||
| grpc_status_code > Status::GrpcStatus::MaximumValid) { | ||
| return absl::optional<Status::GrpcStatus>(Status::GrpcStatus::InvalidCode); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,6 +223,7 @@ SIGFPE | |
| SIGILL | ||
| SIGSEGV | ||
| SIGTERM | ||
| SimpleAtoi | ||
| SNI | ||
| SPDY | ||
| SPIFFE | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.