]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
fixing additional warning
authorJosh <jrosenba@cisco.com>
Tue, 22 Jul 2014 21:51:51 +0000 (17:51 -0400)
committerJosh <jrosenba@cisco.com>
Tue, 22 Jul 2014 21:51:51 +0000 (17:51 -0400)
src/codecs/checksum.cc
src/codecs/checksum.h
src/codecs/template.cc
src/managers/packet_manager.cc
src/protocols/ipv4.h
tools/snort2lua/option_parser.h

index 51d8838205abb3f8ab50046ba808002101beaea9..ce26385f9bde5938705e9adfe3485fdd9a00dda4 100644 (file)
 namespace checksum
 {
 
-uint16_t cksum_add(const uint16_t *buf, size_t len, uint32_t cksum)
+uint16_t cksum_add(const uint16_t *buf, std::size_t len, uint32_t cksum)
 {
     uint16_t *sp = (uint16_t *)buf;
-    int n, sn;
+    std::size_t n, sn;
 
     if (len > 1 )
     {
@@ -110,7 +110,8 @@ uint16_t cksum_add(const uint16_t *buf, size_t len, uint32_t cksum)
 }
 
 
-static inline void add_ipv4_pseudoheader(const uint16_t *h, uint32_t &cksum)
+static inline void add_ipv4_pseudoheader(const uint16_t *h,
+                                         uint32_t &cksum)
 {
     /* ipv4 pseudo header must have 12 bytes */
     cksum += h[0];
@@ -122,7 +123,8 @@ static inline void add_ipv4_pseudoheader(const uint16_t *h, uint32_t &cksum)
 }
 
 
-static inline void add_ipv6_pseudoheader(const uint16_t *h, uint32_t &cksum)
+static inline void add_ipv6_pseudoheader(const uint16_t *h,
+                                         uint32_t &cksum)
 {
    /* PseudoHeader must have 36 bytes */
    cksum += h[0];
@@ -147,7 +149,7 @@ static inline void add_ipv6_pseudoheader(const uint16_t *h, uint32_t &cksum)
 
 
 static inline void add_tcp_header(const uint16_t* &d,
-                                    size_t &len,
+                                    std::size_t &len,
                                     uint32_t &cksum)
 {
     /* TCP hdr must have 20 hdr bytes */
@@ -179,8 +181,8 @@ static inline void add_udp_header(const uint16_t* &d,
 }
 
 static inline void add_ip_header(const uint16_t* &d,
-                                    size_t &len,
-                                    uint32_t &cksum)
+                                 std::size_t &len,
+                                 uint32_t &cksum)
 {
     /* IP must be >= 20 bytes */
     cksum += d[0];
@@ -198,7 +200,9 @@ static inline void add_ip_header(const uint16_t* &d,
 }
 
  
-uint16_t icmp_cksum(const uint16_t *buf, size_t len, Pseudoheader6* ph)
+uint16_t icmp_cksum(const uint16_t *buf,
+                    std::size_t len,
+                    Pseudoheader6* ph)
 {
     uint32_t cksum = 0;
 
@@ -212,7 +216,9 @@ uint16_t icmp_cksum(const uint16_t *buf, size_t len)
 }
 
 
-uint16_t tcp_cksum(const uint16_t *h, size_t len, Pseudoheader *ph )
+uint16_t tcp_cksum(const uint16_t *h,
+                   std::size_t len,
+                   Pseudoheader *ph )
 {
     uint32_t cksum = 0;
 
@@ -222,7 +228,9 @@ uint16_t tcp_cksum(const uint16_t *h, size_t len, Pseudoheader *ph )
 }
 
 
-uint16_t tcp_cksum(const uint16_t *buf, size_t len, Pseudoheader6 *ph )
+uint16_t tcp_cksum(const uint16_t *buf,
+                   std::size_t len,
+                   Pseudoheader6 *ph )
 {
     uint32_t cksum = 0;
 
@@ -232,7 +240,9 @@ uint16_t tcp_cksum(const uint16_t *buf, size_t len, Pseudoheader6 *ph )
 }
 
 
-uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader *ph )
+uint16_t udp_cksum(const uint16_t *buf,
+                   std::size_t len,
+                   Pseudoheader *ph )
 {
     uint32_t cksum = 0;
 
@@ -242,7 +252,9 @@ uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader *ph )
 }
 
 
-uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader6 *ph )
+uint16_t udp_cksum(const uint16_t *buf,
+                   std::size_t len,
+                   Pseudoheader6 *ph )
 {
     uint32_t cksum = 0;
 
@@ -251,7 +263,7 @@ uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader6 *ph )
     return cksum_add(buf, len, cksum);
 }
 
