This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-server] Fix fill_clamp to handle signed src types
ClosedPublic

Authored by mgorny on Nov 9 2021, 2:59 PM.

Details

Summary

Fix the fill_clamp() function to handle signed source types. Make sure
that the source value is always non-negative, and cast it to unsigned
when verifying the upper bound. This fixes compiler warnings about
comparing unsigned and signed types.

Diff Detail

Event Timeline

mgorny requested review of this revision.Nov 9 2021, 2:59 PM
mgorny created this revision.
labath accepted this revision.Nov 9 2021, 11:43 PM
labath added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
776

T will always be unsigned here, right? May not hurt to add a static_assert for that, mainly to avoid people wondering if this logic is correct...

This revision is now accepted and ready to land.Nov 9 2021, 11:43 PM
mgorny marked an inline comment as done.Nov 9 2021, 11:53 PM
mgorny added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
776

Yes, and that makes the logic much simpler. I'll add the assert. Thanks!

This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 12:39 AM