[Lldb-commits] [lldb] r213822 - ObjectFileMachO: Silence signed/unsigned comparison warning

David Majnemer david.majnemer at gmail.com
Wed Jul 23 17:24:13 PDT 2014


Author: majnemer
Date: Wed Jul 23 19:24:12 2014
New Revision: 213822

URL: http://llvm.org/viewvc/llvm-project?rev=213822&view=rev
Log:
ObjectFileMachO: Silence signed/unsigned comparison warning

File::SeekFromStart returns an off_t representing the position of the
file after seeking.  This return value is always going to be one of two
values: the input or -1 in the case of failure.

ObjectFileMachO compares an expression of type off_t from the return of
File::SeekFromStart(segment.fileoff) and compares it for equality with
segment.fileoff.

The type of segment_command_64::fileoff is unsigned while off_t is
signed, comparing them emits a diagnostic under GCC.

Instead, we can just compare SeekFromSTart with -1 to see if we
successfully seeked.

Differential Revision: http://reviews.llvm.org/D4634

Modified:
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

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=213822&r1=213821&r2=213822&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Jul 23 19:24:12 2014
@@ -5426,8 +5426,7 @@ ObjectFileMachO::SaveCore (const lldb::P
                             // Now write the file data for all memory segments in the process
                             for (const auto &segment : segment_load_commands)
                             {
-                                off_t offset = core_file.SeekFromStart(segment.fileoff);
-                                if (offset < 0 || segment.fileoff != static_cast<uint64_t>(offset))
+                                if (core_file.SeekFromStart(segment.fileoff) == -1)
                                 {
                                     error.SetErrorStringWithFormat("unable to seek to offset 0x%" PRIx64 " in '%s'", segment.fileoff, core_file_path.c_str());
                                     break;





More information about the lldb-commits mailing list