summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-10-09 12:15:06 +0300
committerTor Lillqvist <tml@collabora.com>2013-10-09 13:46:43 +0300
commitfe8ef98e2c1611a72bd2840cd08dc101f25b1cd3 (patch)
tree3a6167da4b41965710fffa43d5fe17699dd040c6 /sal
parent45ffc53a905aa4b4890d862a070a2d6e9bce8546 (diff)
Use assertions to ensure proper use of the osl command line arg API
Stephan says: I don't buy that argument of making things less fragile; IMO it's that "defensive programming" approach gone wrong, where you add complexity to mitigate a problem's effects in one place, instead of fixing the problem itself in the real place. [...] The better robustification is probably to turn the OSL_TRACE in osl_getCommandArgCount (sal/osl/unx/process_impl.cxx) into something stronger like SAL_WARN, assert, or std::abort Change-Id: I3ba6684b4921eb67c2f4534e29e33056e8a891b3
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/process_impl.cxx8
1 files changed, 2 insertions, 6 deletions
diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index bd1e5a2f9726..00766ccf4304 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -176,11 +176,7 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount (void)
sal_uInt32 result = 0;
pthread_mutex_lock (&(g_command_args.m_mutex));
- if (g_command_args.m_nCount == 0) {
- OSL_TRACE(
- OSL_LOG_PREFIX
- "osl_getCommandArgCount w/o prior call to osl_setCommandArgs");
- }
+ assert (g_command_args.m_nCount != 0);
if (g_command_args.m_nCount > 0)
result = g_command_args.m_nCount - 1;
pthread_mutex_unlock (&(g_command_args.m_mutex));
@@ -214,7 +210,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
{
OSL_ASSERT(argc > 0);
pthread_mutex_lock (&(g_command_args.m_mutex));
- OSL_ENSURE (g_command_args.m_nCount == 0, "osl_setCommandArgs(): CommandArgs already set.");
+ assert (g_command_args.m_nCount == 0);
if (g_command_args.m_nCount == 0)
{
rtl_uString** ppArgs = (rtl_uString**)rtl_allocateZeroMemory (argc * sizeof(rtl_uString*));