Author: pfg Date: Tue Mar 7 02:13:26 2017 New Revision: 1785791 URL: http://svn.apache.org/viewvc?rev=1785791&view=rev Log: Revert r1719566 and bringing back some casts.
CERT C coding standard seem to have changed its mind. MEM02-A. Do not cast the return value from malloc(). has been superceeded by: MEM02-C. Immediately cast the result of a memory allocation function call into a pointer to the allocated type. Modified: openoffice/trunk/main/sal/osl/unx/profile.c Modified: openoffice/trunk/main/sal/osl/unx/profile.c URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/osl/unx/profile.c?rev=1785791&r1=1785790&r2=1785791&view=diff ============================================================================== --- openoffice/trunk/main/sal/osl/unx/profile.c (original) +++ openoffice/trunk/main/sal/osl/unx/profile.c Tue Mar 7 02:13:26 2017 @@ -237,7 +237,7 @@ static oslProfile SAL_CALL osl_psz_openP } - pProfile = calloc(1, sizeof(osl_TProfileImpl)); + pProfile = (osl_TProfileImpl*)calloc(1, sizeof(osl_TProfileImpl)); if ( pProfile == NULL ) { @@ -691,7 +691,7 @@ sal_Bool SAL_CALL osl_writeProfileString return (sal_False); } - Line = malloc(strlen(pszEntry)+strlen(pszString)+48); + Line = (sal_Char*)malloc(strlen(pszEntry)+strlen(pszString)+48); if (! (pProfile->m_Flags & osl_Profile_SYSTEM)) { @@ -1219,7 +1219,7 @@ static sal_Bool OslProfile_lockFile(cons static osl_TFile* openFileImpl(const sal_Char* pszFilename, oslProfileOption ProfileFlags ) { int Flags; - osl_TFile* pFile = calloc(1, sizeof(osl_TFile)); + osl_TFile* pFile = (osl_TFile*)calloc(1, sizeof(osl_TFile)); sal_Bool bWriteable = sal_False; if ( ProfileFlags & ( osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE ) ) @@ -1461,7 +1461,7 @@ static sal_Bool OslProfile_putLine(osl_T if ( pFile->m_pWriteBuf == NULL ) { - pFile->m_pWriteBuf = malloc(Len+3); + pFile->m_pWriteBuf = (sal_Char*)malloc(Len+3); pFile->m_nWriteBufLen = Len+3; pFile->m_nWriteBufFree = Len+3; } @@ -1471,7 +1471,7 @@ static sal_Bool OslProfile_putLine(osl_T { sal_Char* pTmp; - pTmp= realloc(pFile->m_pWriteBuf,( ( pFile->m_nWriteBufLen + Len ) * 2) ); + pTmp = (sal_Char*)realloc(pFile->m_pWriteBuf,( ( pFile->m_nWriteBufLen + Len ) * 2) ); if ( pTmp == NULL ) { return sal_False; @@ -1526,7 +1526,7 @@ static sal_Char* addLine(osl_TProfileImp if (pProfile->m_Lines == NULL) { pProfile->m_MaxLines = LINES_INI; - pProfile->m_Lines = calloc(pProfile->m_MaxLines, sizeof(sal_Char *)); + pProfile->m_Lines = (sal_Char **)calloc(pProfile->m_MaxLines, sizeof(sal_Char *)); } else { @@ -1534,7 +1534,7 @@ static sal_Char* addLine(osl_TProfileImp unsigned int oldmax=pProfile->m_MaxLines; pProfile->m_MaxLines += LINES_ADD; - pProfile->m_Lines = realloc(pProfile->m_Lines, + pProfile->m_Lines = (sal_Char **)realloc(pProfile->m_Lines, pProfile->m_MaxLines * sizeof(sal_Char *)); for ( idx = oldmax ; idx < pProfile->m_MaxLines ; ++idx ) { @@ -1567,12 +1567,12 @@ static sal_Char* insertLine(osl_TProfile if (pProfile->m_Lines == NULL) { pProfile->m_MaxLines = LINES_INI; - pProfile->m_Lines = calloc(pProfile->m_MaxLines, sizeof(sal_Char *)); + pProfile->m_Lines = (sal_Char **)calloc(pProfile->m_MaxLines, sizeof(sal_Char *)); } else { pProfile->m_MaxLines += LINES_ADD; - pProfile->m_Lines = realloc(pProfile->m_Lines, + pProfile->m_Lines = (sal_Char **)realloc(pProfile->m_Lines, pProfile->m_MaxLines * sizeof(sal_Char *)); memset(&pProfile->m_Lines[pProfile->m_NoLines], @@ -1684,13 +1684,13 @@ static sal_Bool addEntry(osl_TProfileImp if (pSection->m_Entries == NULL) { pSection->m_MaxEntries = ENTRIES_INI; - pSection->m_Entries = malloc( + pSection->m_Entries = (osl_TProfileEntry *)malloc( pSection->m_MaxEntries * sizeof(osl_TProfileEntry)); } else { pSection->m_MaxEntries += ENTRIES_ADD; - pSection->m_Entries = realloc(pSection->m_Entries, + pSection->m_Entries = (osl_TProfileEntry *)realloc(pSection->m_Entries, pSection->m_MaxEntries * sizeof(osl_TProfileEntry)); } @@ -1741,7 +1741,7 @@ static sal_Bool addSection(osl_TProfileI if (pProfile->m_Sections == NULL) { pProfile->m_MaxSections = SECTIONS_INI; - pProfile->m_Sections = calloc(pProfile->m_MaxSections, sizeof(osl_TProfileSection)); + pProfile->m_Sections = (osl_TProfileSection *)calloc(pProfile->m_MaxSections, sizeof(osl_TProfileSection)); } else { @@ -1749,7 +1749,7 @@ static sal_Bool addSection(osl_TProfileI unsigned int oldmax=pProfile->m_MaxSections; pProfile->m_MaxSections += SECTIONS_ADD; - pProfile->m_Sections = realloc(pProfile->m_Sections, + pProfile->m_Sections = (osl_TProfileSection *)realloc(pProfile->m_Sections, pProfile->m_MaxSections * sizeof(osl_TProfileSection)); for ( idx = oldmax ; idx < pProfile->m_MaxSections ; ++idx ) {