[Lldb-commits] [lldb] r181911 - Fixed a few obvious errors pointed out by the static analyzer.

Jim Ingham jingham at apple.com
Wed May 15 11:27:08 PDT 2013


Author: jingham
Date: Wed May 15 13:27:08 2013
New Revision: 181911

URL: http://llvm.org/viewvc/llvm-project?rev=181911&view=rev
Log:
Fixed a few obvious errors pointed out by the static analyzer.

Modified:
    lldb/trunk/source/API/SBCommunication.cpp
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/Core/DataExtractor.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/DataFormatters/Cocoa.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/ClangExpressionParser.cpp
    lldb/trunk/source/Expression/IRMemoryMap.cpp
    lldb/trunk/source/Host/common/FileSpec.cpp
    lldb/trunk/source/Host/common/Host.cpp

Modified: lldb/trunk/source/API/SBCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommunication.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommunication.cpp (original)
+++ lldb/trunk/source/API/SBCommunication.cpp Wed May 15 13:27:08 2013
@@ -188,7 +188,6 @@ SBCommunication::ReadThreadStart ()
     if (m_opaque)
         success = m_opaque->StartReadThread ();
 
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
         log->Printf ("SBCommunication(%p)::ReadThreadStart () => %i", m_opaque, success);
 

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Wed May 15 13:27:08 2013
@@ -678,7 +678,7 @@ SBFrame::GetValueForVariablePath (const
     
     ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    StackFrame *frame = exe_ctx.GetFramePtr();
+    StackFrame *frame = NULL;
     Target *target = exe_ctx.GetTargetPtr();
     Process *process = exe_ctx.GetProcessPtr();
     if (target && process)

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Wed May 15 13:27:08 2013
@@ -1132,6 +1132,9 @@ uint64_t
 DataExtractor::GetULEB128 (offset_t *offset_ptr) const
 {
     const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+    
     const uint8_t *end = m_end;
     
     if (src < end)
@@ -1169,6 +1172,9 @@ int64_t
 DataExtractor::GetSLEB128 (offset_t *offset_ptr) const
 {
     const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+    
     const uint8_t *end = m_end;
     
     if (src < end)
@@ -1213,6 +1219,9 @@ DataExtractor::Skip_LEB128 (offset_t *of
 {
     uint32_t bytes_consumed = 0;
     const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+        
     const uint8_t *end = m_end;
     
     if (src < end)

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed May 15 13:27:08 2013
@@ -1174,7 +1174,8 @@ ScanFormatDescriptor (const char* var_na
                     *val_obj_display = ValueObject::eValueObjectRepresentationStyleType;
                     break;
                 default:
-                    log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name.c_str());
+                    if (log)
+                        log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name.c_str());
                     break;
             }
         }

Modified: lldb/trunk/source/DataFormatters/Cocoa.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/Cocoa.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/Cocoa.cpp (original)
+++ lldb/trunk/source/DataFormatters/Cocoa.cpp Wed May 15 13:27:08 2013
@@ -57,7 +57,7 @@ lldb_private::formatters::NSBundleSummar
         uint64_t offset = 5 * ptr_size;
         ClangASTType type(valobj.GetClangAST(),ClangASTContext::GetBuiltInType_objc_id(valobj.GetClangAST()));
         ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, type, true));
-        valobj_addr = text->GetValueAsUnsigned(0);
+
         StreamString summary_stream;
         bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream);
         if (was_nsstring_ok && summary_stream.GetSize() > 0)

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed May 15 13:27:08 2013
@@ -1365,7 +1365,7 @@ ClangExpressionDeclMap::FindExternalVisi
                 }
             }
             
-            if (!context.m_found.variable && !namespace_decl)
+            if (target && !context.m_found.variable && !namespace_decl)
             {
                 // We couldn't find a non-symbol variable for this.  Now we'll hunt for a generic 
                 // data symbol, and -- if it is found -- treat it as a variable.

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed May 15 13:27:08 2013
@@ -550,7 +550,7 @@ ClangExpressionParser::PrepareForExecuti
         
         if (execution_policy == eExecutionPolicyAlways || !can_interpret)
         {
-            if (!process->GetDynamicCheckers() && m_expr.NeedsValidation())
+            if (m_expr.NeedsValidation() && (process && (!process->GetDynamicCheckers())))
             {                
                 DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
                 

Modified: lldb/trunk/source/Expression/IRMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRMemoryMap.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp (original)
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp Wed May 15 13:27:08 2013
@@ -70,7 +70,7 @@ IRMemoryMap::FindSpace (size_t size)
     
     for (int iterations = 0; iterations < 16; ++iterations)
     {
-        lldb::addr_t candidate;
+        lldb::addr_t candidate = LLDB_INVALID_ADDRESS;
         
         switch (target_sp->GetArchitecture().GetAddressByteSize())
         {

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Wed May 15 13:27:08 2013
@@ -980,6 +980,8 @@ FileSpec::EnumerateDirectory
                             {
                                 // The subdirectory returned Quit, which means to 
                                 // stop all directory enumerations at all levels.
+                                if (buf)
+                                    free (buf);
                                 return eEnumerateDirectoryResultQuit;
                             }
                             break;

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=181911&r1=181910&r2=181911&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Wed May 15 13:27:08 2013
@@ -696,6 +696,8 @@ Host::SetThreadName (lldb::pid_t pid, ll
         }
     }
     return false;
+#else
+    return false;
 #endif
 }
 





More information about the lldb-commits mailing list