[Lldb-commits] [PATCH 2/2] Some fixes for different sign in comparison.
Marco Minutoli
mminutoli at gmail.com
Sat Apr 16 16:09:48 PDT 2011
This patch solves some of the warning due to comparison of integers of
different signs.
\e isn't portable so I replaced it with its octal value.
---
source/Core/DataExtractor.cpp | 10 ++--
source/Core/Opcode.cpp | 2 +-
source/Core/UserSettingsController.cpp | 52 +++++++++++++-------------
source/Expression/ClangExpressionDeclMap.cpp | 2 +-
source/Expression/ClangExpressionParser.cpp | 2 +-
source/Expression/IRForTarget.cpp | 2 +-
source/Host/common/FileSpec.cpp | 2 +-
7 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/source/Core/DataExtractor.cpp b/source/Core/DataExtractor.cpp
index 4119828..882cbf7 100644
--- a/source/Core/DataExtractor.cpp
+++ b/source/Core/DataExtractor.cpp
@@ -780,7 +780,7 @@ DataExtractor::GetFloat (uint32_t *offset_ptr) const
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
uint8_t *dst_data = (uint8_t *)&val;
- for (int i=0; i<sizeof(float_type); ++i)
+ for (size_t i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
@@ -806,7 +806,7 @@ DataExtractor::GetDouble (uint32_t *offset_ptr) const
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
uint8_t *dst_data = (uint8_t *)&val;
- for (int i=0; i<sizeof(float_type); ++i)
+ for (size_t i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
@@ -833,7 +833,7 @@ DataExtractor::GetLongDouble (uint32_t *offset_ptr) const
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
uint8_t *dst_data = (uint8_t *)&val;
- for (int i=0; i<sizeof(float_type); ++i)
+ for (size_t i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
@@ -1291,7 +1291,7 @@ DataExtractor::Dump
{
switch (ch)
{
- case '\e': s->Printf ("\\e", (uint8_t)ch); break;
+ case '\033': s->Printf ("\\e", (uint8_t)ch); break;
case '\a': s->Printf ("\\a", ch); break;
case '\b': s->Printf ("\\b", ch); break;
case '\f': s->Printf ("\\f", ch); break;
@@ -1351,7 +1351,7 @@ DataExtractor::Dump
{
switch (ch)
{
- case '\e': s->Printf ("\\e", (uint8_t)ch); break;
+ case '\033': s->Printf ("\\e", (uint8_t)ch); break;
case '\a': s->Printf ("\\a", ch); break;
case '\b': s->Printf ("\\b", ch); break;
case '\f': s->Printf ("\\f", ch); break;
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp
index b765bf7..e24647a 100644
--- a/source/Core/Opcode.cpp
+++ b/source/Core/Opcode.cpp
@@ -22,7 +22,7 @@ using namespace lldb_private;
int
Opcode::Dump (Stream *s, uint32_t min_byte_width)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
switch (m_type)
{
case Opcode::eTypeInvalid:
diff --git a/source/Core/UserSettingsController.cpp b/source/Core/UserSettingsController.cpp
index 60c2aa3..6fa7676 100644
--- a/source/Core/UserSettingsController.cpp
+++ b/source/Core/UserSettingsController.cpp
@@ -211,7 +211,7 @@ const SettingEntry *
UserSettingsController::GetGlobalEntry (const ConstString &var_name)
{
- for (int i = 0; i < m_settings.global_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.global_settings.size(); ++i)
{
const SettingEntry &entry = m_settings.global_settings[i];
ConstString entry_name (entry.var_name);
@@ -226,7 +226,7 @@ const SettingEntry *
UserSettingsController::GetInstanceEntry (const ConstString &const_var_name)
{
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
ConstString entry_name (entry.var_name);
@@ -500,7 +500,7 @@ UserSettingsController::SetVariable (const char *full_dot_name,
{
found = true;
std::string new_name;
- for (int j = 0; j < names.GetArgumentCount(); ++j)
+ for (size_t j = 0; j < names.GetArgumentCount(); ++j)
{
if (j > 0)
new_name += '.';
@@ -568,14 +568,14 @@ UserSettingsController::GetVariable
{
ConstString child_prefix (names.GetArgumentAtIndex (0));
bool found = false;
- for (int i = 0; i < m_children.size() && !found; ++i)
+ for (size_t i = 0; i < m_children.size() && !found; ++i)
{
if (child_prefix == m_children[i]->GetLevelName())
{
found = true;
child = m_children[i];
std::string new_name;
- for (int j = 0; j < names.GetArgumentCount(); ++j)
+ for (size_t j = 0; j < names.GetArgumentCount(); ++j)
{
if (j > 0)
new_name += '.';
@@ -727,7 +727,7 @@ UserSettingsController::CreateDefaultInstanceSettings ()
{
Error err;
const ConstString &default_name = InstanceSettings::GetDefaultName();
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
ConstString var_name (entry.var_name);
@@ -747,7 +747,7 @@ UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_se
bool pending)
{
Error err;
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
ConstString var_name (entry.var_name);
@@ -759,7 +759,7 @@ UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_se
value_str.append (value.GetStringAtIndex (0));
else if (value.GetSize() > 1)
{
- for (int j = 0; j < value.GetSize(); ++j)
+ for (size_t j = 0; j < value.GetSize(); ++j)
{
if (j > 0)
value_str.append (" ");
@@ -808,7 +808,7 @@ UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream)
BuildParentPrefix (parent_prefix);
const char *prefix = parent_prefix.c_str();
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
ConstString var_name (entry.var_name);
@@ -822,7 +822,7 @@ UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream)
value_string.Printf ("%s", tmp_value.GetStringAtIndex (0));
else
{
- for (int j = 0; j < tmp_value.GetSize(); ++j)
+ for (size_t j = 0; j < tmp_value.GetSize(); ++j)
{
if (entry.var_type == eSetVarTypeArray)
value_string.Printf ("\n [%d]: '%s'", j, tmp_value.GetStringAtIndex (j));
@@ -860,7 +860,7 @@ UserSettingsController::GetAllPendingSettingValues (Stream &result_stream)
const ConstString instance_name (tmp_name.c_str());
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
ConstString var_name (entry.var_name);
@@ -875,7 +875,7 @@ UserSettingsController::GetAllPendingSettingValues (Stream &result_stream)
value_str.Printf ("%s", tmp_value.GetStringAtIndex (0));
else
{
- for (int j = 0; j < tmp_value.GetSize(); ++j)
+ for (size_t j = 0; j < tmp_value.GetSize(); ++j)
value_str.Printf ("%s ", tmp_value.GetStringAtIndex (j));
}
@@ -926,7 +926,7 @@ UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interp
std::string instance_name = pos->first;
InstanceSettings *settings = pos->second;
- for (int i = 0; i < m_settings.instance_settings.size(); ++i)
+ for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
{
SettingEntry &entry = m_settings.instance_settings[i];
const ConstString var_name (entry.var_name);
@@ -940,7 +940,7 @@ UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interp
tmp_value_str.Printf ("%s", tmp_value.GetStringAtIndex (0));
else
{
- for (int j = 0; j < tmp_value.GetSize(); ++j)
+ for (size_t j = 0; j < tmp_value.GetSize(); ++j)
tmp_value_str.Printf ("%s ",tmp_value.GetStringAtIndex (j));
}
@@ -1042,7 +1042,7 @@ FindMaxNameLength (std::vector<SettingEntry> table)
{
int max_length = 1;
- for (int i = 0; i < table.size(); ++i)
+ for (size_t i = 0; i < table.size(); ++i)
{
int len = strlen (table[i].var_name);
if (len > max_length)
@@ -1382,11 +1382,11 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
Error &err)
{
StreamString description;
- int num_entries = root->m_settings.global_settings.size();
+ size_t num_entries = root->m_settings.global_settings.size();
SettableVariableType var_type;
- for (int i = 0; i < num_entries; ++i)
+ for (size_t i = 0; i < num_entries; ++i)
{
StreamString full_var_name;
const SettingEntry &entry = root->m_settings.global_settings[i];
@@ -1403,7 +1403,7 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
else
{
description.Printf ("%s (%s):\n", full_var_name.GetData(), GetTypeString (entry.var_type));
- for (int j = 0; j < value.GetSize(); ++j)
+ for (size_t j = 0; j < value.GetSize(); ++j)
if (entry.var_type == eSetVarTypeArray)
description.Printf (" [%d]: '%s'\n", j, value.GetStringAtIndex (j));
else if (entry.var_type == eSetVarTypeDictionary)
@@ -1581,7 +1581,7 @@ UserSettingsController::BooleanMatches (const char *partial_value,
}
else
{
- int partial_len = strlen (partial_value);
+ size_t partial_len = strlen (partial_value);
if ((partial_len <= true_string.length())
&& (true_string.find (partial_value) == 0))
@@ -1604,7 +1604,7 @@ UserSettingsController::EnumMatches (const char *partial_value,
bool &word_complete,
StringList &matches)
{
- int len = (partial_value != NULL) ? strlen (partial_value) : 0;
+ size_t len = (partial_value != NULL) ? strlen (partial_value) : 0;
int i = 0;
while (enum_values[i].string_value != NULL)
@@ -1783,7 +1783,7 @@ UserSettingsController::GlobalVariableMatches (const char *partial_name,
const std::string &complete_prefix,
StringList &matches)
{
- int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
+ size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
int num_matches = 0;
for (size_t i = 0; i < m_settings.global_settings.size(); ++i)
@@ -1814,7 +1814,7 @@ UserSettingsController::InstanceVariableMatches (const char *partial_name,
const char *instance_name,
StringList &matches)
{
- int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
+ size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
int num_matches = 0;
for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
@@ -1857,7 +1857,7 @@ UserSettingsController::LiveInstanceMatches (const char *partial_name,
bool &word_complete,
StringList &matches)
{
- int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
+ size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
int num_matches = 0;
std::map<std::string, InstanceSettings*>::iterator pos;
@@ -1890,7 +1890,7 @@ UserSettingsController::ChildMatches (const char *partial_name,
bool &word_complete,
StringList &matches)
{
- int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
+ size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
int num_children = GetNumChildren();
int num_matches = 0;
for (int i = 0; i < num_children; ++i)
@@ -2027,7 +2027,7 @@ UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op,
if (index_value != NULL)
{
- for (int i = 0; i < strlen(index_value); ++i)
+ for (size_t i = 0; i < strlen(index_value); ++i)
if (!isdigit (index_value[i]))
{
valid_index = false;
@@ -2066,7 +2066,7 @@ UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op,
Args new_array (new_value);
if (op == eVarSetOperationInsertAfter)
++index;
- for (int i = 0; i < new_array.GetArgumentCount(); ++i)
+ for (size_t i = 0; i < new_array.GetArgumentCount(); ++i)
array_var.InsertArgumentAtIndex (index, new_array.GetArgumentAtIndex (i));
}
break;
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 0054a03..6fb0bdb 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -166,7 +166,7 @@ ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
if (num_bytes > num_data_bytes)
num_bytes = num_data_bytes;
- for (off_t byte_idx = 0;
+ for (size_t byte_idx = 0;
byte_idx < num_bytes;
++byte_idx)
{
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 0d693ce..1509e43 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -248,7 +248,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
std::string triple = target->GetArchitecture().GetTriple().str();
int dash_count = 0;
- for (int i = 0; i < triple.size(); ++i)
+ for (size_t i = 0; i < triple.size(); ++i)
{
if (triple[i] == '-')
dash_count++;
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 4581712..a2a69bb 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -1587,7 +1587,7 @@ IRForTarget::UnfoldConstant(Constant *old_constant, Value *new_constant, Instruc
++ui)
users.push_back(*ui);
- for (int i = 0;
+ for (size_t i = 0;
i < users.size();
++i)
{
diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp
index d83b182..fc4f6ba 100644
--- a/source/Host/common/FileSpec.cpp
+++ b/source/Host/common/FileSpec.cpp
@@ -912,7 +912,7 @@ FileSpec::EnumerateDirectory
if (call_callback)
{
char child_path[PATH_MAX];
- const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
+ const size_t child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
if (child_path_len < sizeof(child_path) - 1)
{
// Don't resolve the file type or path
--
1.7.1
More information about the lldb-commits
mailing list