[Lldb-commits] [lldb] r281191 - Fix about a dozen compile warnings
Ilia K via lldb-commits
lldb-commits at lists.llvm.org
Sun Sep 11 22:25:33 PDT 2016
Author: ki.stfu
Date: Mon Sep 12 00:25:33 2016
New Revision: 281191
URL: http://llvm.org/viewvc/llvm-project?rev=281191&view=rev
Log:
Fix about a dozen compile warnings
Summary:
It fixes the following compile warnings:
1. '0' flag ignored with precision and ‘%d’ gnu_printf format
2. enumeral and non-enumeral type in conditional expression
3. format ‘%d’ expects argument of type ‘int’, but argument 4 has type ...
4. enumeration value ‘...’ not handled in switch
5. cast from type ‘const uint64_t* {aka ...}’ to type ‘int64_t* {aka ...}’ casts away qualifiers
6. extra ‘;’
7. comparison between signed and unsigned integer expressions
8. variable ‘register_operand’ set but not used
9. control reaches end of non-void function
Reviewers: jingham, emaste, zturner, clayborg
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D24331
Modified:
lldb/trunk/source/Core/Log.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/trunk/source/Target/StackFrame.cpp
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Mon Sep 12 00:25:33 2016
@@ -82,7 +82,7 @@ void Log::VAPrintf(const char *format, v
// Timestamp if requested
if (m_options.Test(LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) {
TimeValue now = TimeValue::Now();
- header.Printf("%9d.%09.9d ", now.seconds(), now.nanoseconds());
+ header.Printf("%9d.%9.9d ", now.seconds(), now.nanoseconds());
}
// Add the process and thread if requested
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Mon Sep 12 00:25:33 2016
@@ -1938,9 +1938,9 @@ void ObjectFileELF::CreateSections(Secti
sect_type = eSectionTypeGoSymtab;
const uint32_t permissions =
- ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0) |
- ((header.sh_flags & SHF_WRITE) ? ePermissionsWritable : 0) |
- ((header.sh_flags & SHF_EXECINSTR) ? ePermissionsExecutable : 0);
+ ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0u) |
+ ((header.sh_flags & SHF_WRITE) ? ePermissionsWritable : 0u) |
+ ((header.sh_flags & SHF_EXECINSTR) ? ePermissionsExecutable : 0u);
switch (header.sh_type) {
case SHT_SYMTAB:
assert(sect_type == eSectionTypeOther);
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Sep 12 00:25:33 2016
@@ -1458,13 +1458,13 @@ void ObjectFileMachO::CreateSections(Sec
}
}
if (m_data.GetU32(&offset, &load_cmd.maxprot, 4)) {
- const uint32_t segment_permissions =
- ((load_cmd.initprot & VM_PROT_READ) ? ePermissionsReadable
- : 0) |
- ((load_cmd.initprot & VM_PROT_WRITE) ? ePermissionsWritable
- : 0) |
- ((load_cmd.initprot & VM_PROT_EXECUTE) ? ePermissionsExecutable
- : 0);
+ uint32_t segment_permissions = 0;
+ if (load_cmd.initprot & VM_PROT_READ)
+ segment_permissions |= ePermissionsReadable;
+ if (load_cmd.initprot & VM_PROT_WRITE)
+ segment_permissions |= ePermissionsWritable;
+ if (load_cmd.initprot & VM_PROT_EXECUTE)
+ segment_permissions |= ePermissionsExecutable;
const bool segment_is_encrypted =
(load_cmd.flags & SG_PROTECTED_VERSION_1) != 0;
@@ -2621,8 +2621,7 @@ size_t ObjectFileMachO::ParseSymtab() {
"/System/Library/Caches/com.apple.dyld/", /* IPHONE_DYLD_SHARED_CACHE_DIR
*/
"dyld_shared_cache_", /* DYLD_SHARED_CACHE_BASE_NAME */
- header_arch.GetArchitectureName(),
- ".development");
+ header_arch.GetArchitectureName(), ".development");
FileSpec dsc_nondevelopment_filespec(dsc_path, false);
FileSpec dsc_development_filespec(dsc_path_development, false);
Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Mon Sep 12 00:25:33 2016
@@ -139,9 +139,9 @@ lldb::addr_t ProcessElfCore::AddAddressR
// Keep a separate map of permissions that that isn't coalesced so all ranges
// are maintained.
const uint32_t permissions =
- ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0) |
- ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0) |
- ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0);
+ ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0u) |
+ ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0u) |
+ ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0u);
m_core_range_infos.Append(
VMRangeToPermissions::Entry(addr, header->p_memsz, permissions));
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Sep 12 00:25:33 2016
@@ -3653,7 +3653,7 @@ Error GDBRemoteCommunicationClient::Conf
error.SetErrorStringWithFormat("configuring StructuredData feature %s "
"failed when sending packet: "
"PacketResult=%d",
- type_name.AsCString(), result);
+ type_name.AsCString(), (int)result);
}
return error;
}
Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Mon Sep 12 00:25:33 2016
@@ -138,6 +138,8 @@ ArchSpec MinidumpParser::GetArchitecture
case MinidumpCPUArchitecture::ARM64:
arch_spec.GetTriple().setArch(llvm::Triple::ArchType::aarch64);
break;
+ default:
+ break;
}
return arch_spec;
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp Mon Sep 12 00:25:33 2016
@@ -518,7 +518,7 @@ int64_t PythonInteger::GetInteger() cons
// 0xffffffffffffffff. If we use the unsigned long long
// it will work as expected.
const uint64_t uval = PyLong_AsUnsignedLongLong(m_py_obj);
- result = *((int64_t *)&uval);
+ result = static_cast<int64_t>(uval);
}
return result;
}
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=281191&r1=281190&r2=281191&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 12 00:25:33 2016
@@ -1278,6 +1278,8 @@ GetBaseExplainingValue(const Instruction
return std::make_pair(nullptr, 0);
}
}
+ default:
+ return std::make_pair(nullptr, 0);
}
}
@@ -1291,7 +1293,7 @@ GetBaseExplainingDereference(const Instr
}
return std::make_pair(nullptr, 0);
}
-};
+}
lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
TargetSP target_sp = CalculateTarget();
@@ -1420,7 +1422,7 @@ ValueObjectSP GetValueForDereferincingOf
Error error;
ValueObjectSP pointee = base->Dereference(error);
- if (offset >= pointee->GetByteSize()) {
+ if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
int64_t index = offset / pointee->GetByteSize();
offset = offset % pointee->GetByteSize();
const bool can_create = true;
@@ -1586,17 +1588,16 @@ lldb::ValueObjectSP DoGuessValueAt(Stack
continue;
}
- Instruction::Operand *register_operand = nullptr;
Instruction::Operand *origin_operand = nullptr;
if (operands[0].m_type == Instruction::Operand::Type::Register &&
operands[0].m_clobbered == true && operands[0].m_register == reg) {
- register_operand = &operands[0];
+ // operands[0] is a register operand
origin_operand = &operands[1];
} else if (operands[1].m_type == Instruction::Operand::Type::Register &&
operands[1].m_clobbered == true &&
operands[1].m_register == reg) {
- register_operand = &operands[1];
origin_operand = &operands[0];
+ // operands[1] is a register operand
} else {
continue;
}
More information about the lldb-commits
mailing list