]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
ICC remark cleanups.
authorMichael Altizer <mialtize@cisco.com>
Fri, 1 Apr 2016 18:39:01 +0000 (14:39 -0400)
committerMichael Altizer <mialtize@cisco.com>
Fri, 1 Apr 2016 19:15:24 +0000 (15:15 -0400)
54 files changed:
src/codecs/ip/cd_auth.cc
src/codecs/ip/cd_pgm.cc
src/codecs/ip/cd_tcp.cc
src/codecs/ip/checksum.h
src/codecs/link/cd_ppp_encap.cc
src/detection/detection_options.cc
src/detection/fp_config.cc
src/detection/fp_create.cc
src/file_api/file_identifier.cc
src/file_api/file_lib.cc
src/filters/sfrf.cc
src/ips_options/asn1_util.cc
src/ips_options/ips_metadata.cc
src/ips_options/sd_pattern_match.cc
src/latency/packet_latency.cc
src/latency/rule_latency.cc
src/log/messages.cc
src/loggers/alert_syslog.cc
src/main/snort.cc
src/main/snort_module.cc
src/main/thread.h
src/main/thread_config.cc
src/managers/module_manager.cc
src/managers/plugin_manager.cc
src/network_inspectors/perf_monitor/flow_ip_tracker.cc
src/network_inspectors/perf_monitor/perf_tracker.cc
src/network_inspectors/port_scan/ipobj.cc
src/network_inspectors/port_scan/port_scan.cc
src/network_inspectors/reputation/reputation_parse.cc
src/packet_io/trough.cc
src/packet_io/trough.h
src/parser/parse_rule.cc
src/parser/parse_stream.cc
src/parser/parse_utils.cc
src/parser/parser.cc
src/ports/port_item.cc
src/ports/port_object.cc
src/ports/port_object2.cc
src/profiler/profiler_nodes.cc
src/protocols/layer.cc
src/protocols/tcp_options.cc
src/service_inspectors/ftp_telnet/ftp_print.cc
src/service_inspectors/http_inspect/hi_server.cc
src/sfrt/sfrt_dir.cc
src/stream/ip/ip_defrag.cc
src/stream/tcp/tcp_reassembler.cc
src/target_based/sftarget_reader.cc
src/utils/bitop.h
src/utils/dnet_header.h
src/utils/util_jsnorm.cc
tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc
tools/snort2lua/preprocessor_states/pps_smtp.cc
tools/u2boat/u2boat.cc
tools/u2spewfoo/u2spewfoo.cc

index af84794b0d93db2b9ff04fb9b08742c15b9dddff..595312196d4645d323fd8404eed6df6c5b8547e7 100644 (file)
@@ -83,7 +83,7 @@ void AuthCodec::get_protocol_ids(std::vector<uint16_t>& v)
 
 bool AuthCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
 {
-    const AuthHdr* const ah = reinterpret_cast<const AuthHdr* const>(raw.data);
+    const AuthHdr* const ah = reinterpret_cast<const AuthHdr*>(raw.data);
 
     if (raw.len < MIN_AUTH_LEN)
     {
index de1f503df4a30371aa90aab4a0b2ca498c1495c9..7eedf583ff282446861a68ece65e9c3f0ef7ebd9 100644 (file)
@@ -105,7 +105,7 @@ static inline int pgm_nak_detect(const RawData& raw)
     }
 
     const PgmHeader* const header =
-        reinterpret_cast<const PgmHeader* const>(raw.data);
+        reinterpret_cast<const PgmHeader*>(raw.data);
 
     if (8 != header->type)
         return PGM_NAK_ERR;
index 7d4c1bc006b15d15515d58ac7b721d7677e697c1..80bf8cd71793d21154d4be273ece6d5f7b8ea0fb 100644 (file)
@@ -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<const uint8_t* const>(opt);
+    const uint8_t* const opt_ptr = reinterpret_cast<const uint8_t*>(opt);
 
     if (expected_len > 1)
     {
index 1a9d9ad862b652eedfee9fbcd6f1d52a1503bcf7..2b0071c0c9b205c6f9cbfd5c2aa2988422f925dd 100644 (file)
@@ -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
-        <const PsuedoheaderUnion* const>(ph4);
+        <const PsuedoheaderUnion*>(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
-        <const Psuedoheader6Union* const>(ph6);
+        <const Psuedoheader6Union*>(ph6);
     const uint16_t* const h = ph6_u->ph6_arr;
 
     /* PseudoHeader must have 36 bytes */
index b2eac2a8b8e2ab61290f376aec73a6d3873428cb..c6723a9e224a21b2eda9a7a6c163744575eda455 100644 (file)
@@ -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<uint16_t>& v)
index c4ef39c06e5ac427de785bfc4a843f50807a87a3..7a60d2247c9fb04c3c604a32ada23de71b8854b1 100644 (file)
@@ -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);
     }
