This is an archive of the discontinued LLVM Phabricator instance.

suppress compiler warning (mostly -Wsign-compare)
AbandonedPublic

Authored by chilledheart on Nov 14 2014, 9:54 AM.

Details

Reviewers
emaste

Diff Detail

Event Timeline

chilledheart retitled this revision from to suppress compiler warning (mostly -Wsign-compare).
chilledheart updated this object.
chilledheart edited the test plan for this revision. (Show Details)
chilledheart added a reviewer: emaste.
chilledheart added a subscriber: Unknown Object (MLST).

One small comment but otherwise looks good to me, fwiw.

tools/debugserver/source/RNBRemote.cpp
2219

I think 'i' should be size_t to match buf_size, right? That's how you changed the decl in the for loop below.

It is a choice based on some reasons:

  1. i is going to negative here where the loop stops. So i must be signed

type.

  1. i should be large enough to hold a unsigned size_t. If type int is

sufficient in the previous case, type long is larger.
3.As I know, size_t is unsigned long under OS X.

Good point, thanks.

emaste edited edge metadata.Nov 20 2014, 4:42 PM

Looks fine to me.

What's next here? Did this get committed?

chilledheart added a comment.EditedFeb 4 2015, 8:42 AM

Hi emaste

Sorry for the late coming back. It is still not committed yet.

I am applying this patch against the latest lldb and double-checking it. It won't be long this time.

chilledheart edited edge metadata.

rebase to trunk

Although there are still some Wsign-compare warnings outside this patch, I think this diff is good enough for its own purpose.

I am fine with landing it if there is no further issue.

BTW Here are the warnings I faced on Linux:

/home/chilledheart/sources-llvm/llvm_lldb/tools/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp:749:35: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
                if (machine_regno == m_machine_fp_regnum)
                    ~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
/home/chilledheart/sources-llvm/llvm_lldb/tools/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp:845:53: warning: comparison of integers of different signs: 'int' and 'lldb::addr_t' (aka 'unsigned long') [-Wsign-compare]
            if (current_func_text_offset + insn_len < m_func_bounds.GetByteSize())
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

Those new warnings from UnwindAssembly-x86.cpp are my fault. I'll fix them later today.

chilledheart abandoned this revision.Mar 21 2015, 11:03 AM

I am abandoning this patch and it will be really helpful if someone can follow the latest code of lldb and fix Wsign-compare warnings.