Fix integer sign comparison

This commit is contained in:
Boris Staletic 2018-01-31 06:55:53 +01:00 committed by Fangrui Song
parent 015195036c
commit be4d37dac3
9 changed files with 16 additions and 16 deletions

View File

@ -20,7 +20,7 @@ std::string ElideLongPath(Config* config, const std::string& path) {
if (config->includeCompletionMaximumPathLength <= 0) if (config->includeCompletionMaximumPathLength <= 0)
return path; return path;
if (path.size() <= config->includeCompletionMaximumPathLength) if ((int)path.size() <= config->includeCompletionMaximumPathLength)
return path; return path;
size_t start = path.size() - config->includeCompletionMaximumPathLength; size_t start = path.size() - config->includeCompletionMaximumPathLength;

View File

@ -57,7 +57,7 @@ optional<std::string> ReadJsonRpcContentFrom(
// Read content. // Read content.
std::string content; std::string content;
content.reserve(content_length); content.reserve(content_length);
for (size_t i = 0; i < content_length; ++i) { for (int i = 0; i < content_length; ++i) {
optional<char> c = read(); optional<char> c = read();
if (!c) { if (!c) {
LOG_S(INFO) << "No more input when reading content body"; LOG_S(INFO) << "No more input when reading content body";

View File

@ -27,7 +27,7 @@ lsPosition CharPos(std::string_view search,
char character, char character,
int character_offset) { int character_offset) {
lsPosition result; lsPosition result;
int index = 0; size_t index = 0;
while (index < search.size()) { while (index < search.size()) {
char c = search[index]; char c = search[index];
if (c == character) if (c == character)
@ -91,13 +91,13 @@ void DecorateIncludePaths(const std::smatch& match,
optional<lsRange> ExtractQuotedRange(int line_number, const std::string& line) { optional<lsRange> ExtractQuotedRange(int line_number, const std::string& line) {
// Find starting and ending quote. // Find starting and ending quote.
int start = 0; int start = 0;
while (start < line.size()) { while (start < (int)line.size()) {
char c = line[start]; char c = line[start];
++start; ++start;
if (c == '"' || c == '<') if (c == '"' || c == '<')
break; break;
} }
if (start == line.size()) if (start == (int)line.size())
return nullopt; return nullopt;
int end = (int)line.size(); int end = (int)line.size();

View File

@ -95,7 +95,7 @@ std::shared_ptr<TValue> LruCache<TKey, TValue>::TryTake(const TKey& key) {
template <typename TKey, typename TValue> template <typename TKey, typename TValue>
void LruCache<TKey, TValue>::Insert(const TKey& key, void LruCache<TKey, TValue>::Insert(const TKey& key,
const std::shared_ptr<TValue>& value) { const std::shared_ptr<TValue>& value) {
if (entries_.size() >= max_entries_) if ((int)entries_.size() >= max_entries_)
entries_.erase(std::min_element(entries_.begin(), entries_.end())); entries_.erase(std::min_element(entries_.begin(), entries_.end()));
Entry entry; Entry entry;

View File

@ -456,7 +456,7 @@ struct TextDocumentCodeActionHandler
std::unordered_set<std::string> include_absolute_paths; std::unordered_set<std::string> include_absolute_paths;
// Find include candidate strings. // Find include candidate strings.
for (int i = 0; i < db->symbols.size(); ++i) { for (size_t i = 0; i < db->symbols.size(); ++i) {
if (include_absolute_paths.size() > kMaxResults) if (include_absolute_paths.size() > kMaxResults)
break; break;
if (db->GetSymbolDetailedName(i).find(include_query) == if (db->GetSymbolDetailedName(i).find(include_query) ==

View File

@ -221,7 +221,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
bool did_fail_check = false; bool did_fail_check = false;
std::string character = *request->params.context->triggerCharacter; std::string character = *request->params.context->triggerCharacter;
char preceding_index = request->params.position.character - 2; int preceding_index = request->params.position.character - 2;
// If the character is '"', '<' or '/', make sure that the line starts with '#'. // If the character is '"', '<' or '/', make sure that the line starts with '#'.
if (character == "\"" || character == "<" || character == "/") { if (character == "\"" || character == "<" || character == "/") {
@ -238,7 +238,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
} }
// If the character is > but - does not preced it, or if it is : and : // If the character is > but - does not preced it, or if it is : and :
// does not preced it, do not show completion results. // does not preced it, do not show completion results.
else if (preceding_index < buffer_line.size()) { else if (preceding_index < (int)buffer_line.size()) {
char preceding = buffer_line[preceding_index]; char preceding = buffer_line[preceding_index];
did_fail_check = (preceding != '-' && character == ">") || did_fail_check = (preceding != '-' && character == ">") ||
(preceding != ':' && character == ":"); (preceding != ':' && character == ":");

View File

@ -106,7 +106,7 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
if (!isspace(c)) if (!isspace(c))
query_without_space += c; query_without_space += c;
for (int i = 0; i < db->symbols.size(); ++i) { for (int i = 0; i < (int)db->symbols.size(); ++i) {
std::string_view detailed_name = db->GetSymbolDetailedName(i); std::string_view detailed_name = db->GetSymbolDetailedName(i);
if (SubsequenceMatch(query_without_space, detailed_name)) { if (SubsequenceMatch(query_without_space, detailed_name)) {
// Do not show the same entry twice. // Do not show the same entry twice.

View File

@ -428,28 +428,28 @@ int ComputeGuessScore(const std::string& a, const std::string& b) {
const int kMatchPostfixWeight = 1; const int kMatchPostfixWeight = 1;
int score = 0; int score = 0;
int i = 0; size_t i = 0;
// Increase score based on matching prefix. // Increase score based on matching prefix.
for (i = 0; i < a.length() && i < b.length(); ++i) { for (i = 0; i < a.size() && i < b.size(); ++i) {
if (a[i] != b[i]) if (a[i] != b[i])
break; break;
score += kMatchPrefixWeight; score += kMatchPrefixWeight;
} }
// Reduce score based on mismatched directory distance. // Reduce score based on mismatched directory distance.
for (int j = i; j < a.length(); ++j) { for (size_t j = i; j < a.size(); ++j) {
if (a[j] == '/') if (a[j] == '/')
score -= kMismatchDirectoryWeight; score -= kMismatchDirectoryWeight;
} }
for (int j = i; j < b.length(); ++j) { for (size_t j = i; j < b.size(); ++j) {
if (b[j] == '/') if (b[j] == '/')
score -= kMismatchDirectoryWeight; score -= kMismatchDirectoryWeight;
} }
// Increase score based on common ending. Don't increase as much as matching // Increase score based on common ending. Don't increase as much as matching
// prefix or directory distance. // prefix or directory distance.
for (int offset = 1; offset <= a.length() && offset <= b.length(); ++offset) { for (size_t offset = 1; offset <= a.size() && offset <= b.size(); ++offset) {
if (a[a.size() - offset] != b[b.size() - offset]) if (a[a.size() - offset] != b[b.size() - offset])
break; break;
score += kMatchPostfixWeight; score += kMatchPostfixWeight;

View File

@ -81,7 +81,7 @@ void DiffDocuments(std::string path,
int max_diff = 5; int max_diff = 5;
size_t len = std::min(actual_output.size(), expected_output.size()); size_t len = std::min(actual_output.size(), expected_output.size());
for (int i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
if (actual_output[i] != expected_output[i]) { if (actual_output[i] != expected_output[i]) {
if (--max_diff < 0) { if (--max_diff < 0) {
std::cout << "(... more lines may differ ...)" << std::endl; std::cout << "(... more lines may differ ...)" << std::endl;