Skip to content

Commit

Permalink
Clean cpl_base64.cpp cpl_conv.cpp cpl_csv.cpp cpl_error.cpp.
Browse files Browse the repository at this point in the history
- Initialize vars
- Fix formatting
- Remove new lines from CPLError message

git-svn-id: https://svn.osgeo.org/gdal/trunk@36920 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
schwehr committed Dec 16, 2016
1 parent aa1d526 commit dbebe8e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions gdal/port/cpl_base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ char *CPLBase64Encode(int nDataLen, const GByte *pabyBytesToEncode)

const int kCharArray3Size = 3;
const int kCharArray4Size = 4;
unsigned char charArray3[kCharArray3Size];
unsigned char charArray3[kCharArray3Size] = {};

std::string result("");
int array3_idx = 0;
Expand Down Expand Up @@ -239,7 +239,7 @@ char *CPLBase64Encode(int nDataLen, const GByte *pabyBytesToEncode)
}

unsigned char charArray4[kCharArray4Size] = {};
charArray4[0] = (charArray3[0] & 0xfc) >> 2;
charArray4[0] = (charArray3[0] & 0xfc) >> 2;
charArray4[1] = ((charArray3[0] & 0x03) << 4)
+ ((charArray3[1] & 0xf0) >> 4);
charArray4[2] = ((charArray3[1] & 0x0f) << 2)
Expand Down
26 changes: 13 additions & 13 deletions gdal/port/cpl_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ const char *CPLReadLine2L( VSILFILE * fp, int nMaxCars,
/* -------------------------------------------------------------------- */
char *pszRLBuffer = NULL;
const size_t nChunkSize = 40;
char szChunk[nChunkSize];
char szChunk[nChunkSize] = {};
size_t nChunkBytesRead = 0;
int nBufLength = 0;
size_t nChunkBytesConsumed = 0;
Expand Down Expand Up @@ -827,7 +827,7 @@ char *CPLScanString( const char *pszString, int nMaxLength,
if( !pszBuffer )
return NULL;

strncpy( pszBuffer, pszString, nMaxLength );
strncpy( pszBuffer, pszString, nMaxLength );
pszBuffer[nMaxLength] = '\0';

if( bTrimSpaces )
Expand Down Expand Up @@ -1062,7 +1062,7 @@ GIntBig CPLAtoGIntBigEx( const char* pszString, int bWarn, int *pbOverflow )

void *CPLScanPointer( const char *pszString, int nMaxLength )
{
char szTemp[128];
char szTemp[128] = {};

/* -------------------------------------------------------------------- */
/* Compute string into local buffer, and terminate it. */
Expand Down Expand Up @@ -1186,7 +1186,7 @@ int CPLPrintString( char *pszDest, const char *pszSrc, int nMaxLen )
return 1;
}

int nChars = 0;
int nChars = 0;
char *pszTemp = pszDest;

while( nChars < nMaxLen && *pszSrc )
Expand Down Expand Up @@ -1271,7 +1271,7 @@ int CPLPrintInt32( char *pszBuffer, GInt32 iValue, int nMaxLen )
if( nMaxLen >= 64 )
nMaxLen = 63;

char szTemp[64];
char szTemp[64] = {};

#if UINT_MAX == 65535
snprintf( szTemp, sizeof(szTemp), "%*ld", nMaxLen, iValue );
Expand Down Expand Up @@ -1310,7 +1310,7 @@ int CPLPrintUIntBig( char *pszBuffer, GUIntBig iValue, int nMaxLen )
if( nMaxLen >= 64 )
nMaxLen = 63;

char szTemp[64];
char szTemp[64] = {};

#if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
/* x86_64-w64-mingw32-g++ (GCC) 4.8.2 annoyingly warns */
Expand Down Expand Up @@ -1360,7 +1360,7 @@ int CPLPrintPointer( char *pszBuffer, void *pValue, int nMaxLen )
if( nMaxLen >= 64 )
nMaxLen = 63;

char szTemp[64];
char szTemp[64] = {};

snprintf( szTemp, sizeof(szTemp), "%p", pValue );

Expand Down Expand Up @@ -1403,7 +1403,7 @@ int CPLPrintDouble( char *pszBuffer, const char *pszFormat,
return 0;

const int double_buffer_size = 64;
char szTemp[double_buffer_size];
char szTemp[double_buffer_size] = {};

CPLsnprintf( szTemp, double_buffer_size, pszFormat, dfValue );
szTemp[double_buffer_size - 1] = '\0';
Expand Down Expand Up @@ -1523,7 +1523,7 @@ void CPLVerifyConfiguration()
if( reinterpret_cast<GByte *>( &nTest )[3] != 1 )
#endif
CPLError( CE_Fatal, CPLE_AppDefined,
"CPLVerifyConfiguration(): byte order set wrong.\n" );
"CPLVerifyConfiguration(): byte order set wrong." );
}

#ifdef DEBUG_CONFIG_OPTIONS
Expand Down Expand Up @@ -1868,11 +1868,11 @@ double CPLDMSToDec( const char *is )
++is;

const char *p = is;
char work[64];
char work[64] = {};
char *s = work;
int n = sizeof(work);
for( ;
isgraph(*p) && --n ; )
isgraph(*p) && --n; )
*s++ = *p++;
*s = '\0';
// It is possible that a really odd input (like lots of leading
Expand Down Expand Up @@ -1969,7 +1969,7 @@ const char *CPLDecToDMS( double dfAngle, const char * pszAxis,
else
pszHemisphere = "N";

char szFormat[30];
char szFormat[30] = {};
CPLsnprintf( szFormat, sizeof(szFormat),
"%%3dd%%2d\'%%%d.%df\"%s",
nPrecision+3, nPrecision, pszHemisphere );
Expand Down Expand Up @@ -2845,7 +2845,7 @@ CPLErr CPLCreateFileInZip( void *, const char *,
return CE_Failure;
}

CPLErr CPLWriteFileInZip( void *, const void *, int )
CPLErr CPLWriteFileInZip( void *, const void *, int )

{
return CE_Failure;
Expand Down
6 changes: 3 additions & 3 deletions gdal/port/cpl_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ char **CSVReadParseLine2( FILE * fp, char chDelimiter )
if( fp == NULL )
return NULL;

const char *pszLine = CPLReadLine( fp );
const char *pszLine = CPLReadLine( fp );
if( pszLine == NULL )
return NULL;

Expand Down Expand Up @@ -673,7 +673,7 @@ char **CSVReadParseLine2L( VSILFILE * fp, char chDelimiter )
if( fp == NULL )
return NULL;

const char *pszLine = CPLReadLineL( fp );
const char *pszLine = CPLReadLineL( fp );
if( pszLine == NULL )
return NULL;

Expand Down Expand Up @@ -1415,7 +1415,7 @@ put into CSVDirName). <p>
static const char *CSVFileOverride( const char * pszInput )
{
static char szPath[1024];
static char szPath[1024] = {};
#ifdef WIN32
sprintf( szPath, "%s\\%s", CSVDirName, pszInput );
Expand Down
12 changes: 6 additions & 6 deletions gdal/port/cpl_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ static bool gbCatchDebug = true;

static const int DEFAULT_LAST_ERR_MSG_SIZE =
#if !defined(HAVE_VSNPRINTF)
20000
20000
#else
500
500
#endif
;
;

typedef struct errHandler
{
Expand Down Expand Up @@ -948,7 +948,7 @@ void CPL_STDCALL CPLLoggingErrorHandler( CPLErr eErrClass, CPLErrorNum nError,
* CPLTurnFailureIntoWarning() *
**********************************************************************/

/** Whether failures should be turned into warnings.
/** Whether failures should be turned into warnings.
*/
void CPLTurnFailureIntoWarning( int bOn )
{
Expand Down Expand Up @@ -1215,8 +1215,8 @@ void CPL_STDCALL _CPLAssert( const char * pszExpression, const char * pszFile,

{
CPLError( CE_Fatal, CPLE_AssertionFailed,
"Assertion `%s' failed\n"
"in file `%s', line %d\n",
"Assertion `%s' failed "
"in file `%s', line %d",
pszExpression, pszFile, iLine );

// Just to please compiler so it is aware the function does not return.
Expand Down

0 comments on commit dbebe8e

Please sign in to comment.