-uint16_t ip_cksum(const uint16_t *buf, size_t len)
+uint16_t ip_cksum(const uint16_t *buf, std::size_t len)
 {
     uint32_t cksum = 0;
 
@@ -259,7 +271,7 @@ uint16_t ip_cksum(const uint16_t *buf, size_t len)
     return cksum_add(buf, len, cksum);
 }
 
-uint16_t cksum_add(const uint16_t *buf, size_t len)
+uint16_t cksum_add(const uint16_t *buf, std::size_t len)
 {
     return cksum_add(buf, len, 0);
 }
index c7303a8ba9db4ab698fa073f1055fb63b6f3aa1c..aabc3bc436afd9eabef65998879c213a27273fe1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <cstddef>
 
 
 namespace checksum
@@ -51,14 +52,14 @@ struct Pseudoheader
 };
 
 
-uint16_t cksum_add(const uint16_t *buf, size_t len);
-uint16_t tcp_cksum(const uint16_t *buf, size_t len, Pseudoheader*);
-uint16_t tcp_cksum(const uint16_t *buf, size_t len, Pseudoheader6 *ph );
-uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader*);
-uint16_t udp_cksum(const uint16_t *buf, size_t len, Pseudoheader6*);
-uint16_t icmp_cksum(const uint16_t *buf, size_t len, Pseudoheader6*);
-uint16_t icmp_cksum(const uint16_t *buf, size_t len);
-uint16_t ip_cksum(const uint16_t *buf, size_t len);
+uint16_t cksum_add(const uint16_t *buf, std::size_t len);
+uint16_t tcp_cksum(const uint16_t *buf, std::size_t len, Pseudoheader*);
+uint16_t tcp_cksum(const uint16_t *buf, std::size_t len, Pseudoheader6 *ph );
+uint16_t udp_cksum(const uint16_t *buf, std::size_t len, Pseudoheader*);
+uint16_t udp_cksum(const uint16_t *buf, std::size_t len, Pseudoheader6*);
+uint16_t icmp_cksum(const uint16_t *buf, std::size_t len, Pseudoheader6*);
+uint16_t icmp_cksum(const uint16_t *buf, std::size_t len);
+uint16_t ip_cksum(const uint16_t *buf, std::size_t len);
 
 } // namespace checksum
 
index 8dfc5911a838f677f27d66265db0731b70c5617f..8e50a456e0eaf31bf73de9889c147ee422872197 100644 (file)
@@ -70,18 +70,18 @@ struct NameHdr
 } // namespace
 
 
-void NameCodec::get_data_link_type(std::vector<int>&v)
+void NameCodec::get_data_link_type(std::vector<int>&/*v*/)
 {
 //    v.push_back(DLT_ID);
 }
 
-void NameCodec::get_protocol_ids(std::vector<uint16_t>& v)
+void NameCodec::get_protocol_ids(std::vector<uint16_t>&/*v*/)
 {
 //    v.push_back(PROTO_TYPE);
 }
 
