@@ -58,6 +58,7 @@ static void _HexDump(const char* p, size_t data_len)
5858 char line [80 ]; /* Buffer for a line of hex output */
5959 size_t linePos = 0 ;
6060 size_t off = 0 ;
61+ const char hex [] = "0123456789ABCDEF" ;
6162
6263 WH_TEST_DEBUG_PRINT (" HD:%p for %lu bytes\n" , p , data_len );
6364 if ((p == NULL ) || (data_len == 0 ))
@@ -66,21 +67,30 @@ static void _HexDump(const char* p, size_t data_len)
6667 for (off = 0 ; off < data_len ; off ++ ) {
6768 if ((off % bytesPerLine ) == 0 ) {
6869 linePos = 0 ;
69- linePos += snprintf (line + linePos , sizeof (line ) - linePos , " " );
70+ line [linePos ++ ] = ' ' ;
71+ line [linePos ++ ] = ' ' ;
72+ line [linePos ++ ] = ' ' ;
73+ line [linePos ++ ] = ' ' ;
7074 }
7175 if (u [off ] < two_digits ) {
72- linePos += snprintf (line + linePos , sizeof (line ) - linePos , "0%X " , u [off ]);
76+ line [linePos ++ ] = '0' ;
77+ line [linePos ++ ] = hex [u [off ]];
78+ line [linePos ++ ] = ' ' ;
7379 }
7480 else {
75- linePos += snprintf (line + linePos , sizeof (line ) - linePos , "%X " , u [off ]);
81+ line [linePos ++ ] = hex [u [off ] >> 4 ];
82+ line [linePos ++ ] = hex [u [off ] & 0x0F ];
83+ line [linePos ++ ] = ' ' ;
7684 }
7785 if ((off % bytesPerLine ) == (bytesPerLine - 1 )) {
78- linePos += snprintf (line + linePos , sizeof (line ) - linePos , "\n" );
86+ line [linePos ++ ] = '\n' ;
87+ line [linePos ] = '\0' ;
7988 WOLFHSM_CFG_PRINTF ("%s" , line );
8089 }
8190 }
8291 if ((off % bytesPerLine ) != 0 ) {
83- linePos += snprintf (line + linePos , sizeof (line ) - linePos , "\n" );
92+ line [linePos ++ ] = '\n' ;
93+ line [linePos ] = '\0' ;
8494 WOLFHSM_CFG_PRINTF ("%s" , line );
8595 }
8696}
0 commit comments