index 09252396a0ad491d3e8f804b24d0371709ccec45..35d2d4df29bf0231643e04919e549981fe3b5100 100644 (file)
@@ -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;
index 21f906363131bec13aec9efa94116a23a8c74df0..65ac08b0cf0ec455cc2f9e323ee49f544da1ad88 100644 (file)
@@ -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;
index a60a2da3153cf33d17f1bfa494cfb20c1f05fde2..00a8ceb3fec087fa70da6573b14a9ec9fdef7ad3 100644 (file)
@@ -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;
     }
 
index 4bf97a189128d9afb434d4f99623ead5cd62a470..25e3db2f711ca9ce9e52078f08fccdde7b0157db 100644 (file)
@@ -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;
index c6dd700bb37713abb952ab2217501d42bfb3c26e..d3f1c7e351f583e4b62f30e02b7bdec595bb5abf 100644 (file)
@@ -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++ )
index 8903e43bdcc408f1f7a6e19baf90ad010ea8e474..27b6381b89168825a38679a526e440744294d541 100644 (file)
@@ -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++)
index 1b4da84663d3df7474305a963a0021a412c6555f..fa4fb56062a2d6135eeacd8453a288fbb279ce5a 100644 (file)
@@ -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;
 }
index 934eb05b509196ef4b793d5d2783746424137b26..878dd9b8bee9ccda03a54600020b49f0ccffcbcd 100644 (file)
@@ -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;
 
index 5f8878ca87260db575c28447d8f539e9d2e29c4a..715296918f7b3f81032696656e0d3426fab6c059 100644 (file)
@@ -182,20 +182,20 @@ inline bool Impl<Clock>::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
     {
index d24571d7a7c3d52d7361809fae534d818da64ce5..3180d0aad80e6798824285a42739e190baf4baa2 100644 (file)
@@ -279,14 +279,14 @@ inline void Impl<Clock, RuleTree>::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
     {
index a65f3d40a54c1aff421228c2c717d001591c8ac2..5c4ee38edbf66b5d3cb7571ca50dd04e4d3ca542 100644 (file)
@@ -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);
 }
index 0bef63cee7a9ca039e24eda083e62e96f2f3d441..0023b2805514dadb98f160e8bf9c400dc3dc0967 100644 (file)
@@ -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);
             }
         }
 
index 1c36ca15f27f99563249f716bffb3536bb69ec23..b661a7ad44ac31f837d88b2ffa7890d2bc38729b 100644 (file)
@@ -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());
 }
 
index e2770a2794c974ca8dc46b65e2ef6f9c37593d84..1f5c6452fb9e71ed691024287e143e25644253bd 100644 (file)
@@ -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<char>(x));
     exit(0);
 }
 
index b14797043c104a4e28517ed3cfa5f3500463ce36..ba4fe9fb09d5533d21f44ab77756dcc97a053222 100644 (file)
@@ -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
index 1ae1a733d5af59da49a0a596fe082e948c36ed04..ca43597b4173118b3b0fd03db12171ad92f66729 100644 (file)
@@ -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
index 44f196940c2dfed57eeebe48c1f1437ffc667998..4037322a3b403ff46cfc2b8fc0510d0d0893dd76 100644 (file)
@@ -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);
index 0225d37f4fa9a77baf29c55ffd7c94abccd909fc..ec1f5af179d2f3742b1f8d67b6edbe49a02df889 100644 (file)
@@ -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;
     }
index f5051547453343ae4f5336a1ee2845698e6e907f..b91e68bd4004a0073db897a37b4acd63f1d0635d 100644 (file)
@@ -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];
index 1ecabbbae14a4d221a121fcef33157d4b0f26b7e..39fe3052346bdf5049aa3d2546d1d7f3091ad14b 100644 (file)
@@ -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));
                 }
 
index 99b72a7ed4cd40448ebdfe9c33c3f1a424028194..ab454b175870f4b3531eb8117ae5d16b2ff554dc 100644 (file)
@@ -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");
         }
index b3a10231a0b4ede85fe7a8557fd744f11ac4d9e8..1a7fd794185586012b6219a510c218e5ebbfa390 100644 (file)
@@ -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), " ");
         }
index 63779da293df90a67d4ff495299a65c967790813..b7942e4d0ed770ada4408d3895eeda6ae5301577 100644 (file)
@@ -645,7 +645,7 @@ static char* GetListInfo(INFO info)
     case WHITELISTED_TRUST:
         return white_info;
     default:
-        return nullptr;
+        break;
     }
     return nullptr;
 }
index b4604e141a95b560397599a7d5d48ea0a8ff37c2..8afa43f5f5ac34499d24583cb8f754d2870f5695 100644 (file)
@@ -35,19 +35,7 @@ std::vector<std::string>::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<struct PcapReadObject> &pol, std::vector<std::string> &pcap_queue)
+int Trough::get_pcaps(std::vector<struct PcapReadObject> &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())
index 1d01749bb42d14d4da4a3d5f30a4d922105db7ee..eeb3d89b1532cf1ccd083d058eb19e2e483b8ad2 100644 (file)
@@ -65,7 +65,7 @@ private:
         std::string filter;
     };
 
-    static int get_pcaps(std::vector<struct PcapReadObject> &pol, std::vector<std::string> &pcap_queue);
+    static int get_pcaps(std::vector<struct PcapReadObject> &pol);
     static std::vector<struct PcapReadObject> pcap_object_list;
     static std::vector<std::string> pcap_queue;
     static std::vector<std::string>::const_iterator pcap_queue_iter;
