diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-03-06 14:31:10 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-03-06 14:31:23 +0100 |
commit | ebb4ac785f9d5278bc22405c0a3dc1c419af690d (patch) | |
tree | 99a649c39ded0b4bbcddf4be906c526ff3e9549f /sal/osl | |
parent | f52dbb2d1de1135f6ef4adeb9703989d03d9775f (diff) |
coverity#1190347 check rename(3) return value
Change-Id: Iebd3b0e1b52a01e14e01c6db1ca158ada91e8613
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/unx/profile.cxx | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx index 2ee461e95410..952e5e22ad92 100644 --- a/sal/osl/unx/profile.cxx +++ b/sal/osl/unx/profile.cxx @@ -130,7 +130,7 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile); static sal_Bool writeProfileImpl (osl_TFile* pFile); static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl*); -static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl*); +static bool osl_ProfileSwapProfileNames(osl_TProfileImpl*); static void osl_ProfileGenerateExtension(const sal_Char* pszFileName, const sal_Char* pszExtension, sal_Char* pszTmpName, int BufferMaxLen); static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, oslProfileOption Flags); @@ -2014,10 +2014,8 @@ static osl_TFile* osl_openTmpProfileImpl(osl_TProfileImpl* pProfile) return pFile; } -static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) +static bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) { - sal_Bool bRet = sal_False; - sal_Char pszBakFile[PATH_MAX]; sal_Char pszTmpFile[PATH_MAX]; @@ -2030,13 +2028,9 @@ static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) /* unlink bak */ unlink( pszBakFile ); - /* rename ini bak */ - rename( pProfile->m_FileName, pszBakFile ); - - /* rename tmp ini */ - rename( pszTmpFile, pProfile->m_FileName ); - - return bRet; + // Rename ini -> bak, then tmp -> ini: + return rename( pProfile->m_FileName, pszBakFile ) == 0 + && rename( pszTmpFile, pProfile->m_FileName ) == 0; } static void osl_ProfileGenerateExtension(const sal_Char* pszFileName, const sal_Char* pszExtension, sal_Char* pszTmpName, int BufferMaxLen) |