-bool NameCodec::decode(const uint8_t *raw_pkt, const uint32_t &raw_len,
-        Packet *p, uint16_t &lyr_len, uint16_t &next_prot_id)
+bool NameCodec::decode(const uint8_t *raw_pkt, const uint32_t& /*raw_len*/,
+        Packet* /*p*/, uint16_t& lyr_len, uint16_t& next_prot_id)
 {
     // reinterpret the raw data into this codec's data format
     const NameHdr *hdr = reinterpret_cast<const NameHdr *>(raw_pkt);
@@ -120,12 +120,15 @@ bool NameCodec::encode(EncState *enc, Buffer* out, const uint8_t* raw_in)
     return true;
 }
 
-bool NameCodec::update(Packet*, Layer*, uint32_t* len)
+bool NameCodec::update(Packet*, Layer*, uint32_t* /*len*/)
 {
     return true;
 }
 
-void NameCodec::format(EncodeFlags, const Packet* p, Packet* c, Layer*)
+void NameCodec::format(EncodeFlags,
+                       const Packet* /*p*/,
+                       Packet* /*c*/,
+                       Layer* /*l*/)
 {
 }
 
index 58f3071d8977be2633069e5425885e267ab95c71..d30b04f8cefd1cc20488ad07cbbcdee940a02e15 100644 (file)
@@ -355,7 +355,7 @@ void PacketManager::thread_init(void)
                         s_protocols[grinder]->get_name(), cd->get_name(),
                         cd->get_name());
 
-                grinder = i;
+                grinder = (uint8_t)i;
             }
         }
     }
@@ -488,8 +488,8 @@ void PacketManager::decode(
         ipv6_util::CheckIPv6ExtensionOrder(p);
 
     s_stats[mapped_prot + stat_offset]++;
-    p->packet_flags &= ~PKT_ESP_LYR_PRESENT; // cleanup.  Just in case.
-    p->dsize = len;
+    p->packet_flags &= (uint32_t)~PKT_ESP_LYR_PRESENT; // cleanup just in case.
+    p->dsize = (uint16_t)len;
     p->data = pkt;
 
     PREPROC_PROFILE_END(decodePerfStats);
@@ -569,7 +569,7 @@ SO_PUBLIC int PacketManager::encode_format_with_daq_info (
 {
     int i;
     Layer* lyr;
-    size_t len;
+    int len;
     int num_layers = p->next_layer;
     DAQ_PktHdr_t* pkth = (DAQ_PktHdr_t*)c->pkth;
     uint8_t* pkt = (uint8_t*)c->pkt;
index e288119e3469a5fd2273bbd6d4edf6d7dcc71a95..0da18f8a64491af132165be7957e5b2b036b725a 100644 (file)
@@ -210,12 +210,12 @@ static inline bool is_ipv4(uint8_t ch)
 
 static inline uint8_t get_pkt_len(const IP4Hdr* p)
 {
-    return (p->ip_verhl & 0x0f) << 2;
+    return (uint8_t)((p->ip_verhl & 0x0f) << 2);
 }
 
 static inline uint8_t get_pkt_len(const IPHdr* p)
 {
-    return (p->ip_verhl & 0x0f) << 2;
+    return (uint8_t)((p->ip_verhl & 0x0f) << 2);
 }
 
 static inline uint8_t get_version(IPHdr* p)
index 27291082235916010c0d1a384b07f7a53a417b7c..77082cbd7aa3f462ab9e83a12f8a4541773a71f8 100644 (file)
@@ -534,7 +534,7 @@ public:
    */
   int index() const
   {
-    return desc == 0 ? -1 : desc->index;
+    return desc == 0 ? -1 : (int)desc->index;
   }
 
   /**
@@ -1448,7 +1448,7 @@ public:
         return false; // overflow protection: don't accept number of options that doesn't fit signed int
 
       buffer[parser.op_count] = option;
-      int idx = buffer[parser.op_count].desc->index;
+      unsigned idx = buffer[parser.op_count].desc->index;
       if (options[idx])
         options[idx].append(buffer[parser.op_count]);
       else