From: Michael Altizer Date: Fri, 1 Apr 2016 18:39:01 +0000 (-0400) Subject: ICC remark cleanups. X-Git-Tag: 3.0.0-233~483^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d8f4039f7b2efb2103c6ef7963a75c8d348adfd;p=thirdparty%2Fsnort3.git ICC remark cleanups. --- diff --git a/src/codecs/ip/cd_auth.cc b/src/codecs/ip/cd_auth.cc index af84794b0..595312196 100644 --- a/src/codecs/ip/cd_auth.cc +++ b/src/codecs/ip/cd_auth.cc @@ -83,7 +83,7 @@ void AuthCodec::get_protocol_ids(std::vector& v) bool AuthCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort) { - const AuthHdr* const ah = reinterpret_cast(raw.data); + const AuthHdr* const ah = reinterpret_cast(raw.data); if (raw.len < MIN_AUTH_LEN) { diff --git a/src/codecs/ip/cd_pgm.cc b/src/codecs/ip/cd_pgm.cc index de1f503df..7eedf583f 100644 --- a/src/codecs/ip/cd_pgm.cc +++ b/src/codecs/ip/cd_pgm.cc @@ -105,7 +105,7 @@ static inline int pgm_nak_detect(const RawData& raw) } const PgmHeader* const header = - reinterpret_cast(raw.data); + reinterpret_cast(raw.data); if (8 != header->type) return PGM_NAK_ERR; diff --git a/src/codecs/ip/cd_tcp.cc b/src/codecs/ip/cd_tcp.cc index 7d4c1bc00..80bf8cd71 100644 --- a/src/codecs/ip/cd_tcp.cc +++ b/src/codecs/ip/cd_tcp.cc @@ -490,7 +490,7 @@ int TcpCodec::OptLenValidate(const tcp::TcpOption* const opt, const int expected_len) { // case for pointer arithmetic - const uint8_t* const opt_ptr = reinterpret_cast(opt); + const uint8_t* const opt_ptr = reinterpret_cast(opt); if (expected_len > 1) { diff --git a/src/codecs/ip/checksum.h b/src/codecs/ip/checksum.h index 1a9d9ad86..2b0071c0c 100644 --- a/src/codecs/ip/checksum.h +++ b/src/codecs/ip/checksum.h @@ -175,7 +175,7 @@ inline void add_ipv4_pseudoheader(const Pseudoheader* const ph4, * Otherwise they assume we are reading garbage values */ const PsuedoheaderUnion* const ph4_u = reinterpret_cast - (ph4); + (ph4); const uint16_t* const h = ph4_u->ph4_arr; /* ipv4 pseudo header must have 12 bytes */ @@ -195,7 +195,7 @@ inline void add_ipv6_pseudoheader(const Pseudoheader6* const ph6, * Otherwise they assume we are reading garbage values */ const Psuedoheader6Union* const ph6_u = reinterpret_cast - (ph6); + (ph6); const uint16_t* const h = ph6_u->ph6_arr; /* PseudoHeader must have 36 bytes */ diff --git a/src/codecs/link/cd_ppp_encap.cc b/src/codecs/link/cd_ppp_encap.cc index b2eac2a8b..c6723a9e2 100644 --- a/src/codecs/link/cd_ppp_encap.cc +++ b/src/codecs/link/cd_ppp_encap.cc @@ -42,11 +42,11 @@ public: bool decode(const RawData&, CodecData&, DecodeData&) override; }; -const static uint16_t PPP_IP = 0x0021; /* Internet Protocol */ -const static uint16_t PPP_IPV6 = 0x0057; /* Internet Protocol v6 */ -const static uint16_t PPP_VJ_COMP = 0x002d; /* VJ compressed TCP/IP */ -const static uint16_t PPP_VJ_UCOMP = 0x002f; /* VJ uncompressed TCP/IP */ -const static uint16_t PPP_IPX = 0x002b; /* Novell IPX Protocol */ +static const uint16_t PPP_IP = 0x0021; /* Internet Protocol */ +static const uint16_t PPP_IPV6 = 0x0057; /* Internet Protocol v6 */ +static const uint16_t PPP_VJ_COMP = 0x002d; /* VJ compressed TCP/IP */ +static const uint16_t PPP_VJ_UCOMP = 0x002f; /* VJ uncompressed TCP/IP */ +static const uint16_t PPP_IPX = 0x002b; /* Novell IPX Protocol */ } // namespace void PppEncap::get_protocol_ids(std::vector& v) diff --git a/src/detection/detection_options.cc b/src/detection/detection_options.cc index c4ef39c06..7a60d2247 100644 --- a/src/detection/detection_options.cc +++ b/src/detection/detection_options.cc @@ -720,7 +720,6 @@ struct node_profile_stats static void detection_option_node_update_otn_stats(detection_option_tree_node_t* node, node_profile_stats* stats, uint64_t checks, uint64_t timeouts, uint64_t suspends) { - int i; node_profile_stats local_stats; /* cumulative stats for this node */ node_profile_stats node_stats; /* sum of all instances */ @@ -782,7 +781,7 @@ static void detection_option_node_update_otn_stats(detection_option_tree_node_t* if ( node->num_children ) { - for ( i=0; i < node->num_children; ++i ) + for ( int i=0; i < node->num_children; ++i ) detection_option_node_update_otn_stats(node->children[i], &local_stats, checks, timeouts, suspends); } diff --git a/src/detection/fp_config.cc b/src/detection/fp_config.cc index 09252396a..35d2d4df2 100644 --- a/src/detection/fp_config.cc +++ b/src/detection/fp_config.cc @@ -65,7 +65,7 @@ bool FastPatternConfig::set_detect_search_method(const char* method) void FastPatternConfig::set_max_pattern_len(unsigned int max_len) { if (max_pattern_len != 0) - ParseWarning(WARN_CONF, "maximum pattern length redefined from %d to %d.\n", + ParseWarning(WARN_CONF, "maximum pattern length redefined from %d to %u.\n", max_pattern_len, max_len); max_pattern_len = max_len; diff --git a/src/detection/fp_create.cc b/src/detection/fp_create.cc index 21f906363..65ac08b0c 100644 --- a/src/detection/fp_create.cc +++ b/src/detection/fp_create.cc @@ -513,7 +513,7 @@ bool set_fp_content(OptTreeNode* otn) if ( best.pmd and otn->proto == SNORT_PROTO_FILE and best.cat != CAT_SET_FILE ) { - ParseWarning(WARN_RULES, "file rule %d:%d does not have file_data fast pattern", + ParseWarning(WARN_RULES, "file rule %u:%u does not have file_data fast pattern", otn->sigInfo.generator, otn->sigInfo.id); best.pmd->fp = 0; @@ -524,7 +524,7 @@ bool set_fp_content(OptTreeNode* otn) return true; if ( content ) - ParseWarning(WARN_RULES, "content based rule %d:%d has no fast pattern", + ParseWarning(WARN_RULES, "content based rule %u:%u has no fast pattern", otn->sigInfo.generator, otn->sigInfo.id); return false; diff --git a/src/file_api/file_identifier.cc b/src/file_api/file_identifier.cc index a60a2da31..00a8ceb3f 100644 --- a/src/file_api/file_identifier.cc +++ b/src/file_api/file_identifier.cc @@ -149,7 +149,7 @@ void FileIdentifier::verify_magic_offset(FileMagicData* parent, FileMagicData* c { if ((parent) && (parent->content.size() + parent->offset > current->offset)) { - ParseError("magic content at offset %d overlaps with offset %d.", + ParseError("magic content at offset %u overlaps with offset %u.", parent->offset, current->offset); return; } @@ -278,7 +278,7 @@ void FileIdentifier::update_trie(IdentifierNode* start, IdentifierNode* append) if (append->type_id) { if (start->type_id) - ParseWarning(WARN_RULES, "Duplicated type definition '%d -> %d at offset %d", + ParseWarning(WARN_RULES, "Duplicated type definition '%u -> %u at offset %u", start->type_id, append->type_id, append->offset); start->type_id = append->type_id; } @@ -313,13 +313,13 @@ void FileIdentifier::insert_file_rule(FileMagicRule& rule) if (rule.id > FILE_ID_MAX) { - ParseError("file type: rule id %d larger than %d", rule.id, FILE_ID_MAX); + ParseError("file type: rule id %u larger than %d", rule.id, FILE_ID_MAX); return; } if (file_magic_rules[rule.id].id > 0) { - ParseError("file type: duplicated rule id %d defined", rule.id); + ParseError("file type: duplicated rule id %u defined", rule.id); return; } diff --git a/src/file_api/file_lib.cc b/src/file_api/file_lib.cc index 4bf97a189..25e3db2f7 100644 --- a/src/file_api/file_lib.cc +++ b/src/file_api/file_lib.cc @@ -508,7 +508,7 @@ void FileContext::print() if (unused > 0) { - used = snprintf(cur, unused, "\nFile type: %s(%d)", + used = snprintf(cur, unused, "\nFile type: %s(%u)", file_config->file_type_name(file_type_id).c_str(), file_type_id); unused -= used; cur += used; diff --git a/src/filters/sfrf.cc b/src/filters/sfrf.cc index c6dd700bb..d3f1c7e35 100644 --- a/src/filters/sfrf.cc +++ b/src/filters/sfrf.cc @@ -595,7 +595,7 @@ void SFRF_ShowObjects(RateFilterConfig* config) SFGHASH* genHash; tSFRFSidNode* pSidnode; tSFRFConfigNode* cfgNode; - int gid; + unsigned int gid; SFGHASH_NODE* sidHashNode; for ( gid=0; gid < SFRF_MAX_GENID; gid++ ) diff --git a/src/ips_options/asn1_util.cc b/src/ips_options/asn1_util.cc index 8903e43bd..27b6381b8 100644 --- a/src/ips_options/asn1_util.cc +++ b/src/ips_options/asn1_util.cc @@ -981,7 +981,7 @@ int asn1_print_types(ASN1_TYPE* asn1_type, void* user) printf(" "); printf("IDENT - asn1_class: %.2x | flag: %.2x | tag_type: %.2x | " - "tag_num: %d\n", asn1_type->ident.asn1_class, asn1_type->ident.flag, + "tag_num: %u\n", asn1_type->ident.asn1_class, asn1_type->ident.flag, asn1_type->ident.tag_type, asn1_type->ident.tag); for (iCtr = 0; iCtr < iTabs; iCtr++) @@ -993,7 +993,7 @@ int asn1_print_types(ASN1_TYPE* asn1_type, void* user) for (iCtr = 0; iCtr < iTabs; iCtr++) printf(" "); - printf("DATA | data_len: %d | ", asn1_type->data_len); + printf("DATA | data_len: %u | ", asn1_type->data_len); if (asn1_type->data) { for (iCtr = 0; iCtr < asn1_type->data_len; iCtr++) diff --git a/src/ips_options/ips_metadata.cc b/src/ips_options/ips_metadata.cc index 1b4da8466..fa4fb5606 100644 --- a/src/ips_options/ips_metadata.cc +++ b/src/ips_options/ips_metadata.cc @@ -115,8 +115,8 @@ static IpsOption* metadata_ctor(Module* p, OptTreeNode* otn) { MetadataModule* m = (MetadataModule*)p; - for ( auto p : m->services ) - add_service_to_otn(m->snort_config, otn, p.c_str()); + for ( auto service : m->services ) + add_service_to_otn(m->snort_config, otn, service.c_str()); return nullptr; } diff --git a/src/ips_options/sd_pattern_match.cc b/src/ips_options/sd_pattern_match.cc index 934eb05b5..878dd9b8b 100644 --- a/src/ips_options/sd_pattern_match.cc +++ b/src/ips_options/sd_pattern_match.cc @@ -29,8 +29,7 @@ #include "log/messages.h" -int AddPiiPiece(SdTreeNode *node, char *new_pattern, SdOptionData *data); -SdTreeNode* AddChild(SdTreeNode *node, SdOptionData *data, char *pattern); +static SdTreeNode* AddChild(SdTreeNode *node, SdOptionData *data, char *pattern); SdOptionData::SdOptionData(std::string pattern, uint8_t threshold) @@ -203,7 +202,7 @@ int AddPii(SdTreeNode *head, SdOptionData *data) } // Create a new tree node, and add it as a child to the current node. -SdTreeNode * AddChild(SdTreeNode *node, SdOptionData *data, char *pattern) +static SdTreeNode * AddChild(SdTreeNode *node, SdOptionData *data, char *pattern) { SdTreeNode * new_node = NULL; diff --git a/src/latency/packet_latency.cc b/src/latency/packet_latency.cc index 5f8878ca8..715296918 100644 --- a/src/latency/packet_latency.cc +++ b/src/latency/packet_latency.cc @@ -182,20 +182,20 @@ inline bool Impl::fastpath() // static variables // ----------------------------------------------------------------------------- -static struct SnortConfigWrapper : ConfigWrapper +static struct SnortConfigWrapper : public ConfigWrapper { const PacketLatencyConfig* operator->() const override { return &snort_conf->latency->packet_latency; } } config; -static struct SnortEventHandler : EventHandler +static struct SnortEventHandler : public EventHandler { void handle(const Event&) override { SnortEventqAdd(GID_LATENCY, LATENCY_EVENT_PACKET_FASTPATHED); } } event_handler; -static struct SnortLogHandler : EventHandler +static struct SnortLogHandler : public EventHandler { void handle(const Event& e) override { diff --git a/src/latency/rule_latency.cc b/src/latency/rule_latency.cc index d24571d7a..3180d0aad 100644 --- a/src/latency/rule_latency.cc +++ b/src/latency/rule_latency.cc @@ -279,14 +279,14 @@ inline void Impl::handle(const Event& e) // static variables // ----------------------------------------------------------------------------- -static struct SnortConfigWrapper : ConfigWrapper +static struct SnortConfigWrapper : public ConfigWrapper { const RuleLatencyConfig* operator->() const override { return &snort_conf->latency->rule_latency; } } config; -static struct SnortEventHandler : EventHandler +static struct SnortEventHandler : public EventHandler { void handle(const Event& e) override { @@ -306,7 +306,7 @@ static struct SnortEventHandler : EventHandler } } event_handler; -static struct SnortLogHandler : EventHandler +static struct SnortLogHandler : public EventHandler { void handle(const Event& e) override { diff --git a/src/log/messages.cc b/src/log/messages.cc index a65f3d40a..5c4ee38ed 100644 --- a/src/log/messages.cc +++ b/src/log/messages.cc @@ -162,7 +162,7 @@ NORETURN void ParseAbort(const char* format, ...) // FIXIT-L Refer to ParseMessage above. if (file_name != NULL) - FatalError("%s(%d) %s\n", file_name, file_line, buf); + FatalError("%s(%u) %s\n", file_name, file_line, buf); else FatalError("%s\n", buf); } diff --git a/src/loggers/alert_syslog.cc b/src/loggers/alert_syslog.cc index 0bef63cee..0023b2805 100644 --- a/src/loggers/alert_syslog.cc +++ b/src/loggers/alert_syslog.cc @@ -230,7 +230,7 @@ static void AlertSyslog( if (event->sig_info->priority != 0) { SnortSnprintfAppend(event_string, sizeof(event_string), - "[Priority: %d] ", event->sig_info->priority); + "[Priority: %u] ", event->sig_info->priority); } } diff --git a/src/main/snort.cc b/src/main/snort.cc index 1c36ca15f..b661a7ad4 100644 --- a/src/main/snort.cc +++ b/src/main/snort.cc @@ -212,7 +212,7 @@ static void show_source(const char* pcap) fprintf(stdout, "%s", "\n"); fprintf(stdout, - "Reading network traffic from \"%s\" with snaplen = %d\n", + "Reading network traffic from \"%s\" with snaplen = %u\n", pcap, DAQ_GetSnapLen()); } diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index e2770a279..1f5c6452f 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -98,7 +98,7 @@ NORETURN static void c2x(const char* s) NORETURN static void x2c(unsigned x) { - printf("0x%2.2X (%d) = '%c'\n", x, x, x); + printf("0x%2.2X (%u) = '%c'\n", x, x, static_cast(x)); exit(0); } diff --git a/src/main/thread.h b/src/main/thread.h index b14797043..ba4fe9fb0 100644 --- a/src/main/thread.h +++ b/src/main/thread.h @@ -30,7 +30,7 @@ // `__thread` is a gnu extension that at present is slightly faster than // `thread_local` (possibly due to the lack of dynamic initialization) -#if USE_THREAD_LOCAL +#ifdef USE_THREAD_LOCAL # define THREAD_LOCAL thread_local #else # define THREAD_LOCAL __thread diff --git a/src/main/thread_config.cc b/src/main/thread_config.cc index 1ae1a733d..ca43597b4 100644 --- a/src/main/thread_config.cc +++ b/src/main/thread_config.cc @@ -34,7 +34,7 @@ static unsigned instance_max = 1; struct CpuSet { - CpuSet(hwloc_cpuset_t cpuset) : cpuset(cpuset) { } + CpuSet(hwloc_cpuset_t set) : cpuset(set) { } ~CpuSet() { if (cpuset) @@ -152,7 +152,7 @@ void ThreadConfig::implement_thread_affinity(SThreadType type, unsigned id) hwloc_bitmap_list_asprintf(&s, desired_cpuset); if (hwloc_set_cpubind(topology, desired_cpuset, HWLOC_CPUBIND_THREAD)) { - FatalError("Unable to pin thread %u (type %u) to %s: %s (%d)\n", + FatalError("Failed to pin thread %u (type %u) to %s: %s (%d)\n", id, type, s, get_error(errno), errno); } #ifndef REG_TEST diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index 44f196940..4037322a3 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -164,7 +164,7 @@ static void trace(const char* s, const char* fqn, Value& v) if ( v.get_type() == Value::VT_STR ) printf("%s: %s = '%s'\n", s, fqn, v.get_string()); else - printf("%s: %s = %lu\n", s, fqn, v.get_long()); + printf("%s: %s = %ld\n", s, fqn, v.get_long()); } static ModHook* get_hook(const char* s) @@ -669,8 +669,8 @@ SO_PUBLIC bool open_table(const char* s, int idx) if ( strcmp(m->get_name(), s) ) { - std::string fqn = s; - p = get_params(fqn, m->get_parameters(), idx); + std::string sfqn = s; + p = get_params(sfqn, m->get_parameters(), idx); if ( !p ) { @@ -912,9 +912,9 @@ void ModuleManager::show_module(const char* name) cout << endl << "Type: " << mod_type(p->api) << endl; - if ( const Parameter* p = m->get_parameters() ) + if ( const Parameter* params = m->get_parameters() ) { - if ( p->type < Parameter::PT_MAX ) + if ( params->type < Parameter::PT_MAX ) { cout << endl << "Configuration: " << endl << endl; show_configs(name, true); diff --git a/src/managers/plugin_manager.cc b/src/managers/plugin_manager.cc index 0225d37f4..ec1f5af17 100644 --- a/src/managers/plugin_manager.cc +++ b/src/managers/plugin_manager.cc @@ -209,14 +209,14 @@ static bool register_plugin( if ( api->size != sym->size ) { - ParseWarning(WARN_PLUGINS, "%s: size mismatch; expected %d, got %d", + ParseWarning(WARN_PLUGINS, "%s: size mismatch; expected %u, got %u", api->name, sym->size, api->size); return false; } if ( api->api_version != sym->version ) { - ParseWarning(WARN_PLUGINS, "%s: version mismatch; expected %d, got %d", + ParseWarning(WARN_PLUGINS, "%s: version mismatch; expected %u, got %u", api->name, sym->version, api->version); return false; } diff --git a/src/network_inspectors/perf_monitor/flow_ip_tracker.cc b/src/network_inspectors/perf_monitor/flow_ip_tracker.cc index f50515474..b91e68bd4 100644 --- a/src/network_inspectors/perf_monitor/flow_ip_tracker.cc +++ b/src/network_inspectors/perf_monitor/flow_ip_tracker.cc @@ -173,7 +173,7 @@ void FlowIPTracker::write_stats() if (!fh) return; - fprintf(fh, "%ld,%u,", (unsigned long)cur_time, sfxhash_count(ipMap)); + fprintf(fh, "%lu,%u,", (unsigned long)cur_time, sfxhash_count(ipMap)); for (node = sfxhash_findfirst(ipMap); node; node = sfxhash_findnext(ipMap)) { char ipA[41], ipB[41]; diff --git a/src/network_inspectors/perf_monitor/perf_tracker.cc b/src/network_inspectors/perf_monitor/perf_tracker.cc index 1ecabbbae..39fe30523 100644 --- a/src/network_inspectors/perf_monitor/perf_tracker.cc +++ b/src/network_inspectors/perf_monitor/perf_tracker.cc @@ -77,7 +77,7 @@ void PerfTracker::open(bool append) if (chmod(file_name, mode) != 0) { WarningMessage("perfmonitor: Unable to change mode of " - "stats file '%s' to mode:%d: %s.", + "stats file '%s' to mode:%u: %s.", file_name, mode, get_error(errno)); } diff --git a/src/network_inspectors/port_scan/ipobj.cc b/src/network_inspectors/port_scan/ipobj.cc index 99b72a7ed..ab454b175 100644 --- a/src/network_inspectors/port_scan/ipobj.cc +++ b/src/network_inspectors/port_scan/ipobj.cc @@ -192,9 +192,9 @@ int ipset_print(IPSET* ipc) pr != 0; pr=(PORTRANGE*)sflist_next(&cur_port) ) { - printf(" %d", pr->port_lo); + printf(" %u", pr->port_lo); if ( pr->port_hi != pr->port_lo ) - printf("-%d", pr->port_hi); + printf("-%u", pr->port_hi); } printf("\n"); } diff --git a/src/network_inspectors/port_scan/port_scan.cc b/src/network_inspectors/port_scan/port_scan.cc index b3a10231a..1a7fd7941 100644 --- a/src/network_inspectors/port_scan/port_scan.cc +++ b/src/network_inspectors/port_scan/port_scan.cc @@ -694,10 +694,10 @@ static void PrintIPPortSet(IP_PORT* p) { if ( pr->port_lo != 0) { - SnortSnprintfAppend(output_str, sizeof(output_str), "%d", pr->port_lo); + SnortSnprintfAppend(output_str, sizeof(output_str), "%u", pr->port_lo); if ( pr->port_hi != pr->port_lo ) { - SnortSnprintfAppend(output_str, sizeof(output_str), "-%d", pr->port_hi); + SnortSnprintfAppend(output_str, sizeof(output_str), "-%u", pr->port_hi); } SnortSnprintfAppend(output_str, sizeof(output_str), " "); } diff --git a/src/network_inspectors/reputation/reputation_parse.cc b/src/network_inspectors/reputation/reputation_parse.cc index 63779da29..b7942e4d0 100644 --- a/src/network_inspectors/reputation/reputation_parse.cc +++ b/src/network_inspectors/reputation/reputation_parse.cc @@ -645,7 +645,7 @@ static char* GetListInfo(INFO info) case WHITELISTED_TRUST: return white_info; default: - return nullptr; + break; } return nullptr; } diff --git a/src/packet_io/trough.cc b/src/packet_io/trough.cc index b4604e141..8afa43f5f 100644 --- a/src/packet_io/trough.cc +++ b/src/packet_io/trough.cc @@ -35,19 +35,7 @@ std::vector::const_iterator Trough::pcap_queue_iter; long Trough::pcap_loop_count = 0; unsigned Trough::file_count = 0; -/***************************************************************** - * Function: GetPcaps() - * - * This function takes a list of pcap types and arguments from - * the command line, parses them depending on type and puts them - * in a user supplied queue. The pcap object list will contain - * PcapReadObject structures. The returned queue contains - * strings representing paths to pcaps. - * - * returns -1 on error and 0 on success - * - ****************************************************************/ -int Trough::get_pcaps(std::vector &pol, std::vector &pcap_queue) +int Trough::get_pcaps(std::vector &pol) { for (const PcapReadObject &pro : pol) { @@ -224,7 +212,7 @@ void Trough::setup(void) { if (!pcap_object_list.empty()) { - if (get_pcaps(pcap_object_list, pcap_queue) == -1) + if (get_pcaps(pcap_object_list) == -1) FatalError("Error getting pcaps.\n"); if (pcap_queue.empty()) diff --git a/src/packet_io/trough.h b/src/packet_io/trough.h index 1d01749bb..eeb3d89b1 100644 --- a/src/packet_io/trough.h +++ b/src/packet_io/trough.h @@ -65,7 +65,7 @@ private: std::string filter; }; - static int get_pcaps(std::vector &pol, std::vector &pcap_queue); + static int get_pcaps(std::vector &pol); static std::vector pcap_object_list; static std::vector pcap_queue; static std::vector::const_iterator pcap_queue_iter; diff --git a/src/parser/parse_rule.cc b/src/parser/parse_rule.cc index c08ef7ad3..b0633303e 100644 --- a/src/parser/parse_rule.cc +++ b/src/parser/parse_rule.cc @@ -1066,7 +1066,7 @@ static int mergeDuplicateOtn( if (otn_cur->proto != otn_new->proto) { - ParseError("GID %d SID %d in rule duplicates previous rule, with " + ParseError("GID %u SID %u in rule duplicates previous rule, with " "different protocol.", otn_new->sigInfo.generator, otn_new->sigInfo.id); return 0; @@ -1076,7 +1076,7 @@ static int mergeDuplicateOtn( if ((rtn_cur != NULL) && (rtn_cur->type != rtn_new->type)) { - ParseError("GID %d SID %d in rule duplicates previous rule, with " + ParseError("GID %u SID %u in rule duplicates previous rule, with " "different type.", otn_new->sigInfo.generator, otn_new->sigInfo.id); return 0; @@ -1089,7 +1089,7 @@ static int mergeDuplicateOtn( deleteRtnFromOtn(otn_new); ParseWarning(WARN_RULES, - "%d:%d duplicates previous rule. Using revision %d.", + "%u:%u duplicates previous rule. Using revision %u.", otn_cur->sigInfo.generator, otn_cur->sigInfo.id, otn_cur->sigInfo.rev); /* Now free the OTN itself -- this function is also used @@ -1128,14 +1128,14 @@ static int mergeDuplicateOtn( if (SnortConfig::conf_error_out()) { ParseError( - "%d:%d:%d duplicates previous rule.", + "%u:%u:%u duplicates previous rule.", otn_new->sigInfo.generator, otn_new->sigInfo.id, otn_new->sigInfo.rev); return 0; } else { ParseWarning(WARN_RULES, - "%d:%d duplicates previous rule. Using revision %d.", + "%u:%u duplicates previous rule. Using revision %u.", otn_new->sigInfo.generator, otn_new->sigInfo.id, otn_new->sigInfo.rev); } } @@ -1512,7 +1512,7 @@ const char* parse_rule_close(SnortConfig* sc, RuleTreeNode& rtn, OptTreeNode* ot ParseError("gid must set in builtin rules"); if ( otn->num_detection_opts ) - ParseError("%d:%d builtin rules do not support detection options", + ParseError("%u:%u builtin rules do not support detection options", otn->sigInfo.generator, otn->sigInfo.id); otn->sigInfo.text_rule = false; diff --git a/src/parser/parse_stream.cc b/src/parser/parse_stream.cc index 63a735b3e..abaf90821 100644 --- a/src/parser/parse_stream.cc +++ b/src/parser/parse_stream.cc @@ -208,7 +208,7 @@ static TokenType get_token( else if ( c == '\\' ) state = (esc > 0) ? 4 : 16; else if ( c == '\n' ) - ParseWarning(WARN_RULES, "line break in string on line %d\n", lines-1); + ParseWarning(WARN_RULES, "line break in string on line %u\n", lines-1); else s += c; break; @@ -223,7 +223,7 @@ static TokenType get_token( break; case 5: // unquoted escape if ( c != '\n' && c != '\r' ) - ParseWarning(WARN_RULES, "invalid escape on line %d\n", lines); + ParseWarning(WARN_RULES, "invalid escape on line %u\n", lines); state = 0; break; case 6: // token @@ -315,7 +315,7 @@ static TokenType get_token( state = 11; else if ( c == '\n' ) { - ParseWarning(WARN_RULES, "line break in commented string on line %d\n", lines-1); + ParseWarning(WARN_RULES, "line break in commented string on line %u\n", lines-1); state = 11; } break; @@ -327,7 +327,7 @@ static TokenType get_token( } else { - ParseWarning(WARN_RULES, "\\x used with no following hex digits on line %d\n", + ParseWarning(WARN_RULES, "\\x used with no following hex digits on line %u\n", lines-1); s += c; state = 3; diff --git a/src/parser/parse_utils.cc b/src/parser/parse_utils.cc index c81b0efc5..865dd1394 100644 --- a/src/parser/parse_utils.cc +++ b/src/parser/parse_utils.cc @@ -118,7 +118,7 @@ bool parse_byte_code(const char* in, bool& negate, std::string& out) } } if ( !ok ) - ParseError("invalid byte code at %d", idx); + ParseError("invalid byte code at %u", idx); return ok; } diff --git a/src/parser/parser.cc b/src/parser/parser.cc index df33f2c70..d7fd017de 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -613,7 +613,7 @@ void SetRuleStates(SnortConfig* sc) if (otn == NULL) { - ParseError("Rule state specified for invalid SID: %d GID: %d", + ParseError("Rule state specified for invalid SID: %u GID: %u", rule_state->sid, rule_state->gid); return; } diff --git a/src/ports/port_item.cc b/src/ports/port_item.cc index 1a5f2c229..4832e02ba 100644 --- a/src/ports/port_item.cc +++ b/src/ports/port_item.cc @@ -85,9 +85,9 @@ void PortObjectItemPrint(PortObjectItem* poi, char* dstbuf, int bufsize) SnortSnprintfAppend(dstbuf, bufsize, "any"); else if ( poi->one() ) - SnortSnprintfAppend(dstbuf, bufsize, "%u", poi->lport); + SnortSnprintfAppend(dstbuf, bufsize, "%hu", poi->lport); else - SnortSnprintfAppend(dstbuf, bufsize, "%u:%u",poi->lport,poi->hport); + SnortSnprintfAppend(dstbuf, bufsize, "%hu:%hu",poi->lport,poi->hport); } diff --git a/src/ports/port_object.cc b/src/ports/port_object.cc index 294abf6ac..d59ff841a 100644 --- a/src/ports/port_object.cc +++ b/src/ports/port_object.cc @@ -762,7 +762,7 @@ void PortObjectPrintEx(PortObject* po, } SnortSnprintfAppend(po_print_buf, bufsize, - " Id:%d Ports:%d Rules:%d\n {\n", + " Id:%d Ports:%u Rules:%u\n {\n", po->id, po->item_list->count,po->rule_list->count); SnortSnprintfAppend(po_print_buf, bufsize, " Ports [\n "); diff --git a/src/ports/port_object2.cc b/src/ports/port_object2.cc index 8a2207e0b..1ff9c7c76 100644 --- a/src/ports/port_object2.cc +++ b/src/ports/port_object2.cc @@ -352,7 +352,7 @@ void PortObject2PrintPorts(PortObject2* po) } SnortSnprintfAppend(po_print_buf, bufsize, - " Id:%d Ports:%d Rules:%d\n {\n Ports [", + " Id:%d Ports:%u Rules:%u\n {\n Ports [", po->id, po->item_list->count, po->rule_hash->count); if ( PortObjectHasAny( (PortObject*)po) ) @@ -390,7 +390,7 @@ void PortObject2PrintEx(PortObject2* po, if ( po->name ) SnortSnprintfAppend(po_print_buf, bufsize, "%s ",po->name); - SnortSnprintfAppend(po_print_buf, bufsize, " Id:%d Ports:%d Rules:%d PortUsageCnt=%d\n {\n", + SnortSnprintfAppend(po_print_buf, bufsize, " Id:%d Ports:%u Rules:%u PortUsageCnt=%d\n {\n", po->id, po->item_list->count, po->rule_hash->count, po->port_cnt); SnortSnprintfAppend(po_print_buf, bufsize, " Ports [\n "); diff --git a/src/profiler/profiler_nodes.cc b/src/profiler/profiler_nodes.cc index 92d834a4f..913255cbc 100644 --- a/src/profiler/profiler_nodes.cc +++ b/src/profiler/profiler_nodes.cc @@ -48,7 +48,7 @@ struct GetProfileFunctor const std::string name; }; -struct GetProfileFromModule : GetProfileFunctor +struct GetProfileFromModule : public GetProfileFunctor { GetProfileFromModule(std::string name, Module* m) : GetProfileFunctor(name), m(m) { } @@ -71,7 +71,7 @@ struct GetProfileFromModule : GetProfileFunctor Module* m; }; -struct GetProfileFromFunction : GetProfileFunctor +struct GetProfileFromFunction : public GetProfileFunctor { GetProfileFromFunction(std::string name, get_profile_stats_fn fn) : GetProfileFunctor(name), fn(fn) { } diff --git a/src/protocols/layer.cc b/src/protocols/layer.cc index 2fc572575..6715d23cb 100644 --- a/src/protocols/layer.cc +++ b/src/protocols/layer.cc @@ -156,7 +156,7 @@ const ip::IP6Frag* get_inner_ip6_frag(const Packet* const pkt) return reinterpret_cast(lyr->start); // Only check until current ip6h header - if (lyr->start == (const uint8_t* const)ip6h) + if (lyr->start == (const uint8_t*)ip6h) return nullptr; lyr--; diff --git a/src/protocols/tcp_options.cc b/src/protocols/tcp_options.cc index 7fa6c9dd1..4f87394de 100644 --- a/src/protocols/tcp_options.cc +++ b/src/protocols/tcp_options.cc @@ -33,7 +33,7 @@ const TcpOption& TcpOptIteratorIter::operator*() const TcpOptIterator::TcpOptIterator(const TCPHdr* const tcp_header, const Packet* const p) { - const uint8_t* const hdr = (const uint8_t* const)tcp_header; + const uint8_t* const hdr = (const uint8_t*)tcp_header; start_ptr = hdr + TCP_MIN_HEADER_LEN; end_ptr = start_ptr; // == begin() @@ -54,7 +54,7 @@ TcpOptIterator::TcpOptIterator(const TCPHdr* const tcp_header, const Packet* con TcpOptIterator::TcpOptIterator(const TCPHdr* const tcp_header, const uint32_t valid_hdr_len) { - const uint8_t* const hdr = (const uint8_t* const)tcp_header; + const uint8_t* const hdr = (const uint8_t*)tcp_header; start_ptr = hdr + TCP_MIN_HEADER_LEN; if (valid_hdr_len < TCP_MIN_HEADER_LEN) diff --git a/src/service_inspectors/ftp_telnet/ftp_print.cc b/src/service_inspectors/ftp_telnet/ftp_print.cc index 23e3197e3..798a7b4ec 100644 --- a/src/service_inspectors/ftp_telnet/ftp_print.cc +++ b/src/service_inspectors/ftp_telnet/ftp_print.cc @@ -214,7 +214,7 @@ int PrintFTPClientConf(FTP_CLIENT_PROTO_CONF* ClientConf) if (((FTPBounce->ip.family == AF_INET) && (bits != 32)) || ((FTPBounce->ip.family == AF_INET6) && (bits != 128))) { - snprintf(bits_str, sizeof(bits_str), "/%u", bits); + snprintf(bits_str, sizeof(bits_str), "/%hhu", bits); } if (FTPBounce->porthi) { @@ -265,7 +265,7 @@ int PrintFTPServerConf(FTP_SERVER_PROTO_CONF* ServerConf) while (FTPCmd != NULL) { memset(buf, 0, BUF_SIZE+1); - snprintf(buf, BUF_SIZE, " %s { %d ", + snprintf(buf, BUF_SIZE, " %s { %u ", FTPCmd->cmd_name, FTPCmd->max_param_len); #ifdef PRINT_DEFAULT_CONFIGS if (FTPCmd->data_chan_cmd) diff --git a/src/service_inspectors/http_inspect/hi_server.cc b/src/service_inspectors/http_inspect/hi_server.cc index 92b263d45..9e4be2a88 100644 --- a/src/service_inspectors/http_inspect/hi_server.cc +++ b/src/service_inspectors/http_inspect/hi_server.cc @@ -243,10 +243,6 @@ static int IsHttpServerData(HI_SESSION* session, Packet* p, HttpSessionData* sd) return HI_SUCCESS; } } - else - { - return HI_SUCCESS; - } return HI_SUCCESS; } diff --git a/src/sfrt/sfrt_dir.cc b/src/sfrt/sfrt_dir.cc index 5e88c0a80..721ea14d4 100644 --- a/src/sfrt/sfrt_dir.cc +++ b/src/sfrt/sfrt_dir.cc @@ -658,7 +658,7 @@ static void _sub_table_print(dir_sub_table_t* sub, uint32_t level, dir_table_t* for (index=0; index < sub->num_entries; index++) { if (sub->lengths[index] || sub->entries[index]) - printf("%sIndex: %d, Length: %d, dataIndex: %d\n", label, index, sub->lengths[index], + printf("%sIndex: %d, Length: %d, dataIndex: %u\n", label, index, sub->lengths[index], (uint32_t)sub->entries[index]); if ( !sub->lengths[index] && sub->entries[index] ) diff --git a/src/stream/ip/ip_defrag.cc b/src/stream/ip/ip_defrag.cc index 04cd5b335..e4b84bed8 100644 --- a/src/stream/ip/ip_defrag.cc +++ b/src/stream/ip/ip_defrag.cc @@ -870,7 +870,7 @@ static void FragRebuild(FragTracker* ft, Packet* p) if ((lyr.prot_id == ETHERTYPE_IPV6) || (lyr.prot_id == IPPROTO_ID_IPV6)) { ip::IP6Hdr* const rawHdr = - const_cast(dpkt->ptrs.ip_api.get_ip6h()); + const_cast(dpkt->ptrs.ip_api.get_ip6h()); rawHdr->ip6_next = ft->protocol; } else diff --git a/src/stream/tcp/tcp_reassembler.cc b/src/stream/tcp/tcp_reassembler.cc index 74cbdcff1..294da31df 100644 --- a/src/stream/tcp/tcp_reassembler.cc +++ b/src/stream/tcp/tcp_reassembler.cc @@ -78,7 +78,7 @@ void TcpReassembler::trace_segments(void) else if (SEQ_GT(sx, tsn->seq)) fprintf(stdout, " -%u", sx - tsn->seq); - fprintf(stdout, " %u", tsn->payload_size); + fprintf(stdout, " %hu", tsn->payload_size); segs++; bytes += tsn->payload_size; diff --git a/src/target_based/sftarget_reader.cc b/src/target_based/sftarget_reader.cc index 8f59d8909..e52c679f3 100644 --- a/src/target_based/sftarget_reader.cc +++ b/src/target_based/sftarget_reader.cc @@ -269,7 +269,7 @@ int SFAT_AddHostEntryToMap(HostAttributeEntry* host) { ParseWarning(WARN_HOSTS, "AttributeTable insertion failed: %d Insufficient " - "space in attribute table, only configured to store %d hosts\n", + "space in attribute table, only configured to store %u hosts\n", ret, SnortConfig::get_max_attribute_hosts()); sfat_insufficient_space_logged = true; } diff --git a/src/utils/bitop.h b/src/utils/bitop.h index 98b1dad51..b2afdb40d 100644 --- a/src/utils/bitop.h +++ b/src/utils/bitop.h @@ -65,6 +65,9 @@ inline BitOp::BitOp(size_t len) : inline BitOp::~BitOp() { delete[] bit_buf; } +inline uint8_t BitOp::mask(size_t bit) const +{ return (uint8_t)(0x80 >> (bit & 7)); } + // FIXIT-L J ops that don't need to be inlined can probably be but into a .cc file // Reset the bit buffer so that it can be reused inline void BitOp::reset() @@ -94,9 +97,6 @@ inline void BitOp::clear(unsigned int bit) inline size_t BitOp::size() const { return buf_size << 3; } -inline uint8_t BitOp::mask(size_t bit) const -{ return (uint8_t)(0x80 >> (bit & 7)); } - inline size_t BitOp::get_buf_size() const { return buf_size; } diff --git a/src/utils/dnet_header.h b/src/utils/dnet_header.h index 1e159904e..f2766ffdf 100644 --- a/src/utils/dnet_header.h +++ b/src/utils/dnet_header.h @@ -33,7 +33,7 @@ #pragma clang diagnostic ignored "-Wflexible-array-extensions" #endif -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #endif @@ -48,7 +48,7 @@ #pragma clang diagnostic pop #endif -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) #pragma GCC diagnostic pop #endif diff --git a/src/utils/util_jsnorm.cc b/src/utils/util_jsnorm.cc index 5667105ab..4d6bf552f 100644 --- a/src/utils/util_jsnorm.cc +++ b/src/utils/util_jsnorm.cc @@ -370,7 +370,7 @@ static const JSNorm javascript_norm[] = { Z6+ 0, ANY, Z0+ 0, Z0+ 0, ACT_NOP } }; -void UnescapeDecode(char*, uint16_t, char**, char**, uint16_t*, JSState*, uint8_t*); +static void UnescapeDecode(char*, uint16_t, char**, char**, uint16_t*, JSState*, uint8_t*); void InitJSNormLookupTable(void) { @@ -1027,7 +1027,7 @@ static int Unescape_scan_fsm(UnescapeState* s, int c, JSState* js) return(Unescape_exec(s, (ActionUnsc)m->action, c, js)); } -void UnescapeDecode(char* src, uint16_t srclen, char** ptr, char** dst, uint16_t* bytes_copied, +static void UnescapeDecode(char* src, uint16_t srclen, char** ptr, char** dst, uint16_t* bytes_copied, JSState* js, uint8_t* iis_unicode_map) { int iRet; diff --git a/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc b/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc index 060a04cc5..38d3931fc 100644 --- a/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc +++ b/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc @@ -54,7 +54,7 @@ private: length(command_default_len) { } }; - const static int command_default_len = -1; + static const int command_default_len = -1; static int ftpsever_binding_id; std::vector commands; diff --git a/tools/snort2lua/preprocessor_states/pps_smtp.cc b/tools/snort2lua/preprocessor_states/pps_smtp.cc index 1801f4a75..817ebf29a 100644 --- a/tools/snort2lua/preprocessor_states/pps_smtp.cc +++ b/tools/snort2lua/preprocessor_states/pps_smtp.cc @@ -50,7 +50,7 @@ private: length(command_default_len) { } }; - const static int command_default_len = -1; + static const int command_default_len = -1; std::vector commands; bool parse_alt_max_cmd(std::istringstream& data_stream); diff --git a/tools/u2boat/u2boat.cc b/tools/u2boat/u2boat.cc index 906a31a87..f28d8ebde 100644 --- a/tools/u2boat/u2boat.cc +++ b/tools/u2boat/u2boat.cc @@ -224,7 +224,7 @@ static int GetRecord(FILE* input, u2record* rec) items_read = fread(rec->data, sizeof(uint8_t), rec->length, input); if (items_read != rec->length) { - fprintf(stderr, "Error: incomplete record. %d of %u bytes read.\n", + fprintf(stderr, "Error: incomplete record. %u of %u bytes read.\n", items_read, rec->length); return FAILURE; } diff --git a/tools/u2spewfoo/u2spewfoo.cc b/tools/u2spewfoo/u2spewfoo.cc index 44362edee..6f5e07ec9 100644 --- a/tools/u2spewfoo/u2spewfoo.cc +++ b/tools/u2spewfoo/u2spewfoo.cc @@ -319,7 +319,7 @@ static void event_dump(u2record* record) "\tsensor id: %u\tevent id: %u\tevent second: %u\tevent microsecond: %u\n" "\tsig id: %u\tgen id: %u\trevision: %u\t classification: %u\n" "\tpriority: %u\tip source: %u.%u.%u.%u\tip destination: %u.%u.%u.%u\n" - "\tsrc port: %u\tdest port: %u\tprotocol: %u\timpact_flag: %u\tblocked: %u\n", + "\tsrc port: %hu\tdest port: %hu\tprotocol: %hhu\timpact_flag: %hhu\tblocked: %hhu\n", event.sensor_id, event.event_id, event.event_second, event.event_microsecond, event.signature_id, event.generator_id, @@ -370,7 +370,7 @@ static void event6_dump(u2record* record) inet_ntop(AF_INET6, &event.ip_destination, ip6buf, INET6_ADDRSTRLEN); printf("ip destination: %s\n" - "\tsrc port: %u\tdest port: %u\tprotocol: %u\timpact_flag: %u\tblocked: %u\n", + "\tsrc port: %hu\tdest port: %hu\tprotocol: %hhu\timpact_flag: %hhu\tblocked: %hhu\n", ip6buf, event.sport_itype, event.dport_icode, event.protocol, event.impact_flag, event.blocked); @@ -412,8 +412,8 @@ static void event2_dump(u2record* record) "\tsensor id: %u\tevent id: %u\tevent second: %u\tevent microsecond: %u\n" "\tsig id: %u\tgen id: %u\trevision: %u\t classification: %u\n" "\tpriority: %u\tip source: %u.%u.%u.%u\tip destination: %u.%u.%u.%u\n" - "\tsrc port: %u\tdest port: %u\tprotocol: %u\timpact_flag: %u\tblocked: %u\n" - "\tmpls label: %u\tvland id: %u\tpolicy id: %u\n", + "\tsrc port: %hu\tdest port: %hu\tprotocol: %hhu\timpact_flag: %hhu\tblocked: %hhu\n" + "\tmpls label: %u\tvland id: %hu\tpolicy id: %hu\n", event.sensor_id, event.event_id, event.event_second, event.event_microsecond, event.signature_id, event.generator_id, @@ -473,8 +473,8 @@ static void event2_6_dump(u2record* record) inet_ntop(AF_INET6, &event.ip_destination, ip6buf, INET6_ADDRSTRLEN); printf("ip destination: %s\n" - "\tsrc port: %u\tdest port: %u\tprotocol: %u\timpact_flag: %u\tblocked: %u\n" - "\tmpls label: %u\tvland id: %u\tpolicy id: %u\n", + "\tsrc port: %hu\tdest port: %hu\tprotocol: %hhu\timpact_flag: %hhu\tblocked: %hhu\n" + "\tmpls label: %u\tvland id: %hu\tpolicy id: %hu\n", ip6buf, event.sport_itype, event.dport_icode, event.protocol, event.impact_flag, event.blocked,