From: Josh Date: Tue, 22 Jul 2014 21:51:51 +0000 (-0400) Subject: fixing additional warning X-Git-Tag: 3.0.0-233~1175^2~14^2~1^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00ebcbeabfb89f65fffcab9c06c97a1eb658e523;p=thirdparty%2Fsnort3.git fixing additional warning --- diff --git a/src/codecs/checksum.cc b/src/codecs/checksum.cc index 51d883820..ce26385f9 100644 --- a/src/codecs/checksum.cc +++ b/src/codecs/checksum.cc @@ -30,10 +30,10 @@ 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); } diff --git a/src/codecs/checksum.h b/src/codecs/checksum.h index c7303a8ba..aabc3bc43 100644 --- a/src/codecs/checksum.h +++ b/src/codecs/checksum.h @@ -28,6 +28,7 @@ #include #include +#include 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 diff --git a/src/codecs/template.cc b/src/codecs/template.cc index 8dfc5911a..8e50a456e 100644 --- a/src/codecs/template.cc +++ b/src/codecs/template.cc @@ -70,18 +70,18 @@ struct NameHdr } // namespace -void NameCodec::get_data_link_type(std::vector&v) +void NameCodec::get_data_link_type(std::vector&/*v*/) { // v.push_back(DLT_ID); } -void NameCodec::get_protocol_ids(std::vector& v) +void NameCodec::get_protocol_ids(std::vector&/*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(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*/) { } diff --git a/src/managers/packet_manager.cc b/src/managers/packet_manager.cc index 58f3071d8..d30b04f8c 100644 --- a/src/managers/packet_manager.cc +++ b/src/managers/packet_manager.cc @@ -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; diff --git a/src/protocols/ipv4.h b/src/protocols/ipv4.h index e288119e3..0da18f8a6 100644 --- a/src/protocols/ipv4.h +++ b/src/protocols/ipv4.h @@ -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) diff --git a/tools/snort2lua/option_parser.h b/tools/snort2lua/option_parser.h index 272910822..77082cbd7 100644 --- a/tools/snort2lua/option_parser.h +++ b/tools/snort2lua/option_parser.h @@ -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