fixathon updated this revision to Diff 453348.
fixathon added a comment.

Change to C++ style comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131998/new/

https://reviews.llvm.org/D131998

Files:
  lldb/include/lldb/Core/ThreadSafeValue.h
  lldb/source/Host/common/ProcessRunLock.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/tools/lldb-vscode/FifoFiles.cpp

Index: lldb/tools/lldb-vscode/FifoFiles.cpp
===================================================================
--- lldb/tools/lldb-vscode/FifoFiles.cpp
+++ lldb/tools/lldb-vscode/FifoFiles.cpp
@@ -62,6 +62,13 @@
           line = buffer;
       }));
   if (future->wait_for(timeout) == std::future_status::timeout || !line)
+    // Indeed this is a leak, but it's intentional. "future" obj destructor
+    //  will block on waiting for the worker thread to join. And the worker
+    //  thread might be stuck in blocking I/O. Intentionally leaking the  obj
+    //  as a hack to avoid blocking main thread, and adding annotation to
+    //  supress static code inspection warnings
+
+    // coverity[leaked_storage]
     return createStringError(inconvertibleErrorCode(),
                              "Timed out trying to get messages from the " +
                                  m_other_endpoint_name);
@@ -79,6 +86,13 @@
         done = true;
       }));
   if (future->wait_for(timeout) == std::future_status::timeout || !done) {
+    // Indeed this is a leak, but it's intentional. "future" obj destructor will
+    // block on waiting for the worker thread to join. And the worker thread
+    // might be stuck in blocking I/O. Intentionally leaking the  obj as a hack
+    // to avoid blocking main thread, and adding annotation to supress static
+    // code inspection warnings"
+
+    // coverity[leaked_storage]
     return createStringError(inconvertibleErrorCode(),
                              "Timed out trying to send messages to the " +
                                  m_other_endpoint_name);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -304,7 +304,7 @@
     response.PutChar(';');
   }
 #endif // #if defined(__APPLE__)
-
+  // coverity[unsigned_compare]
   if (g_default_packet_timeout_sec > 0)
     response.Printf("default_packet_timeout:%u;", g_default_packet_timeout_sec);
 
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
@@ -126,6 +126,7 @@
 
 size_t RegisterInfoPOSIX_riscv64::GetRegisterSetFromRegisterIndex(
     uint32_t reg_index) const {
+  // coverity[unsigned_compare]
   if (reg_index >= gpr_first_riscv && reg_index <= gpr_last_riscv)
     return GPRegSet;
   if (reg_index >= fpr_first_riscv && reg_index <= fpr_last_riscv)
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===================================================================
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -105,6 +105,7 @@
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
   bool VectorSizeIsValid(uint32_t vq) {
+    // coverity[unsigned_compare]
     if (vq >= eVectorQuadwordAArch64 && vq <= eVectorQuadwordAArch64SVEMax)
       return true;
     return false;
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6345,6 +6345,7 @@
         // The segment name in a Mach-O LC_SEGMENT/LC_SEGMENT_64 is char[16] and
         // is not guaranteed to be nul-terminated if all 16 characters are
         // used.
+        // coverity[buffer_size_warning]
         strncpy(seg_vmaddr.segname, name.AsCString(),
                 sizeof(seg_vmaddr.segname));
         seg_vmaddr.vmaddr = vmaddr;
@@ -6740,6 +6741,7 @@
           // the right one, doesn't need to be nul terminated.
           // LC_NOTE name field is char[16] and is not guaranteed to be
           // nul-terminated.
+          // coverity[buffer_size_warning]
           strncpy(namebuf, lcnote->name.c_str(), sizeof(namebuf));
           buffer.PutRawBytes(namebuf, sizeof(namebuf));
           buffer.PutHex64(lcnote->payload_file_offset);
Index: lldb/source/Host/common/ProcessRunLock.cpp
===================================================================
--- lldb/source/Host/common/ProcessRunLock.cpp
+++ lldb/source/Host/common/ProcessRunLock.cpp
@@ -24,6 +24,7 @@
 bool ProcessRunLock::ReadTryLock() {
   ::pthread_rwlock_rdlock(&m_rwlock);
   if (!m_running) {
+    // coverity[missing_unlock]
     return true;
   }
   ::pthread_rwlock_unlock(&m_rwlock);
Index: lldb/include/lldb/Core/ThreadSafeValue.h
===================================================================
--- lldb/include/lldb/Core/ThreadSafeValue.h
+++ lldb/include/lldb/Core/ThreadSafeValue.h
@@ -42,6 +42,7 @@
 
   // Call this if you have already manually locked the mutex using the
   // GetMutex() accessor
+  // coverity[missing_lock]
   void SetValueNoLock(const T &value) { m_value = value; }
 
   std::recursive_mutex &GetMutex() { return m_mutex; }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to