Skip to content

Commit

Permalink
Fix old %llu printf with PRIu64 format
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Nov 10, 2024
1 parent 6cd6a95 commit 8a11e1a
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 83 deletions.
7 changes: 4 additions & 3 deletions src/collector/expire.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023, Peter Haag
* Copyright (c) 2009-2024, Peter Haag
* Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
* All rights reserved.
*
Expand Down Expand Up @@ -32,6 +32,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -604,7 +605,7 @@ void ExpireProfile(channel_t *channel, dirstat_t *current_stat, uint64_t maxsize

if (!size_done) {
// expire size-wise if needed
dbg_printf(" Size expire %llu %llu\n", current_stat->filesize, sizelimit);
dbg_printf(" Size expire %" PRIu64 " %" PRIu64 "\n", current_stat->filesize, sizelimit);
if (current_stat->filesize > sizelimit) {
// need to delete this file
if (unlink(expire_channel->ftsent->fts_path) == 0) {
Expand Down Expand Up @@ -712,7 +713,7 @@ void ExpireProfile(channel_t *channel, dirstat_t *current_stat, uint64_t maxsize
if (expire_channel->dirstat->numfiles) {
// if channel is empty, no files must be reported, but rebuild is done anyway
LogError("Inconsistency detected in channel %s. Will rebuild automatically.\n", expire_channel->datadir);
LogError("No more files found, but %llu expected.\n", expire_channel->dirstat->numfiles);
LogError("No more files found, but %" PRIu64 " expected.\n", expire_channel->dirstat->numfiles);
}
expire_channel->dirstat->numfiles = 0;
expire_channel->dirstat->status = FORCE_REBUILD;
Expand Down
2 changes: 1 addition & 1 deletion src/libnfdump/filter/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ uint32_t NewElement(uint32_t extID, uint32_t offset, uint32_t length, uint64_t v
exit(255);
}
}
dbg_printf("New element: extID: %u, offset: %u, length: %u, value: %llu\n", extID, offset, length, value);
dbg_printf("New element: extID: %u, offset: %u, length: %u, value: %" PRIu64 "\n", extID, offset, length, value);

FilterTree[n] = (filterElement_t){
.extID = extID,
Expand Down
5 changes: 3 additions & 2 deletions src/libnffile/nfxV3.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Haag
* Copyright (c) 2024, Peter Haag
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -32,6 +32,7 @@

#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -419,7 +420,7 @@ int SequencerRun(sequencer_t *sequencer, const void *inBuff, size_t inSize, void
#endif
if (stackID && stack) {
stack[stackID] = valBuff[0];
dbg_printf("Stack value %llu in slot %u\n", (long long unsigned)valBuff[0], stackID);
dbg_printf("Stack value %" PRIu64 " in slot %u\n", valBuff[0], stackID);
}

switch (outLength) {
Expand Down
34 changes: 18 additions & 16 deletions src/netflow/ipfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static exporterDomain_t *getExporter(FlowSource_t *fs, uint32_t ObservationDomai
static void InsertSampler(FlowSource_t *fs, exporterDomain_t *exporter, sampler_record_t *sampler_record) {
sampler_t *sampler;

dbg_printf("[%u] Insert Sampler: Exporter is 0x%llu\n", exporter->info.id, (long long unsigned)exporter);
dbg_printf("[%u] Insert Sampler: Exporter is 0x%p\n", exporter->info.id, (void *)exporter);
if (!exporter->sampler) {
// no samplers so far
sampler = (sampler_t *)malloc(sizeof(sampler_t));
Expand Down Expand Up @@ -1169,7 +1169,7 @@ static void Process_ipfix_option_templates(exporterDomain_t *exporter, void *opt
}
optionTemplate->optionSize = offset;

dbg_printf("\n[%u] Option size: %llu, flags: %llx\n", exporter->info.id, optionTemplate->optionSize, optionTemplate->flags);
dbg_printf("\n[%u] Option size: %" PRIu64 ", flags: %llx\n", exporter->info.id, optionTemplate->optionSize, optionTemplate->flags);
if (optionTemplate->flags) {
// if it exitsts - remove old template on exporter with same ID
templateList_t *template = newTemplate(exporter, tableID);
Expand Down Expand Up @@ -1289,8 +1289,8 @@ static void Process_ipfix_data(exporterDomain_t *exporter, uint32_t ExportTime,
// map file record to output buffer
outBuff = GetCurrentCursor(fs->dataBlock);

dbg_printf("[%u] Process data record: %u addr: %llu, size_left: %u buff_avail: %u\n", exporter->info.id, processed_records,
(long long unsigned)((ptrdiff_t)inBuff - (ptrdiff_t)data_flowset), size_left, buffAvail);
dbg_printf("[%u] Process data record: %u addr: %p, size_left: %u buff_avail: %u\n", exporter->info.id, processed_records,
(void *)((ptrdiff_t)inBuff - (ptrdiff_t)data_flowset), size_left, buffAvail);

// process record
AddV3Header(outBuff, recordHeaderV3);
Expand Down Expand Up @@ -1400,27 +1400,29 @@ static void Process_ipfix_data(exporterDomain_t *exporter, uint32_t ExportTime,
packetInterval = overwriteSampler->record.packetInterval;
spaceInterval = overwriteSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Overwrite sampling - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval, spaceInterval);
dbg_printf("[%u] Overwrite sampling - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, packetInterval,
spaceInterval);
} else if (sampler) {
// individual assigned sampler ID
packetInterval = sampler->record.packetInterval;
spaceInterval = sampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found assigned sampler ID %u - packet interval: %llu, packet space: %llu\n", exporter->info.id, sampler_id,
dbg_printf("[%u] Found assigned sampler ID %u - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, sampler_id,
packetInterval, spaceInterval);
} else if (genericSampler) {
// global sampler ID
packetInterval = genericSampler->record.packetInterval;
spaceInterval = genericSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found generic sampler - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval, spaceInterval);
dbg_printf("[%u] Found generic sampler - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, packetInterval,
spaceInterval);
} else if (defaultSampler) {
// static default sampler
packetInterval = defaultSampler->record.packetInterval;
spaceInterval = defaultSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found static default sampler - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval,
spaceInterval);
dbg_printf("[%u] Found static default sampler - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id,
packetInterval, spaceInterval);
}
intervalTotal = packetInterval + spaceInterval;

Expand Down Expand Up @@ -1448,10 +1450,10 @@ static void Process_ipfix_data(exporterDomain_t *exporter, uint32_t ExportTime,

if (genericFlow->msecFirst < fs->msecFirst) fs->msecFirst = genericFlow->msecFirst;
if (genericFlow->msecLast > fs->msecLast) fs->msecLast = genericFlow->msecLast;
dbg_printf("msecFrist: %llu\n", genericFlow->msecFirst);
dbg_printf("msecLast : %llu\n", genericFlow->msecLast);
dbg_printf("packets : %llu\n", (long long unsigned)genericFlow->inPackets);
dbg_printf("bytes : %llu\n", (long long unsigned)genericFlow->inBytes);
dbg_printf("msecFrist: %" PRIu64 "\n", genericFlow->msecFirst);
dbg_printf("msecLast : %" PRIu64 "\n", genericFlow->msecLast);
dbg_printf("packets : %" PRIu64 "\n", genericFlow->inPackets);
dbg_printf("bytes : %" PRIu64 "\n", genericFlow->inBytes);

if (spaceInterval > 0) {
genericFlow->inPackets = genericFlow->inPackets * intervalTotal / (uint64_t)packetInterval;
Expand Down Expand Up @@ -1875,7 +1877,7 @@ static void Process_ipfix_SysUpTime_option_data(exporterDomain_t *exporter, temp
uint8_t *in = (uint8_t *)(data_flowset + 4); // skip flowset header
if (CHECK_OPTION_DATA(size_left, optionTemplate->SysUpOption)) {
exporter->SysUpTime = Get_val(in, optionTemplate->SysUpOption.offset, optionTemplate->SysUpOption.length);
dbg_printf("Extracted SysUpTime : %llu\n", exporter->SysUpTime);
dbg_printf("Extracted SysUpTime : %" PRIu64 "\n", exporter->SysUpTime);
} else {
LogError("Process_ipfix_option: %s line %d: Not enough data for option data", __FILE__, __LINE__);
return;
Expand Down Expand Up @@ -1944,8 +1946,8 @@ void Process_IPFIX(void *in_buff, ssize_t in_buff_cnt, FlowSource_t *fs) {
flowset_header = (void *)ipfix_header + IPFIX_HEADER_LENGTH;
size_left -= IPFIX_HEADER_LENGTH;

dbg_printf("\n[%u] process packet: %u, export time: %s, TemplateRecords: %llu, DataRecords: %llu, buffer: %li \n", ObservationDomain, pkg_num++,
UNIX2ISO(ExportTime), (long long unsigned)exporter->TemplateRecords, (long long unsigned)exporter->DataRecords, size_left);
dbg_printf("\n[%u] process packet: %u, export time: %s, TemplateRecords: %" PRIu64 ", DataRecords: %" PRIu64 ", buffer: %zd \n",
ObservationDomain, pkg_num++, UNIX2ISO(ExportTime), exporter->TemplateRecords, exporter->DataRecords, size_left);
dbg_printf("[%u] Sequence: %u\n", ObservationDomain, Sequence);

// sequence check
Expand Down
33 changes: 18 additions & 15 deletions src/netflow/netflow_v9.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -454,7 +455,7 @@ static inline exporterDomain_t *getExporter(FlowSource_t *fs, uint32_t exporter_
static void InsertSampler(FlowSource_t *fs, exporterDomain_t *exporter, sampler_record_t *sampler_record) {
sampler_t *sampler;

dbg_printf("[%u] Insert Sampler: Exporter is 0x%llu\n", exporter->info.id, (long long unsigned)exporter);
dbg_printf("[%u] Insert Sampler: Exporter is 0x%p\n", exporter->info.id, (void *)exporter);
if (!exporter->sampler) {
// no samplers so far
sampler = (sampler_t *)malloc(sizeof(sampler_t));
Expand Down Expand Up @@ -921,7 +922,7 @@ static inline void Process_v9_option_templates(exporterDomain_t *exporter, void
}
optionTemplate->optionSize = offset;

dbg_printf("\n[%u] Option size: %llu, flags: %llx\n", exporter->info.id, optionTemplate->optionSize, optionTemplate->flags);
dbg_printf("\n[%u] Option size: %" PRIu64 ", flags: %llx\n", exporter->info.id, optionTemplate->optionSize, optionTemplate->flags);
if (optionTemplate->flags) {
// if it exitsts - remove old template on exporter with same ID
templateList_t *template = newTemplate(exporter, tableID);
Expand Down Expand Up @@ -1034,8 +1035,8 @@ static inline void Process_v9_data(exporterDomain_t *exporter, void *data_flowse
// map file record to output buffer
outBuff = GetCurrentCursor(fs->dataBlock);

dbg_printf("[%u] Process data record: %u addr: %llu, size_left: %u buff_avail: %u\n", exporter->info.id, processed_records,
(long long unsigned)((ptrdiff_t)inBuff - (ptrdiff_t)data_flowset), size_left, buffAvail);
dbg_printf("[%u] Process data record: %u addr: %p, size_left: %u buff_avail: %u\n", exporter->info.id, processed_records,
(void *)((ptrdiff_t)inBuff - (ptrdiff_t)data_flowset), size_left, buffAvail);

// process record
AddV3Header(outBuff, recordHeaderV3);
Expand Down Expand Up @@ -1143,27 +1144,29 @@ static inline void Process_v9_data(exporterDomain_t *exporter, void *data_flowse
packetInterval = overwriteSampler->record.packetInterval;
spaceInterval = overwriteSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Overwrite sampling - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval, spaceInterval);
dbg_printf("[%u] Overwrite sampling - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, packetInterval,
spaceInterval);
} else if (sampler) {
// individual assigned sampler ID
packetInterval = sampler->record.packetInterval;
spaceInterval = sampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found assigned sampler ID %u - packet interval: %llu, packet space: %llu\n", exporter->info.id, sampler_id,
dbg_printf("[%u] Found assigned sampler ID %u - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, sampler_id,
packetInterval, spaceInterval);
} else if (genericSampler) {
// global sampler ID
packetInterval = genericSampler->record.packetInterval;
spaceInterval = genericSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found generic sampler - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval, spaceInterval);
dbg_printf("[%u] Found generic sampler - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id, packetInterval,
spaceInterval);
} else if (defaultSampler) {
// static default sampler
packetInterval = defaultSampler->record.packetInterval;
spaceInterval = defaultSampler->record.spaceInterval;
SetFlag(recordHeaderV3->flags, V3_FLAG_SAMPLED);
dbg_printf("[%u] Found static default sampler - packet interval: %llu, packet space: %llu\n", exporter->info.id, packetInterval,
spaceInterval);
dbg_printf("[%u] Found static default sampler - packet interval: %" PRIu64 ", packet space: %" PRIu64 "\n", exporter->info.id,
packetInterval, spaceInterval);
}
intervalTotal = packetInterval + spaceInterval;

Expand All @@ -1190,10 +1193,10 @@ static inline void Process_v9_data(exporterDomain_t *exporter, void *data_flowse

if (genericFlow->msecFirst < fs->msecFirst) fs->msecFirst = genericFlow->msecFirst;
if (genericFlow->msecLast > fs->msecLast) fs->msecLast = genericFlow->msecLast;
dbg_printf("msecFrist: %llu\n", (long long unsigned)genericFlow->msecFirst);
dbg_printf("msecLast : %llu\n", (long long unsigned)genericFlow->msecLast);
dbg_printf("packets : %llu\n", (long long unsigned)genericFlow->inPackets);
dbg_printf("bytes : %llu\n", (long long unsigned)genericFlow->inBytes);
dbg_printf("msecFrist: %" PRIu64 "\n", genericFlow->msecFirst);
dbg_printf("msecLast : %" PRIu64 "\n", genericFlow->msecLast);
dbg_printf("packets : %" PRIu64 "\n", genericFlow->inPackets);
dbg_printf("bytes : %" PRIu64 "\n", genericFlow->inBytes);

if (spaceInterval > 0) {
genericFlow->inPackets = genericFlow->inPackets * intervalTotal / (uint64_t)packetInterval;
Expand Down Expand Up @@ -1635,7 +1638,7 @@ static void Process_v9_SysUpTime_option_data(exporterDomain_t *exporter, templat
uint8_t *in = (uint8_t *)(data_flowset + 4); // skip flowset header
if (CHECK_OPTION_DATA(size_left, optionTemplate->SysUpOption)) {
exporter->SysUpTime = Get_val(in, optionTemplate->SysUpOption.offset, optionTemplate->SysUpOption.length);
dbg_printf("Extracted SysUpTime : %llu\n", exporter->SysUpTime);
dbg_printf("Extracted SysUpTime : %" PRIu64 "\n", exporter->SysUpTime);
} else {
LogError("Process_v9_option: %s line %d: Not enough data for option data", __FILE__, __LINE__);
return;
Expand Down Expand Up @@ -1733,7 +1736,7 @@ void Process_v9(void *in_buff, ssize_t in_buff_cnt, FlowSource_t *fs) {
(long long)exporter->sequence, (long long)distance);
}
}
dbg_printf("Sequence: %llu\n", exporter->sequence);
dbg_printf("Sequence: %" PRIu64 "\n", exporter->sequence);

processed_records = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/netflow/nfd_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void Process_nfd(void *in_buff, ssize_t in_buff_cnt, FlowSource_t *fs) {

uint16_t count = ntohl(pcapd_header->numRecord);
uint32_t numRecords = 0;
dbg_printf("Process nfd packet: %llu, size: %zd, recordCnt: %u\n", exporter->packets, in_buff_cnt, count);
dbg_printf("Process nfd packet: %" PRIu64 ", size: %zd, recordCnt: %u\n", exporter->packets, in_buff_cnt, count);

if ((sizeof(nfd_header_t) + sizeof(recordHeaderV3_t)) > size_left) {
LogError("Process_nfd: Not enough data.");
Expand Down
6 changes: 3 additions & 3 deletions src/nfdump/compat_1_6_x/nfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int Insert_Extension_Map(extension_map_list_t *extension_map_list, extension_map
// is this slot free
if (extension_map_list->slot[map_id]) {
int i;
dbg_printf("Extension info in slot %d already exists: 0x%llu\n", map_id, (long long unsigned)extension_map_list->slot[map_id]);
dbg_printf("Extension info in slot %d already exists: 0x%p\n", map_id, (void *)extension_map_list->slot[map_id]);
// no - check if same map already in slot
if (extension_map_list->slot[map_id]->map->size == map->size) {
// existing map and new map have the same size
Expand Down Expand Up @@ -225,7 +225,7 @@ int Insert_Extension_Map(extension_map_list_t *extension_map_list, extension_map
if (l->map->size == map->size && (l->map->extension_size == map->extension_size)) {
while ((l->map->ex_id[i] || map->ex_id[i]) && (l->map->ex_id[i] == map->ex_id[i])) i++;
if (l->map->ex_id[i] == 0) {
dbg_printf("Map found: 0x%llu ID: %u\n", (long long unsigned)l, l->map->map_id);
dbg_printf("Map found: 0x%p ID: %u\n", l, l->map->map_id);
break;
}
}
Expand Down Expand Up @@ -257,7 +257,7 @@ int Insert_Extension_Map(extension_map_list_t *extension_map_list, extension_map
}

// l is now our valid extension
dbg_printf("Insert extension into slot %i: 0x%llu\n\n", map_id, (long long unsigned)l);
dbg_printf("Insert extension into slot %i: 0x%p\n\n", map_id, l);

// remove map from lookup list, if it exists
if (extension_map_list->slot[map_id]) extension_map_list->slot[map_id]->map->map_id = 0;
Expand Down
Loading

0 comments on commit 8a11e1a

Please sign in to comment.