summaryrefslogtreecommitdiff
path: root/absl/flags/parse.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-08 12:21:40 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-08 12:22:28 -0700
commit69199fcebe806a49a21992575b5227ee432f6917 (patch)
tree9013b1e4fc06bd7fa9a7d69ecdb9739eb184cfb8 /absl/flags/parse.cc
parent518984e432e0597fd4e66a9c52148e8dec2bb46a (diff)
Fix "unsafe narrowing" warnings in absl, 9/n.
Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on miscellaneous non-test source files.) Bug: chromium:1292951 PiperOrigin-RevId: 473054605 Change-Id: Ifd7b24966613ca915511a3a607095508068200b8
Diffstat (limited to 'absl/flags/parse.cc')
-rw-r--r--absl/flags/parse.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc
index dd1a6796..2851c0f7 100644
--- a/absl/flags/parse.cc
+++ b/absl/flags/parse.cc
@@ -159,14 +159,14 @@ class ArgsList {
// Returns success status: true if parsing successful, false otherwise.
bool ReadFromFlagfile(const std::string& flag_file_name);
- int Size() const { return args_.size() - next_arg_; }
- int FrontIndex() const { return next_arg_; }
+ size_t Size() const { return args_.size() - next_arg_; }
+ size_t FrontIndex() const { return next_arg_; }
absl::string_view Front() const { return args_[next_arg_]; }
void PopFront() { next_arg_++; }
private:
std::vector<std::string> args_;
- int next_arg_;
+ size_t next_arg_;
};
bool ArgsList::ReadFromFlagfile(const std::string& flag_file_name) {
@@ -626,7 +626,7 @@ std::vector<char*> ParseCommandLineImpl(int argc, char* argv[],
std::vector<char*> output_args;
std::vector<char*> positional_args;
- output_args.reserve(argc);
+ output_args.reserve(static_cast<size_t>(argc));
// This is the list of undefined flags. The element of the list is the pair
// consisting of boolean indicating if flag came from command line (vs from
@@ -795,8 +795,8 @@ std::vector<char*> ParseCommandLineImpl(int argc, char* argv[],
// All the remaining arguments are positional.
if (!input_args.empty()) {
- for (int arg_index = input_args.back().FrontIndex(); arg_index < argc;
- ++arg_index) {
+ for (size_t arg_index = input_args.back().FrontIndex();
+ arg_index < static_cast<size_t>(argc); ++arg_index) {
output_args.push_back(argv[arg_index]);
}
}