Skip to content

Commit e8fd5be

Browse files
authored
Fix MISRA C 2012 20.12 deviations (#157)
* Use a local variable here to prevent macro replacement is subjected to macro itself.
1 parent 8401d38 commit e8fd5be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/core_json.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,15 @@ static void skipScalars( const char * buf,
10351035
size_t max,
10361036
char mode )
10371037
{
1038-
coreJSON_ASSERT( isOpenBracket_( mode ) );
1038+
bool modeIsOpenBracket = ( bool ) isOpenBracket_( mode );
1039+
1040+
/* assert function may be implemented in macro using a # or ## operator.
1041+
* Using a local variable here to prevent macro replacement is subjected
1042+
* to macro itself. */
1043+
coreJSON_ASSERT( modeIsOpenBracket != false );
1044+
1045+
/* Adding this line to avoid unused variable warning in release mode. */
1046+
( void ) modeIsOpenBracket;
10391047

10401048
skipSpace( buf, start, max );
10411049

0 commit comments

Comments
 (0)