diff --git a/CMakeLists.txt b/CMakeLists.txt index d8501f1..7ad3e17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ project(sngrep set(PROJECT_NAME sngrep) set(CMAKE_C_STANDARD 99) add_compile_options(-Werror) +#add_compile_options(-Werror -Wall -pedantic -Wextra) configure_file( ${PROJECT_SOURCE_DIR}/src/config.h.cmake.in diff --git a/src/capture/capture.c b/src/capture/capture.c index 82345f0..d508866 100644 --- a/src/capture/capture.c +++ b/src/capture/capture.c @@ -81,7 +81,7 @@ capture_manager_start(CaptureManager *manager) for (GSList *le = manager->inputs; le != NULL; le = le->next) { CaptureInput *input = le->data; input->running = TRUE; - input->thread = g_thread_new(NULL, (void *) input->start, input); + input->thread = g_thread_new(NULL, (GThreadFunc) input->start, input); } } @@ -132,7 +132,7 @@ capture_manager_filter(CaptureManager *manager) } void -capture_manager_set_keyfile(CaptureManager *manager, gchar *keyfile, GError **error) +capture_manager_set_keyfile(CaptureManager *manager, gchar *keyfile, G_GNUC_UNUSED GError **error) { manager->keyfile = keyfile; } diff --git a/src/capture/capture_pcap.c b/src/capture/capture_pcap.c index ead5eef..dc81d86 100644 --- a/src/capture/capture_pcap.c +++ b/src/capture/capture_pcap.c @@ -85,7 +85,7 @@ capture_input_pcap_online(const gchar *dev, GError **error) pcap->link = pcap_datalink(pcap->handle); // Check linktypes sngrep knowns before start parsing packets - if (proto_link_size(pcap->link) == -1) { + if (proto_link_size(pcap->link) == 0) { g_set_error (error, CAPTURE_PCAP_ERROR, CAPTURE_PCAP_ERROR_UNKNOWN_LINK, @@ -142,7 +142,7 @@ capture_input_pcap_offline(const gchar *infile, GError **error) pcap->link = pcap_datalink(pcap->handle); // Check linktypes sngrep knowns before start parsing packets - if (proto_link_size(pcap->link) == -1) { + if (proto_link_size(pcap->link) == 0) { g_set_error (error, CAPTURE_PCAP_ERROR, CAPTURE_PCAP_ERROR_UNKNOWN_LINK, @@ -307,11 +307,9 @@ capture_pcap_parse_packet(u_char *info, const struct pcap_pkthdr *header, const // Capture Input info CaptureInput *input = (CaptureInput *) info; - // Capture pcap info - CapturePcap *pcap = input->priv; // Capture manager CaptureManager *manager = input->manager; - // + // Packet dissectors parser PacketParser *parser = input->parser; // Ignore packets while capture is paused diff --git a/src/curses/ui_call_flow.c b/src/curses/ui_call_flow.c index 9759183..b9212cb 100644 --- a/src/curses/ui_call_flow.c +++ b/src/curses/ui_call_flow.c @@ -430,7 +430,7 @@ call_flow_draw_message(ui_t *ui, call_flow_arrow_t *arrow, int cline) Address src; Address dst; char method[80]; - char delta[15] = { }; + char delta[15] = { 0 }; int flowh; char mediastr[40]; SipMsg *msg = arrow->item; diff --git a/src/curses/ui_call_list.c b/src/curses/ui_call_list.c index 5cbf554..3983eb7 100644 --- a/src/curses/ui_call_list.c +++ b/src/curses/ui_call_list.c @@ -160,7 +160,7 @@ call_list_info(ui_t *ui) } bool -call_list_redraw(ui_t *ui) +call_list_redraw(G_GNUC_UNUSED ui_t *ui) { return storage_calls_changed(); } diff --git a/src/packet/address.c b/src/packet/address.c index 8c3a583..0aba9c5 100644 --- a/src/packet/address.c +++ b/src/packet/address.c @@ -105,7 +105,7 @@ address_is_local(Address addr) Address address_from_str(const char *ipport) { - Address ret = {}; + Address ret = { 0 }; gchar scanipport[256]; gchar address[256]; guint16 port; @@ -115,7 +115,7 @@ address_from_str(const char *ipport) strncpy(scanipport, ipport, strlen(ipport)); - if (sscanf(scanipport, "%[^:]:%hd", address, &port) == 2) { + if (sscanf(scanipport, "%[^:]:%hu", address, &port) == 2) { strncpy(ret.ip, address, strlen(address)); ret.port = port; } diff --git a/src/packet/dissectors/packet_ip.c b/src/packet/dissectors/packet_ip.c index 2064873..3e3d8df 100644 --- a/src/packet/dissectors/packet_ip.c +++ b/src/packet/dissectors/packet_ip.c @@ -195,6 +195,8 @@ packet_ip_parse(PacketParser *parser, Packet *packet, GByteArray *data) // Call next dissector return packet_parser_next_dissector(parser, packet, data); } + + return data; } static void diff --git a/src/packet/dissectors/packet_link.c b/src/packet/dissectors/packet_link.c index d35a594..d8654b1 100644 --- a/src/packet/dissectors/packet_link.c +++ b/src/packet/dissectors/packet_link.c @@ -45,7 +45,7 @@ packet_link_parse(PacketParser *parser, Packet *packet, GByteArray *data) g_return_val_if_fail(priv, NULL); // Get Layer header size from link type - gint offset = priv->link_size; + guint offset = (guint) priv->link_size; // For ethernet, skip VLAN header if present if (priv->link_type == DLT_EN10MB) { @@ -162,7 +162,7 @@ packet_link_init(PacketParser *parser) } static void -packet_link_deinit(PacketParser *parser) +packet_link_deinit(G_GNUC_UNUSED PacketParser *parser) { // g_free(proto->priv); // g_free(proto); diff --git a/src/packet/dissectors/packet_rtcp.c b/src/packet/dissectors/packet_rtcp.c index 561d946..fae5f02 100644 --- a/src/packet/dissectors/packet_rtcp.c +++ b/src/packet/dissectors/packet_rtcp.c @@ -91,7 +91,7 @@ packet_rtcp_parse(G_GNUC_UNUSED PacketParser *parser, Packet *packet, GByteArray break; // Header length - gint hlen = g_ntohs(hdr.len) * 4 + 4; + guint hlen = (guint) g_ntohs(hdr.len) * 4 + 4; // No enough data for this RTCP header if (hlen > data->len) @@ -117,7 +117,7 @@ packet_rtcp_parse(G_GNUC_UNUSED PacketParser *parser, Packet *packet, GByteArray size_t bsize = sizeof(hdr_xr); // Read all report blocks - while (bsize < ntohs(hdr_xr.len) * 4 + 4) { + while (bsize < (guint) ntohs(hdr_xr.len) * 4 + 4) { // Read block header memcpy(&blk_xr, data->data + bsize, sizeof(blk_xr)); // Check block type diff --git a/src/packet/dissectors/packet_sdp.c b/src/packet/dissectors/packet_sdp.c index 2fb6e27..9c72350 100644 --- a/src/packet/dissectors/packet_sdp.c +++ b/src/packet/dissectors/packet_sdp.c @@ -227,6 +227,8 @@ packet_sdp_dissect(G_GNUC_UNUSED PacketParser *parser, Packet *packet, GByteArra // Set packet SDP data g_ptr_array_insert(packet->proto, PACKET_SDP, sdp); + + return data; } PacketDissector * diff --git a/src/packet/dissectors/packet_sip.c b/src/packet/dissectors/packet_sip.c index 30dd5e4..6443458 100644 --- a/src/packet/dissectors/packet_sip.c +++ b/src/packet/dissectors/packet_sip.c @@ -172,14 +172,14 @@ packet_sip_parse(PacketParser *parser, Packet *packet, GByteArray *data) gint start, end; // Only handle UTF-8 SIP payloads - if (!g_utf8_validate(data->data, data->len, NULL)) { + if (!g_utf8_validate((gchar *) data->data, data->len, NULL)) { return data; } DissectorSipData *sip = g_ptr_array_index(parser->dissectors, PACKET_SIP); // Convert payload to something we can parse with regular expressions - GString *payload = g_string_new_len(data->data, data->len); + GString *payload = g_string_new_len((const gchar *) data->data, data->len); // If this comes from a TCP stream, check we have a whole packet if (packet_has_type(packet, PACKET_TCP)) { @@ -204,14 +204,14 @@ packet_sip_parse(PacketParser *parser, Packet *packet, GByteArray *data) g_match_info_fetch_pos(pmatch, 1, &start, &end); // The SDP body of the SIP message ends in another packet - if (start + content_len > data->len) { + if ((guint) (start + content_len) > data->len) { g_match_info_free(pmatch); // Not a SIP message or not complete return data; } // We got more than one SIP message in the same packet - if (start + content_len < data->len) { + if ((guint) (start + content_len) < data->len) { // Limit the size of the string to the end of the body g_string_set_size(payload, start + content_len); } diff --git a/src/packet/dissectors/packet_tcp.c b/src/packet/dissectors/packet_tcp.c index 9758428..f22ac9e 100644 --- a/src/packet/dissectors/packet_tcp.c +++ b/src/packet/dissectors/packet_tcp.c @@ -248,6 +248,8 @@ packet_tcp_parse(PacketParser *parser, Packet *packet, GByteArray *data) } else if (pending->len < data->len) { // Partially parsed } + + return pending; } static void diff --git a/src/packet/old_packet.h b/src/packet/old_packet.h index 3492ca3..de4ef9c 100644 --- a/src/packet/old_packet.h +++ b/src/packet/old_packet.h @@ -33,8 +33,8 @@ * */ -#ifndef __SNGREP_CAPTURE_PACKET_H -#define __SNGREP_CAPTURE_PACKET_H +#ifndef __SNGREP_CAPTURE_OLD_PACKET_H +#define __SNGREP_CAPTURE_OLD_PACKET_H #include #include @@ -173,4 +173,4 @@ packet_payload(packet_t *packet); struct timeval packet_time(const packet_t *packet); -#endif /* __SNGREP_CAPTURE_PACKET_H */ +#endif /* __SNGREP_CAPTURE_OLD_PACKET_H */ diff --git a/src/packet/packet.c b/src/packet/packet.c index 8a33dd4..9340397 100644 --- a/src/packet/packet.c +++ b/src/packet/packet.c @@ -144,7 +144,7 @@ packet_to_oldpkt(Packet *packet) PacketSipData *sipdata = g_ptr_array_index(packet->proto, PACKET_SIP); if (sipdata) { - packet_set_payload(oldpkt, sipdata->payload, strlen(sipdata->payload)); + packet_set_payload(oldpkt, (guchar *) sipdata->payload, strlen(sipdata->payload)); } oldpkt->frames = g_sequence_new(NULL); diff --git a/src/packet/parser.c b/src/packet/parser.c index 1757119..780ded4 100644 --- a/src/packet/parser.c +++ b/src/packet/parser.c @@ -113,6 +113,8 @@ packet_parser_add_proto(PacketParser *parser, GNode *parent, enum packet_proto i for (GSList *l = dissector->subdissectors; l != NULL; l = l->next) { packet_parser_add_proto(parser, node, GPOINTER_TO_UINT(l->data)); } + + return dissector; }