index c08ef7ad30b16793078cb3bad6ff14bf736f3228..b0633303e4711923a368f612b85e33b8ceef582b 100644 (file)
@@ -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;
index 63a735b3e1e8e3c00c8e47dee4b660eff19d2ed1..abaf908211a7c21d2a9751598d1085bafba5fa01 100644 (file)
@@ -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;
index c81b0efc5820ece1778d50f3fd4dabd685c73d7a..865dd1394fca8e5d3363c04ab4a0b89dec3e4d0e 100644 (file)
@@ -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;
 }
index df33f2c707f9c3f452b6d3da102541f0cb4fd992..d7fd017ded4adbebf29147a862eb1d81b0e1fbe5 100644 (file)
@@ -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;
         }
index 1a5f2c229fb8101d5ddf84cc637e94b5a44ae333..4832e02ba12b820d8b7d2e216c61e106ded0e34e 100644 (file)
@@ -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);
 }
 
index 294abf6acde36897b85d686a16f062c3db332f13..d59ff841a3006367558f7e9899874cd4c9f14ca6 100644 (file)
@@ -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  ");
index 8a2207e0baf143039a4bfaea36eb9992efb1a069..1ff9c7c769a4713511bca3371d67bc583a0855c9 100644 (file)
@@ -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  ");
index 92d834a4fd4429f19a40e5960de4299e142725de..913255cbcdd24a42d9035f11e17b73136f375204 100644 (file)
@@ -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) { }
index 2fc572575f96b950264b3f9307cbf2cff9243fa3..6715d23cb75781232a56946dfd357f8d8e42b82a 100644 (file)
@@ -156,7 +156,7 @@ const ip::IP6Frag* get_inner_ip6_frag(const Packet* const pkt)
                 return reinterpret_cast<const ip::IP6Frag*>(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--;
index 7fa6c9dd1a30668819516f3dc869712555c53eb7..4f87394de5b1e771375956d46ce248cdf0e84db5 100644 (file)
@@ -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)
index 23e3197e30e531ff5dee84ae99d63403c638083f..798a7b4ecb762e766c6634dd163b2f5e60650ee1 100644 (file)
@@ -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)
index 92b263d45614341bbe8a6a3091831b3925e81285..9e4be2a889ed5c2882899684f5154172fc272eb8 100644 (file)
@@ -243,10 +243,6 @@ static int IsHttpServerData(HI_SESSION* session, Packet* p, HttpSessionData* sd)
             return HI_SUCCESS;
         }
     }
-    else
-    {
-        return HI_SUCCESS;
-    }
 
     return HI_SUCCESS;
 }
index 5e88c0a80628539f7279c551c7da2d96049d468b..721ea14d4416ac8c6db853b0bdfc3d97431a4c3a 100644 (file)
@@ -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] )
index 04cd5b3352e643015666d16aaf5b4d3eba3b593c..e4b84bed8d30ee3b66503515c22921ebfd55ff6a 100644 (file)
@@ -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<ip::IP6Hdr* const>(dpkt->ptrs.ip_api.get_ip6h());
+                const_cast<ip::IP6Hdr*>(dpkt->ptrs.ip_api.get_ip6h());
             rawHdr->ip6_next = ft->protocol;
         }
         else
index 74cbdcff19f3587ea63cef24730e6c2b5cb9baa9..294da31df25752936044a5172a5a61dca5e0a511 100644 (file)
@@ -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;
index 8f59d89097839733c070952a8679d4787e2da905..e52c679f3d8d4908fd7ddc622bd88e38171c9811 100644 (file)
@@ -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;
             }
index 98b1dad510dc8b60d1a8ace58e17a57bea294165..b2afdb40d66401aa44c7f5c3a217cb25bb4a4e18 100644 (file)
@@ -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; }
 
index 1e159904e50ee4d81e974505fd48106915bc44c3..f2766ffdfe3264f799ad4987d1818d84dfc1a3e1 100644 (file)
@@ -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
 
index 5667105abf8eecb371c8123cc8a36e557e95870e..4d6bf552f21f461a1e67bb2ff498324b76f17bb9 100644 (file)
@@ -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;
index 060a04cc517b9835aff3dfe368ce510e6c80e3d9..38d3931fcb4ba4ea0f230a26adfc0610d65f7c54 100644 (file)
@@ -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<Command> commands;
 
index 1801f4a75c32e9e4f65d1ec5ff119850cdaef099..817ebf29a379bdb09d99a573886e5a57ef8a3e7e 100644 (file)
@@ -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<Command> commands;
 
     bool parse_alt_max_cmd(std::istringstream& data_stream);
index 906a31a87aed7438bcbd47361c2c759b50700a1e..f28d8ebde7261d9362af045f1770e6f4c031f68c 100644 (file)
@@ -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;
     }
index 44362edee3538592ee6b91b1f21d32dcc6ebeb78..6f5e07ec9eee7f39d8c77749b72f150b0661248b 100644 (file)
@@ -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,