Skip to content

Commit

Permalink
Reduce gnu complexity score of httpHeaderCpy function.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbartell committed May 11, 2021
1 parent d5a7cca commit 166cbe0
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,44 +1289,32 @@ static size_t httpHeaderCpy( char * pDest,

for( i = 0; i < len; i++ )
{
switch( pSrc[ i ] )
if( pSrc[ i ] == NULL_CHARACTER )
{
endOfInput = 1U;
}
else if( pSrc[ i ] == CARRIAGE_RETURN_CHARACTER )
{
LogError( ( "Invalid character '\r' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
}
else if( pSrc[ i ] == LINEFEED_CHARACTER )
{
LogError( ( "Invalid character '\n' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
}
else if( ( pSrc[ i ] == COLON_CHARACTER ) && ( isField == 1U ) )
{
LogError( ( "Invalid character ':' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
}
else
{
case NULL_CHARACTER:
endOfInput = 1U;
break;

case CARRIAGE_RETURN_CHARACTER:
LogError( ( "Invalid character '\r' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
break;

case LINEFEED_CHARACTER:
LogError( ( "Invalid character '\n' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
break;

case COLON_CHARACTER:

if( isField == 1U )
{
LogError( ( "Invalid character ':' found in %.*s",
( int ) len, pSrc ) );
hasError = 1U;
}
else
{
pDest[ i ] = pSrc[ i ];
charsWritten++;
}

break;

default:
pDest[ i ] = pSrc[ i ];
charsWritten++;
break;
pDest[ i ] = pSrc[ i ];
charsWritten++;
}

if( ( endOfInput == 1U ) || ( hasError == 1U ) )
Expand Down

0 comments on commit 166cbe0

Please sign in to comment.