[Lldb-commits] [PATCH] D105788: [LLDB] Silence warnings from ScriptedProcessPythonInterface.cpp

Muhammad Omair Javaid via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Jul 11 20:51:08 PDT 2021


omjavaid created this revision.
omjavaid added a reviewer: mib.
Herald added a subscriber: kristof.beyls.
omjavaid requested review of this revision.

This patch fixes ScriptedProcessPythonInterface::GetGenericInteger to
avoid compiler warning emitted due to size_t being 32 bit when built
on 32 bit paltform.

      

Tested on 32 Bit Arm (armv8l).


https://reviews.llvm.org/D105788

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -130,17 +130,17 @@
 ScriptedProcessPythonInterface::GetGenericInteger(llvm::StringRef method_name) {
   Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
                  Locker::FreeLock);
-
+  size_t gen_int_val = std::numeric_limits<size_t>::max();
   if (!m_object_instance_sp)
-    return LLDB_INVALID_ADDRESS;
+    return gen_int_val;
 
   if (!m_object_instance_sp)
-    return LLDB_INVALID_ADDRESS;
+    return gen_int_val;
   PythonObject implementor(PyRefType::Borrowed,
                            (PyObject *)m_object_instance_sp->GetValue());
 
   if (!implementor.IsAllocated())
-    return LLDB_INVALID_ADDRESS;
+    return gen_int_val;
 
   PythonObject pmeth(
       PyRefType::Owned,
@@ -150,12 +150,12 @@
     PyErr_Clear();
 
   if (!pmeth.IsAllocated())
-    return LLDB_INVALID_ADDRESS;
+    return gen_int_val;
 
   if (PyCallable_Check(pmeth.get()) == 0) {
     if (PyErr_Occurred())
       PyErr_Clear();
-    return LLDB_INVALID_ADDRESS;
+    return gen_int_val;
   }
 
   if (PyErr_Occurred())
@@ -173,9 +173,9 @@
 
   if (py_return.get()) {
     auto size = py_return.AsUnsignedLongLong();
-    return (size) ? *size : LLDB_INVALID_ADDRESS;
+    return (size) ? *size : gen_int_val;
   }
-  return LLDB_INVALID_ADDRESS;
+  return gen_int_val;
 }
 
 lldb::MemoryRegionInfoSP
@@ -274,7 +274,7 @@
 lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
   size_t pid = GetGenericInteger("get_process_id");
 
-  return (pid >= std::numeric_limits<lldb::pid_t>::max())
+  return (pid >= std::numeric_limits<size_t>::max())
              ? LLDB_INVALID_PROCESS_ID
              : pid;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105788.357836.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210712/b7074390/attachment.bin>


More information about the lldb-commits mailing list