From 4c05911b7ef25505acacbb81053a56cf428e9edc Mon Sep 17 00:00:00 2001 From: Mukhiddin Yusupov Date: Wed, 21 May 2014 01:46:57 +0200 Subject: fdo#43157 - Clean up OSL_ASSERT, DBG_ASSERT Replaced OSL_ASSERT with SAL_WARN_IF, OSL_TRACE with SAL_INFO Change-Id: Ia2283c09ac702558fe6ad39e963b0f401ef31de0 Signed-off-by: Stephan Bergmann --- sal/osl/unx/profile.cxx | 377 +++++------------------------------------------ sal/osl/unx/security.cxx | 19 ++- 2 files changed, 46 insertions(+), 350 deletions(-) (limited to 'sal/osl') diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx index 15df5b5fba93..66846627b4bd 100644 --- a/sal/osl/unx/profile.cxx +++ b/sal/osl/unx/profile.cxx @@ -47,9 +47,6 @@ #define DEFAULT_PMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) -/*#define DEBUG_OSL_PROFILE*/ -/*#define TRACE_OSL_PROFILE*/ - typedef time_t osl_TStamp; typedef enum _osl_TLockMode @@ -153,41 +150,8 @@ static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, o osl_TProfileImpl* pProfile; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_openProfile"); -#endif - -#ifdef DEBUG_OSL_PROFILE - Flags=osl_Profile_FLUSHWRITE; - - OSL_TRACE("opening '%s'",pszProfileName); - if ( Flags == osl_Profile_DEFAULT ) - { - OSL_TRACE("with osl_Profile_DEFAULT"); - } - if ( Flags & osl_Profile_SYSTEM ) - { - OSL_TRACE("with osl_Profile_SYSTEM"); - } - if ( Flags & osl_Profile_READLOCK ) - { - OSL_TRACE("with osl_Profile_READLOCK"); - } - if ( Flags & osl_Profile_WRITELOCK ) - { - OSL_TRACE("with osl_Profile_WRITELOCK"); - } - if ( Flags & osl_Profile_FLUSHWRITE ) - { - OSL_TRACE("with osl_Profile_FLUSHWRITE"); - } -#endif - if ( ( pFile = openFileImpl(pszProfileName, Flags ) ) == NULL ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_openProfile [not opened]"); -#endif return (NULL); } @@ -212,14 +176,11 @@ static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, o pProfile->m_Stamp = OslProfile_getFileStamp(pFile); bRet=loadProfile(pFile, pProfile); bRet &= realpath(pszProfileName, pProfile->m_FileName) != NULL; - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "realpath(pszProfileName, pProfile->m_FileName) != NULL ==> false"); if (pProfile->m_pFile == NULL) closeFileImpl(pFile,pProfile->m_Flags); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_openProfile [ok]"); -#endif return (pProfile); } @@ -228,15 +189,8 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) osl_TProfileImpl* pProfile = (osl_TProfileImpl*)Profile; osl_TProfileImpl* pTmpProfile; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_closeProfile"); -#endif - if ( Profile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_closeProfile [profile==0]"); -#endif return sal_False; } @@ -244,11 +198,9 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) if ( pProfile->m_bIsValid == false ) { - OSL_ASSERT(pProfile->m_bIsValid); + SAL_WARN("sal.osl", "!pProfile->m_bIsValid"); pthread_mutex_unlock(&(pProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_closeProfile [not valid]"); -#endif + return sal_False; } @@ -261,7 +213,7 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) if ( pTmpProfile != 0 ) { bool bRet = storeProfile(pTmpProfile, true); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "storeProfile(pTmpProfile, true) ==> false"); (void)bRet; } } @@ -273,9 +225,8 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) if ( pTmpProfile == 0 ) { pthread_mutex_unlock(&(pProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_closeProfile [pProfile==0]"); -#endif + + SAL_INFO("sal.osl", "Out osl_closeProfile [pProfile==0]"); return sal_False; } @@ -326,9 +277,6 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile) free(pProfile); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_closeProfile [ok]"); -#endif return (sal_True); } @@ -338,15 +286,8 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) osl_TFile* pFile; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_flushProfile()"); -#endif - if ( pProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_flushProfile() [pProfile == 0]"); -#endif return sal_False; } @@ -354,11 +295,8 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) if ( pProfile->m_bIsValid == false ) { - OSL_ASSERT(pProfile->m_bIsValid); + SAL_WARN_IF(!pProfile->m_bIsValid, "sal.osl", "!pProfile->m_bIsValid"); pthread_mutex_unlock(&(pProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_flushProfile [not valid]"); -#endif return sal_False; } @@ -366,24 +304,16 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile) if ( !( pFile != 0 && pFile->m_Handle >= 0 ) ) { pthread_mutex_unlock(&(pProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_flushProfile() [invalid file]"); -#endif + return sal_False; } if ( pProfile->m_Flags & FLG_MODIFIED ) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("swapping to storeprofile"); -#endif bRet = storeProfile(pProfile, false); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "storeProfile(pProfile, false) ==> false"); } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_flushProfile() [ok]"); -#endif pthread_mutex_unlock(&(pProfile->m_AccessLock)); return bRet; } @@ -394,26 +324,19 @@ static bool writeProfileImpl(osl_TFile* pFile) unsigned int nLen=0; #endif -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_writeProfileImpl()"); -#endif - if ( !( pFile != 0 && pFile->m_Handle >= 0 ) || ( pFile->m_pWriteBuf == 0 ) ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileImpl() [invalid args]"); -#endif return false; } #if OSL_DEBUG_LEVEL > 1 nLen=strlen(pFile->m_pWriteBuf); - OSL_ASSERT(nLen == (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree)); + SAL_WARN_IF(nLen != (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree), "sal.osl", "nLen != (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree)"); #endif if ( !safeWrite(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree) ) { - OSL_TRACE("write failed '%s'",strerror(errno)); + SAL_INFO("sal.osl", "write failed " << strerror(errno)); return false; } @@ -421,9 +344,7 @@ static bool writeProfileImpl(osl_TFile* pFile) pFile->m_pWriteBuf=0; pFile->m_nWriteBufLen=0; pFile->m_nWriteBufFree=0; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileImpl() [ok]"); -#endif + return true; } @@ -441,17 +362,10 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, osl_TProfileImpl* pTmpProfile=0; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_readProfileString"); -#endif - pTmpProfile = (osl_TProfileImpl*) Profile; if ( pTmpProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileString [pTmpProfile==0]"); -#endif return sal_False; } @@ -460,9 +374,7 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, if ( pTmpProfile->m_bIsValid == false ) { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileString [not valid]"); -#endif + return sal_False; } @@ -471,9 +383,7 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, if ( pProfile == NULL ) { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileString [pProfile==0]"); -#endif + return (sal_False); } @@ -504,24 +414,18 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, { /* not implemented */ } bRet=releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); (void)bRet; if ( pStr == 0 ) { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileString [pStr==0]"); -#endif + return sal_False; } pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileString [ok]"); -#endif - return (sal_True); } @@ -533,10 +437,6 @@ sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile, sal_Char Line[32]; Line[0] = '\0'; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_readProfileBool"); -#endif - if (osl_readProfileString(Profile, pszSection, pszEntry, Line, sizeof(Line), "")) { if ((strcasecmp(Line, STR_INI_BOOLYES) == 0) || @@ -550,10 +450,6 @@ sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile, Default = sal_False; } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileBool [ok]"); -#endif - return (Default); } @@ -568,10 +464,6 @@ sal_uInt32 SAL_CALL osl_readProfileIdent(oslProfile Profile, sal_Char Line[256]; Line[0] = '\0'; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_readProfileIdent"); -#endif - if (osl_readProfileString(Profile, pszSection, pszEntry, Line, sizeof(Line), "")) { i = 0; @@ -586,9 +478,6 @@ sal_uInt32 SAL_CALL osl_readProfileIdent(oslProfile Profile, } } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_readProfileIdent [ok]"); -#endif return (Default); } @@ -606,17 +495,10 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, osl_TProfileImpl* pProfile = 0; osl_TProfileImpl* pTmpProfile = 0; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_writeProfileString"); -#endif - pTmpProfile = (osl_TProfileImpl*) Profile; if ( pTmpProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [pTmpProfile==0]"); -#endif return sal_False; } @@ -624,11 +506,9 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, if ( pTmpProfile->m_bIsValid == false ) { - OSL_ASSERT(pTmpProfile->m_bIsValid); + SAL_WARN_IF(!pTmpProfile->m_bIsValid, "sal.osl", "!pTmpProfile->m_bIsValid"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [not valid]"); -#endif + return sal_False; } @@ -637,9 +517,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, if (pProfile == NULL) { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [pProfile==0]"); -#endif + return (sal_False); } @@ -661,15 +539,11 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, (! addSection(pProfile, pProfile->m_NoLines - 1, &pStr[1], strlen(pszSection)))) { bRet=releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); free(Line); - -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [not added]"); -#endif return (sal_False); } @@ -693,14 +567,11 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, (! addEntry(pProfile, pSec, i, pStr, strlen(pszEntry)))) { bRet=releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); free(Line); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [not inserted]"); -#endif return (sal_False); } @@ -721,7 +592,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, } bRet = releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); if ( Line!= 0 ) @@ -729,10 +600,6 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, free(Line); } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileString [ok]"); -#endif - return bRet; } @@ -743,19 +610,11 @@ sal_Bool SAL_CALL osl_writeProfileBool(oslProfile Profile, { bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_writeProfileBool"); -#endif - if (Value) bRet=osl_writeProfileString(Profile, pszSection, pszEntry, STR_INI_BOOLONE); else bRet=osl_writeProfileString(Profile, pszSection, pszEntry, STR_INI_BOOLZERO); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileBool [ok]"); -#endif - return bRet; } @@ -769,10 +628,6 @@ sal_Bool SAL_CALL osl_writeProfileIdent(oslProfile Profile, int i, n = 0; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_writeProfileIdent"); -#endif - while (Strings[n] != NULL) ++n; @@ -781,9 +636,6 @@ sal_Bool SAL_CALL osl_writeProfileIdent(oslProfile Profile, else bRet = osl_writeProfileString(Profile, pszSection, pszEntry, Strings[i]); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_writeProfileIdent"); -#endif return bRet; } @@ -797,17 +649,10 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, osl_TProfileImpl* pTmpProfile = 0; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_removeProfileEntry"); -#endif - pTmpProfile = (osl_TProfileImpl*) Profile; if ( pTmpProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_removeProfileEntry [pProfile==0]"); -#endif return sal_False; } @@ -815,11 +660,8 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, if ( pTmpProfile->m_bIsValid == false ) { - OSL_ASSERT(pTmpProfile->m_bIsValid); + SAL_WARN_IF(!pTmpProfile->m_bIsValid, "sal.osl", "!pTmpProfile->m_bIsValid"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_removeProfileEntry [not valid]"); -#endif return sal_False; } @@ -828,9 +670,7 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, if (pProfile == NULL) { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_removeProfileEntry [pProfile==0]"); -#endif + return (sal_False); } @@ -859,13 +699,10 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, { /* not implemented */ } bRet = releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_removeProfileEntry [ok]"); -#endif return bRet; } @@ -881,17 +718,10 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, osl_TProfileImpl* pTmpProfile = 0; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_getProfileSectionEntries"); -#endif - pTmpProfile = (osl_TProfileImpl*) Profile; if ( pTmpProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSectionEntries [pTmpProfile==0]"); -#endif return sal_False; } @@ -900,14 +730,10 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, if ( pTmpProfile->m_bIsValid == false ) { - OSL_ASSERT(pTmpProfile->m_bIsValid); + SAL_WARN_IF(!pTmpProfile->m_bIsValid, "sal.osl", "!pTmpProfile->m_bIsValid"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSectionEntries [not valid]"); -#endif - return sal_False; } @@ -917,10 +743,6 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSectionEntries [pProfile=0]"); -#endif - return (0); } @@ -962,15 +784,11 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, } bRet=releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); (void)bRet; pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSectionEntries [ok]"); -#endif - return (n); } @@ -984,17 +802,10 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, osl_TProfileImpl* pTmpProfile = 0; bool bRet = false; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_getProfileSections"); -#endif - pTmpProfile = (osl_TProfileImpl*) Profile; if ( pTmpProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSections [pTmpProfile==0]"); -#endif return sal_False; } @@ -1002,11 +813,9 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, if ( pTmpProfile->m_bIsValid == false ) { - OSL_ASSERT(pTmpProfile->m_bIsValid); + SAL_WARN_IF(!pTmpProfile->m_bIsValid, "sal.osl", "!pTmpProfile->m_bIsValid"); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSections [not valid]"); -#endif + return sal_False; } @@ -1016,9 +825,6 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, { pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSections [pProfile==0]"); -#endif return (0); } @@ -1055,15 +861,11 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, { /* not implemented */ } bRet=releaseProfile(pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "releaseProfile(pProfile) ==> false"); (void)bRet; pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_getProfileSections [ok]"); -#endif - return (n); } @@ -1086,10 +888,6 @@ static bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode) static bool bIsInitialized = false; static bool bLockingDisabled; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In OslProfile_lockFile"); -#endif - if ( !bIsInitialized ) { sal_Char* pEnvValue; @@ -1110,17 +908,11 @@ static bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode) if (pFile->m_Handle < 0) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out OslProfile_lockFile [invalid file handle]"); -#endif return false; } if ( bLockingDisabled ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out OslProfile_lockFile [locking disabled]"); -#endif return true; } @@ -1150,16 +942,10 @@ static bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode) if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 && errno != ENOTSUP ) #endif { - OSL_TRACE("fcntl returned -1 (%s)",strerror(errno)); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out OslProfile_lockFile [fcntl F_SETLKW]"); -#endif + SAL_INFO("sal.osl", "fcntl returned -1 (" << strerror(errno) << ")"); return false; } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out OslProfile_lockFile [ok]"); -#endif return true; } @@ -1171,34 +957,21 @@ static osl_TFile* openFileImpl(const sal_Char* pszFilename, oslProfileOption Pro if ( ProfileFlags & ( osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE ) ) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("setting bWriteable to TRUE"); -#endif bWriteable = true; } if (! bWriteable) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("opening '%s' read only",pszFilename); -#endif - pFile->m_Handle = open(pszFilename, O_RDONLY); /* mfe: argghh!!! do not check if the file could be openend */ /* default mode expects it that way!!! */ } else { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("opening '%s' read/write",pszFilename); -#endif if (((pFile->m_Handle = open(pszFilename, O_RDWR | O_CREAT | O_EXCL, DEFAULT_PMODE)) < 0) && ((pFile->m_Handle = open(pszFilename, O_RDWR)) < 0)) { free(pFile); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out openFileImpl [open read/write]"); -#endif return (NULL); } } @@ -1219,15 +992,9 @@ static osl_TFile* openFileImpl(const sal_Char* pszFilename, oslProfileOption Pro if ( ProfileFlags & (osl_Profile_WRITELOCK | osl_Profile_READLOCK ) ) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("locking '%s' file",pszFilename); -#endif OslProfile_lockFile(pFile, bWriteable ? write_lock : read_lock); } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out openFileImpl [ok]"); -#endif return (pFile); } @@ -1235,15 +1002,8 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags) { osl_TStamp stamp = 0; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In closeFileImpl"); -#endif - if ( pFile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out closeFileImpl [pFile == 0]"); -#endif return stamp; } @@ -1267,42 +1027,26 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags) free(pFile); -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out closeFileImpl [ok]"); -#endif - return(stamp); } static bool OslProfile_rewindFile(osl_TFile* pFile, bool bTruncate) { bool bRet = true; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In osl_OslProfile_rewindFile"); -#endif if (pFile->m_Handle >= 0) { pFile->m_pReadPtr = pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf); -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("rewinding"); -#endif bRet = (lseek(pFile->m_Handle, SEEK_SET, 0L) == 0L); if (bTruncate) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("truncating"); -#endif bRet &= (ftruncate(pFile->m_Handle, 0L) == 0); } } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out osl_OslProfile_rewindFile [ok]"); -#endif return bRet; } @@ -1335,7 +1079,7 @@ static sal_Char* OslProfile_getLine(osl_TFile* pFile) if ((Max = read(pFile->m_Handle, &pFile->m_ReadBuf[Bytes], Free)) < 0) { - OSL_TRACE("read failed '%s'",strerror(errno)); + SAL_INFO("sal.osl", "read failed " << strerror(errno)); if( pLine ) rtl_freeMemory( pLine ); @@ -1398,10 +1142,6 @@ static bool OslProfile_putLine(osl_TFile* pFile, const sal_Char *pszLine) { unsigned int Len = strlen(pszLine); -#ifdef DEBUG_OSL_PROFILE - int strLen=0; -#endif - if ( pFile == 0 || pFile->m_Handle < 0 ) { return false; @@ -1432,9 +1172,6 @@ static bool OslProfile_putLine(osl_TFile* pFile, const sal_Char *pszLine) } memcpy(pFile->m_pWriteBuf + ( pFile->m_nWriteBufLen - pFile->m_nWriteBufFree ),pszLine,Len+1); -#ifdef DEBUG_OSL_PROFILE - strLen = strlen(pFile->m_pWriteBuf); -#endif pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len]='\n'; pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len + 1]='\0'; @@ -1838,7 +1575,7 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) { bWasAdded = addLine( pProfile, pLine ); rtl_freeMemory( pLine ); - OSL_ASSERT(bWasAdded); + SAL_WARN_IF(!bWasAdded, "sal.osl", "addLine( pProfile, pLine ) ==> false"); if ( ! bWasAdded ) return false; } @@ -1864,7 +1601,7 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) if (! addEntry(pProfile, &pProfile->m_Sections[pProfile->m_NoSections - 1], i, pStr, pChar - pStr)) { - OSL_ASSERT(false); + SAL_WARN("sal.osl", "Adding entry => false"); continue; } @@ -1875,7 +1612,7 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) if (! addSection(pProfile, i, pStr + 1, pChar - pStr - 1)) { - OSL_ASSERT(false); + SAL_WARN("sal.osl", "Adding section => false"); continue; } @@ -1887,10 +1624,6 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) static bool storeProfile(osl_TProfileImpl* pProfile, bool bCleanup) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In storeProfile"); -#endif - if (pProfile->m_Lines != NULL) { if (pProfile->m_Flags & FLG_MODIFIED) @@ -1922,9 +1655,6 @@ static bool storeProfile(osl_TProfileImpl* pProfile, bool bCleanup) pTmpFile->m_nWriteBufLen=0; pTmpFile->m_nWriteBufFree=0; -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out storeProfile [not flushed]"); -#endif closeFileImpl(pTmpFile,pProfile->m_Flags); return false; @@ -1961,9 +1691,6 @@ static bool storeProfile(osl_TProfileImpl* pProfile, bool bCleanup) } } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out storeProfile [ok]"); -#endif return true; } @@ -2075,10 +1802,6 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable) if (pProfile == NULL) { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("AUTOOPEN MODE"); -#endif - if ( ( pProfile = (osl_TProfileImpl*) osl_openProfile(0, PFlags ) ) != NULL ) { pProfile->m_Flags |= FLG_AUTOOPEN; @@ -2086,19 +1809,12 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable) } else { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("try to acquire"); -#endif - if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { if (! (pProfile->m_Flags & (osl_Profile_READLOCK | osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE ))) { osl_TStamp Stamp; -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("Profile acquire DEFAULT MODE"); -#endif if (! (pProfile->m_pFile = openFileImpl(pProfile->m_FileName, pProfile->m_Flags | PFlags ))) return NULL; @@ -2111,15 +1827,12 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable) pProfile->m_Stamp = Stamp; bRet=loadProfile(pProfile->m_pFile, pProfile); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "loadProfile(pProfile->m_pFile, pProfile) ==> false"); (void)bRet; } } else { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("Profile acquire READ/WRITELOCK MODE"); -#endif /* A readlock file could not be written */ if ((pProfile->m_Flags & osl_Profile_READLOCK) && bWriteable) { @@ -2134,36 +1847,23 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, bool bWriteable) static bool releaseProfile(osl_TProfileImpl* pProfile) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("In releaseProfile"); -#endif - if ( pProfile == 0 ) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out releaseProfile [profile==0]"); -#endif return false; } if (pProfile->m_Flags & FLG_AUTOOPEN) { -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out releaseProfile [AUTOOPEN]"); -#endif return (osl_closeProfile((oslProfile)pProfile)); } else { -#ifdef DEBUG_OSL_PROFILE - OSL_TRACE("DEFAULT MODE"); -#endif if (! (pProfile->m_Flags & (osl_Profile_READLOCK | osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE ))) { if (pProfile->m_Flags & FLG_MODIFIED) { bool bRet = storeProfile(pProfile, false); - OSL_ASSERT(bRet); + SAL_WARN_IF(!bRet, "sal.osl", "storeProfile(pProfile, false) ==> false"); (void)bRet; } @@ -2172,9 +1872,6 @@ static bool releaseProfile(osl_TProfileImpl* pProfile) } } -#ifdef TRACE_OSL_PROFILE - OSL_TRACE("Out releaseProfile [ok]"); -#endif return true; } diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx index 746685823226..c98b86564118 100644 --- a/sal/osl/unx/security.cxx +++ b/sal/osl/unx/security.cxx @@ -61,9 +61,8 @@ static bool sysconf_SC_GETPW_R_SIZE_MAX(std::size_t * value) { way and always set EINVAL, so be resilient here: */ return false; } else { - OSL_ASSERT( - m >= 0 - && (unsigned long) m < std::numeric_limits::max()); + SAL_WARN_IF( m < 0 || (unsigned long) m >= std::numeric_limits::max(), "sal.osl", + "m < 0 || (unsigned long) m >= std::numeric_limits::max()"); *value = (std::size_t) m; return true; } @@ -218,7 +217,7 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **ustrIdent bRet = osl_psz_getUserIdent(Security,pszIdent,sizeof(pszIdent)); rtl_string2UString( ustrIdent, pszIdent, rtl_str_getLength( pszIdent ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*ustrIdent != NULL); + SAL_WARN_IF(*ustrIdent == NULL, "sal.osl", "*ustrIdent == NULL"); return bRet; } @@ -252,7 +251,7 @@ sal_Bool SAL_CALL osl_getUserName(oslSecurity Security, rtl_uString **ustrName) bRet = osl_psz_getUserName(Security,pszName,sizeof(pszName)); rtl_string2UString( ustrName, pszName, rtl_str_getLength( pszName ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*ustrName != NULL); + SAL_WARN_IF(*ustrName == NULL, "sal.osl", "ustrName == NULL"); return bRet; } @@ -281,7 +280,7 @@ sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **pustrDirect if ( bRet ) { rtl_string2UString( pustrDirectory, pszDirectory, rtl_str_getLength( pszDirectory ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pustrDirectory != NULL); + SAL_WARN_IF(*pustrDirectory == NULL, "sal.osl", "*pustrDirectory == NULL"); osl_getFileURLFromSystemPath( *pustrDirectory, pustrDirectory ); } @@ -376,7 +375,7 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire if ( bRet ) { rtl_string2UString( pustrDirectory, pszDirectory, rtl_str_getLength( pszDirectory ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pustrDirectory != NULL); + SAL_WARN_IF(*pustrDirectory == NULL, "sal.osl", "*pustrDirectory == NULL"); osl_getFileURLFromSystemPath( *pustrDirectory, pustrDirectory ); } @@ -422,19 +421,19 @@ static bool SAL_CALL osl_psz_getConfigDir(oslSecurity Security, sal_Char* pszDir struct stat st; if (stat(pszDirectory, &st) != 0) { - OSL_TRACE("Could not stat $HOME/.config"); + SAL_INFO("sal.osl","Could not stat $HOME/.config"); dirOK = false; } else { if (!S_ISDIR(st.st_mode)) { - OSL_TRACE("$HOME/.config is not a directory"); + SAL_INFO("sal.osl", "$HOME/.config is not a directory"); dirOK = false; } if (!(st.st_mode & S_IRUSR && st.st_mode & S_IWUSR && st.st_mode & S_IXUSR)) { - OSL_TRACE("$HOME/.config has bad permissions"); + SAL_INFO("sal.osl", "$HOME/.config has bad permissions"); dirOK = false; } } -- cgit