diff options
author | Jim Ingham <jingham@apple.com> | 2012-12-15 02:40:54 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2012-12-15 02:40:54 +0000 |
commit | 17fafa155cc4e6e8170c149ee20ef5ac685ee918 (patch) | |
tree | e5586c8d436909e2b6072e203e481f9eb56a74ae /lldb | |
parent | 2e1f745da77279d3e06822ffa3484ad325810874 (diff) | |
download | bcm5719-llvm-17fafa155cc4e6e8170c149ee20ef5ac685ee918.tar.gz bcm5719-llvm-17fafa155cc4e6e8170c149ee20ef5ac685ee918.zip |
Remove the “len” defaulted parameter from CommandReturnObject::AppendMessage, AppendWarning and AppendError. Nobody was using them, and it meant if you accidentally used the AppendWarning when you meant AppendWarningWithFormat with an integer in the format string, it would compile and then return your string plus some unknown amount of junk.
llvm-svn: 170266
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandReturnObject.h | 6 | ||||
-rw-r--r-- | lldb/source/API/SBCommandReturnObject.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandReturnObject.cpp | 25 |
4 files changed, 26 insertions, 23 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index ce062d38845..737ef525a92 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -118,7 +118,7 @@ public: Clear(); void - AppendMessage (const char *in_string, int len = -1); + AppendMessage (const char *in_string); void AppendMessageWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); @@ -127,13 +127,13 @@ public: AppendRawWarning (const char *in_string, int len = -1); void - AppendWarning (const char *in_string, int len = -1); + AppendWarning (const char *in_string); void AppendWarningWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void - AppendError (const char *in_string, int len = -1); + AppendError (const char *in_string); void AppendRawError (const char *in_string, int len = -1); diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 4d0ffc75fe3..4714829c592 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -281,7 +281,17 @@ SBCommandReturnObject::PutCString(const char* string, int len) { if (m_opaque_ap.get()) { - m_opaque_ap->AppendMessage(string, len); + if (len == 0) + { + return; + } + else if (len > 0) + { + std::string buffer(string, len); + m_opaque_ap->AppendMessage(buffer.c_str()); + } + else + m_opaque_ap->AppendMessage(string); } } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index d154e28819f..391cbc42cd1 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -876,7 +876,7 @@ protected: comp_unit->GetDirectory().GetCString(), comp_unit->GetFilename().GetCString()); else - result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex()); + result.AppendErrorWithFormat ("no debug information for frame %u\n", frame->GetFrameIndex()); } else result.AppendError ("'target variable' takes one or more global variable names as arguments\n"); @@ -3152,13 +3152,13 @@ protected: } else { - result.AppendError ("Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr); + result.AppendErrorWithFormat ("Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr); result.SetStatus (eReturnStatusFailed); } } else { - result.AppendError ("Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr); + result.AppendErrorWithFormat ("Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr); result.SetStatus (eReturnStatusFailed); } } diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp index 896ad2b7e84..c7ab8a988d7 100644 --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -104,24 +104,19 @@ CommandReturnObject::AppendWarningWithFormat (const char *format, ...) } void -CommandReturnObject::AppendMessage (const char *in_string, int len) +CommandReturnObject::AppendMessage (const char *in_string) { - if (!in_string || len == 0) + if (!in_string || *in_string == '\0') return; - if (len < 0) - GetOutputStream().Printf("%s\n", in_string); - else - GetOutputStream().Printf("%*.*s\n", len, len, in_string); + GetOutputStream().Printf("%s\n", in_string); } void -CommandReturnObject::AppendWarning (const char *in_string, int len) +CommandReturnObject::AppendWarning (const char *in_string) { - if (!in_string) + if (!in_string || *in_string == '\0') return; - if (len < 0) - len = ::strlen (in_string); - GetErrorStream().Printf("warning: %*.*s\n", len, len, in_string); + GetErrorStream().Printf("warning: %s\n", in_string); } // Similar to AppendWarning, but do not prepend 'warning: ' to message, and @@ -138,13 +133,11 @@ CommandReturnObject::AppendRawWarning (const char *in_string, int len) } void -CommandReturnObject::AppendError (const char *in_string, int len) +CommandReturnObject::AppendError (const char *in_string) { - if (!in_string) + if (!in_string || *in_string == '\0') return; - if (len < 0) - len = ::strlen (in_string); - GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string); + GetErrorStream().Printf ("error: %s\n", in_string); } void |