aboutsummaryrefslogtreecommitdiff
path: root/nDPId.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2023-11-06 23:49:51 +0100
committerToni Uhlig <matzeton@googlemail.com>2023-11-07 00:02:36 +0100
commit5d56288a113aa3aa2e68dbf54f0acde0650bafcb (patch)
treebc4e9904feac2a8c9e5f5287774416b1aa3822f9 /nDPId.c
parent84b12cd02c1f11d134f00b0a066414a677a53719 (diff)
Fixed more SonarCloud complaints.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'nDPId.c')
-rw-r--r--nDPId.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/nDPId.c b/nDPId.c
index 7865b5298..74216da4d 100644
--- a/nDPId.c
+++ b/nDPId.c
@@ -1560,8 +1560,12 @@ static int setup_reader_threads(void)
"Could not get netmask for pcap device %s: %s",
get_cmdarg(&nDPId_options.pcap_file_or_interface),
strerror(errno));
- } else {
- logger_early(1, "Unexpected error while retrieving netmask for pcap device %s", get_cmdarg(&nDPId_options.pcap_file_or_interface));
+ }
+ else
+ {
+ logger_early(1,
+ "Unexpected error while retrieving netmask for pcap device %s",
+ get_cmdarg(&nDPId_options.pcap_file_or_interface));
}
return 1;
}
@@ -2661,15 +2665,13 @@ static void jsonize_packet_event(struct nDPId_reader_thread * const reader_threa
reader_thread->workflow->packets_captured,
reader_thread->array_index);
}
- else if (base64_data_len > 0)
+ else if (base64_data_len > 0 &&
+ ndpi_serialize_string_binary(&workflow->ndpi_serializer, "pkt", base64_data, (uint16_t)base64_data_len) != 0)
{
- if (ndpi_serialize_string_binary(&workflow->ndpi_serializer, "pkt", base64_data, base64_data_len) != 0)
- {
- logger(1,
- "[%8llu, %zu] JSON serializing base64 packet buffer failed",
- reader_thread->workflow->packets_captured,
- reader_thread->array_index);
- }
+ logger(1,
+ "[%8llu, %zu] JSON serializing base64 packet buffer failed",
+ reader_thread->workflow->packets_captured,
+ reader_thread->array_index);
}
serialize_and_send(reader_thread);
}
@@ -4391,8 +4393,8 @@ static void run_pcap_loop(struct nDPId_reader_thread * const reader_thread)
struct nio io;
nio_init(&io);
#ifdef ENABLE_EPOLL
- if ((nDPId_options.use_poll == 0 && nio_use_epoll(&io, 32) != NIO_SUCCESS)
- || (nDPId_options.use_poll != 0 && nio_use_poll(&io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS))
+ if ((nDPId_options.use_poll == 0 && nio_use_epoll(&io, 32) != NIO_SUCCESS) ||
+ (nDPId_options.use_poll != 0 && nio_use_poll(&io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS))
#else
if (nio_use_poll(&io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS)
#endif