Audit and fix up format strings
This commit is contained in:
committed by
Benjamin Barenblat
parent
4cd2da5202
commit
cd7050613c
@@ -38,7 +38,10 @@ void hexdump( const void *buf, size_t len, const char *name ) {
|
||||
const unsigned char *data = (const unsigned char *) buf;
|
||||
printf( DUMP_NAME_FMT, name );
|
||||
for ( size_t i = 0; i < len; i++ ) {
|
||||
printf( "%02x", data[ i ] );
|
||||
// Although data[i] is an unsigned char, it will be promoted to a signed int
|
||||
// when passed as an argument. Explicitly cast it back to an unsigned type
|
||||
// so it can be printed in hex.
|
||||
printf( "%02x", static_cast<unsigned>( data[ i ] ) );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user