Fix some printf warnings with size_t values

This commit is contained in:
Tim Wojtulewicz 2020-08-11 13:42:03 -07:00
parent c6e7d14757
commit f1ed66d52c
4 changed files with 8 additions and 7 deletions

View file

@ -83,7 +83,7 @@ static void choose_global_symbols_regex(const string& regex, vector<zeek::detail
zeek::detail::debug_msg("There were multiple matches, please choose:\n");
for ( size_t i = 0; i < choices.size(); i++ )
zeek::detail::debug_msg("[%lu] %s\n", i+1, choices[i]->Name());
zeek::detail::debug_msg("[%zu] %s\n", i+1, choices[i]->Name());
zeek::detail::debug_msg("[a] All of the above\n");
zeek::detail::debug_msg("[n] None of the above\n");

View file

@ -446,7 +446,7 @@ void Dictionary::DumpKeys() const
DistanceStats(max_distance);
if ( binary )
{
sprintf(key_file, "%d.%d.%lu-%c.key", Length(), max_distance, MemoryAllocation()/Length(), rand()%26 + 'A');
sprintf(key_file, "%d.%d.%zu-%c.key", Length(), max_distance, MemoryAllocation()/Length(), rand()%26 + 'A');
std::ofstream f(key_file, std::ios::binary|std::ios::out|std::ios::trunc);
for ( int idx = 0; idx < Capacity(); idx++ )
if ( ! table[idx].Empty() )
@ -458,7 +458,7 @@ void Dictionary::DumpKeys() const
}
else
{
sprintf(key_file, "%d.%d.%lu-%d.ckey",Length(), max_distance, MemoryAllocation()/Length(), rand()%26 + 'A');
sprintf(key_file, "%d.%d.%zu-%d.ckey",Length(), max_distance, MemoryAllocation()/Length(), rand()%26 + 'A');
std::ofstream f(key_file, std::ios::out|std::ios::trunc);
for ( int idx = 0; idx < Capacity(); idx++ )
if ( ! table[idx].Empty() )
@ -506,7 +506,7 @@ void Dictionary::Dump(int level) const
int distances[DICT_NUM_DISTANCES];
int max_distance = 0;
DistanceStats(max_distance, distances, DICT_NUM_DISTANCES);
printf("cap %'7d ent %'7d %'-7d load %.2f max_dist %2d mem %10zu mem/ent %3lu key/ent %3d lg %2d remaps %1d remap_end %4d ",
printf("cap %'7d ent %'7d %'-7d load %.2f max_dist %2d mem %10zu mem/ent %3zu key/ent %3d lg %2d remaps %1d remap_end %4d ",
Capacity(), Length(), MaxLength(), (double)Length()/(table? Capacity() : 1),
max_distance, MemoryAllocation(), (MemoryAllocation())/(Length()?Length():1), key_size / (Length()?Length():1),
log2_buckets, remaps, remap_end);

View file

@ -1198,7 +1198,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
{
auto expected_name = zeek::type_name(expected_type->Tag());
zeek::reporter->Warning("failed to convert remote event '%s' arg #%lu,"
zeek::reporter->Warning("failed to convert remote event '%s' arg #%zu,"
" got %s, expected %s",
name.data(), i, got_type,
expected_name);
@ -1268,7 +1268,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
fields[i] = field;
else
{
zeek::reporter->Warning("failed to convert remote log field # %lu", i);
zeek::reporter->Warning("failed to convert remote log field # %zu", i);
delete [] fields;
return false;
}

View file

@ -1148,7 +1148,8 @@ void init_random_seed(const char* read_file, const char* write_file,
#endif
if ( pos < zeek::detail::KeyedHash::SEED_INIT_SIZE )
zeek::reporter->FatalError("Could not read enough random data. Wanted %d, got %lu", zeek::detail::KeyedHash::SEED_INIT_SIZE, pos);
zeek::reporter->FatalError("Could not read enough random data. Wanted %d, got %zu",
zeek::detail::KeyedHash::SEED_INIT_SIZE, pos);
if ( ! seed )
{