[lldb-dev] [Bug 52263] New: cli-wrapper-mpxtable.cpp - suspicious always true comparison

via lldb-dev lldb-dev at lists.llvm.org
Fri Oct 22 07:07:21 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52263

            Bug ID: 52263
           Summary: cli-wrapper-mpxtable.cpp - suspicious always true
                    comparison
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: llvm-dev at redking.me.uk
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

static void PrintBTEntry(lldb::addr_t lbound, lldb::addr_t ubound,
                         uint64_t value, uint64_t meta,
                         lldb::SBCommandReturnObject &result) {
  const lldb::addr_t one_cmpl64 = ~((lldb::addr_t)0);
  const lldb::addr_t one_cmpl32 = ~((uint32_t)0);

  if ((lbound == one_cmpl64 || one_cmpl32) && ubound == 0) {
    result.Printf("Null bounds on map: pointer value = 0x%" PRIu64 "\n",
value);
  } else {
    result.Printf("    lbound = 0x%" PRIu64 ",", lbound);
    result.Printf(" ubound = 0x%" PRIu64 , ubound);
    result.Printf(" (pointer value = 0x%" PRIu64 ",", value);
    result.Printf(" metadata = 0x%" PRIu64 ")\n", meta);
  }
}

Coverity is warning: 

  if ((lbound == one_cmpl64 || one_cmpl32) && ubound == 0) {

CID undefined (#1 of 1): Logical vs. bitwise operator
(CONSTANT_EXPRESSION_RESULT)logical_vs_bitwise: The expression lbound ==
18446744073709551615UL /* one_cmpl64 */ || true /* one_cmpl32 */ is suspicious
because it performs a Boolean operation on a constant other than 0 or 1.

Should this be:

  if ((lbound == one_cmpl64 || lbound == one_cmpl32) && ubound == 0) {

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20211022/39213c60/attachment.html>


More information about the lldb-dev mailing list