Skip to content

Commit

Permalink
Fix compiler warnings on some Linux systems
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Jun 24, 2024
1 parent ce52547 commit e56f7f1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/libnffile/nffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
Expand Down Expand Up @@ -1672,7 +1673,7 @@ int QueryFile(char *filename, int verbose) {
}

printf("File : %s\n", filename);
printf("Size : %lld\n", stat_buf.st_size);
printf("Size : %" PRIi64 "\n", (int64_t)stat_buf.st_size);
if (fileHeader.version == LAYOUT_VERSION_1) {
if (lseek(fd, 0, SEEK_SET) < 0) {
LogError("lseek() error in %s line %d: %s", __FILE__, __LINE__, strerror(errno));
Expand Down
13 changes: 11 additions & 2 deletions src/nfdump/nflowcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,12 @@ char *ParseAggregateMask(char *arg) {
return NULL;
}

int modeCSV = 0;
char *sep = " ";
if (modeCSV) {
sep = ",";
}

uint32_t elementCount = 0;
aggregateInfo[0] = -1;

Expand All @@ -1124,7 +1130,10 @@ char *ParseAggregateMask(char *arg) {
return 0;
}
aggr_fmt[0] = '\0';
fmt_len -= snprintf(aggr_fmt, fmt_len, "fmt:%s ", AggrPrependFmt);
if (modeCSV)
fmt_len -= snprintf(aggr_fmt, fmt_len, "csv:%s ", AggrPrependFmt);
else
fmt_len -= snprintf(aggr_fmt, fmt_len, "fmt:%s ", AggrPrependFmt);

uint32_t v4Mask = 0xffffffff;
uint64_t v6Mask[2] = {0xffffffffffffffffLL, 0xffffffffffffffffLL};
Expand Down Expand Up @@ -1195,7 +1204,7 @@ char *ParseAggregateMask(char *arg) {
if (aggregationTable[index].fmt != NULL) {
strncat(aggr_fmt, aggregationTable[index].fmt, fmt_len);
fmt_len -= strlen(aggregationTable[index].fmt);
strncat(aggr_fmt, " ", fmt_len);
strncat(aggr_fmt, sep, fmt_len);
fmt_len -= 1;
}

Expand Down
7 changes: 5 additions & 2 deletions src/nfdump/nfstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdint.h>
Expand Down Expand Up @@ -1232,13 +1233,15 @@ static void PrintJsonStatLine(char *statName, stat_record_t *stat, outputParams_
if (outputParams->hasGeoDB && type == IS_IPADDR) {
printf(
"{ \"first\" : \"%s.%03u\", \"last\" : \"%s.%03u\", \"proto\" : %u, \"%s\" : \"%s\", \"geo\" : \"%s\","
"\"flows\" : %llu, \"packets\" : %llu, \"bytes\" : %llu, \"pps\" : %llu, \"bps\" : %llu, \"bpp\" : %u}\n",
"\"flows\" : %" PRIu64 ", \"packets\" : %" PRIu64 ", \"bytes\" : %" PRIu64 ", \"pps\" : %" PRIu64 ", \"bps\" : %" PRIu64
", \"bpp\" : %u}\n",
datestrFirst, (unsigned)(statRecord->msecFirst % 1000), datestrLast, (unsigned)(statRecord->msecLast % 1000), hashKey->proto, statName,
valstr, geo, count_flows, count_packets, count_bytes, pps, bps, bpp);
} else {
printf(
"{ \"first\" : \"%s.%03u\", \"last\" : \"%s.%03u\", \"proto\" : %u, \"%s\" : \"%s\", "
"\"flows\" : %llu, \"packets\" : %llu, \"bytes\" : %llu, \"pps\" : %llu, \"bps\" : %llu, \"bpp\" : %u}\n",
"\"flows\" : %" PRIu64 ", \"packets\" : %" PRIu64 ", \"bytes\" : %" PRIu64 ", \"pps\" : %" PRIu64 ", \"bps\" : %" PRIu64
", \"bpp\" : %u}\n",
datestrFirst, (unsigned)(statRecord->msecFirst % 1000), datestrLast, (unsigned)(statRecord->msecLast % 1000), hashKey->proto, statName,
valstr, count_flows, count_packets, count_bytes, pps, bps, bpp);
}
Expand Down
2 changes: 1 addition & 1 deletion src/output/output_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ static void String_PortBlockSize(FILE *stream, recordHandle_t *recordHandle) {

static void String_flowId(FILE *stream, recordHandle_t *recordHandle) {
EXflowId_t *flowId = (EXflowId_t *)recordHandle->extensionList[EXflowIdID];
fprintf(stream, "0x%llu", flowId ? flowId->flowId : 0);
fprintf(stream, "0x%" PRIu64, flowId ? flowId->flowId : 0);
} // End of String_flowId

static void String_inServiceID(FILE *stream, recordHandle_t *recordHandle) {
Expand Down
3 changes: 2 additions & 1 deletion src/output/output_fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -2547,7 +2548,7 @@ static void String_PortBlockSize(FILE *stream, recordHandle_t *recordHandle) {

static void String_flowId(FILE *stream, recordHandle_t *recordHandle) {
EXflowId_t *flowId = (EXflowId_t *)recordHandle->extensionList[EXflowIdID];
fprintf(stream, "0x%13llu", flowId ? flowId->flowId : 0);
fprintf(stream, "0x%13" PRIu64, flowId ? flowId->flowId : 0);
} // End of String_flowId

static void String_inServiceID(FILE *stream, recordHandle_t *recordHandle) {
Expand Down
3 changes: 2 additions & 1 deletion src/output/output_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define _GNU_SOURCE

#include <arpa/inet.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -662,7 +663,7 @@ static void stringEXnatPortBlock(FILE *stream, void *extensionRecord, const char
static void stringEXflowId(FILE *stream, void *extensionRecord, const char *indent, const char *fs) {
EXflowId_t *flowId = (EXflowId_t *)extensionRecord;

fprintf(stream, "%s\"flowID\" : %llu%s", indent, flowId->flowId, fs);
fprintf(stream, "%s\"flowID\" : %" PRIu64 "%s", indent, flowId->flowId, fs);
} // End of stringEXflowId

static void stringEXnokiaNat(FILE *stream, void *extensionRecord, const char *indent, const char *fs) {
Expand Down
3 changes: 2 additions & 1 deletion src/output/output_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <arpa/inet.h>
#include <ctype.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -821,7 +822,7 @@ static void stringsEXinmon(FILE *stream, void *extensionRecord) {

static void stringsEXflowId(FILE *stream, void *extensionRecord) {
EXflowId_t *flowId = (EXflowId_t *)extensionRecord;
fprintf(stream, " flow ID = 0x%13llx\n", flowId->flowId);
fprintf(stream, " flow ID = 0x%13" PRIx64 "\n", flowId->flowId);
} // End of stringsEXflowId

static void stringsEXnokiaNat(FILE *stream, void *extensionRecord) {
Expand Down

0 comments on commit e56f7f1

Please sign in to comment.