[Lldb-commits] [PATCH] ObjectFileMachO: Silence signed/unsigned comparison warning
Greg Clayton
gclayton at apple.com
Wed Jul 23 11:31:13 PDT 2014
Looks fine.
> On Jul 22, 2014, at 4:17 PM, David Majnemer <david.majnemer at gmail.com> wrote:
>
> Hi tfiala, zturner,
>
> 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.
>
> http://reviews.llvm.org/D4634
>
> Files:
> source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
>
> Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> ===================================================================
> --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> @@ -5424,7 +5424,7 @@
> // Now write the file data for all memory segments in the process
> for (const auto &segment : segment_load_commands)
> {
> - if (segment.fileoff != core_file.SeekFromStart(segment.fileoff))
> + 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;
> <D4634.11796.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
More information about the lldb-commits
mailing list