From: Russ Combs Date: Sun, 5 Jun 2016 00:37:06 +0000 (-0400) Subject: fix static analysis issues X-Git-Tag: 3.0.0-233~379 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43a60e0;p=thirdparty%2Fsnort3.git fix static analysis issues --- diff --git a/src/flow/flow_cache.cc b/src/flow/flow_cache.cc index ab8b55fa9..5d977a243 100644 --- a/src/flow/flow_cache.cc +++ b/src/flow/flow_cache.cc @@ -247,8 +247,10 @@ unsigned FlowCache::prune_excess(const Flow* save_me) auto flow = static_cast(hash_table->first()); assert(flow); // holds true because hash_table->get_count() > 0 - if ( flow == save_me or flow->was_blocked() ) + if ( (save_me and flow == save_me) or flow->was_blocked() ) { + // check for non-null save_me above to silence analyzer + // "called C++ object pointer is null" here if ( flow->was_blocked() ) ++blocks; diff --git a/src/protocols/packet.h b/src/protocols/packet.h index 81a8da0c3..34ba1d4a3 100644 --- a/src/protocols/packet.h +++ b/src/protocols/packet.h @@ -305,7 +305,6 @@ inline uint32_t extract_32bits(const uint8_t* p) memmove(&tmp, p, sizeof(uint32_t)); return ntohl(tmp); } - #endif #else @@ -333,7 +332,7 @@ inline uint16_t alignedNtohs(const uint16_t* ptr) return ((value & 0xff00) >> 8) | ((value & 0x00ff) << 8); #else return value; -#endif /* WORDS_BIGENDIAN */ +#endif } inline uint32_t alignedNtohl(const uint32_t* ptr) @@ -348,14 +347,14 @@ inline uint32_t alignedNtohl(const uint32_t* ptr) *((uint8_t*)ptr + 2) << 8 | *((uint8_t*)ptr + 3); #else value = *ptr; -#endif /* WORDS_MUSTALIGN */ +#endif #ifdef WORDS_BIGENDIAN return ((value & 0xff000000) >> 24) | ((value & 0x00ff0000) >> 8) | ((value & 0x0000ff00) << 8) | ((value & 0x000000ff) << 24); #else return value; -#endif /* WORDS_BIGENDIAN */ +#endif } inline uint64_t alignedNtohq(const uint64_t* ptr) @@ -372,7 +371,7 @@ inline uint64_t alignedNtohq(const uint64_t* ptr) *((uint8_t*)ptr + 6) << 8 | *((uint8_t*)ptr + 7); #else value = *ptr; -#endif /* WORDS_MUSTALIGN */ +#endif #ifdef WORDS_BIGENDIAN return ((value & 0xff00000000000000) >> 56) | ((value & 0x00ff000000000000) >> 40) | @@ -381,7 +380,7 @@ inline uint64_t alignedNtohq(const uint64_t* ptr) ((value & 0x000000000000ff00) << 40) | ((value & 0x00000000000000ff) << 56); #else return value; -#endif /* WORDS_BIGENDIAN */ +#endif } #endif diff --git a/src/sfip/sfip_test.cc b/src/sfip/sfip_test.cc index d7f8c385b..51d613a33 100644 --- a/src/sfip/sfip_test.cc +++ b/src/sfip/sfip_test.cc @@ -234,6 +234,8 @@ static FuncTest ftests[] = static int RunFunc(const char* func, const char* arg1, const char* arg2) { sfip_t ip1, ip2; + sfip_clear(ip1); + sfip_clear(ip2); int result = SFIP_FAILURE; if ( arg1 ) @@ -251,7 +253,7 @@ static int RunFunc(const char* func, const char* arg1, const char* arg2) result = strcmp(buf1, buf2) ? SFIP_FAILURE : SFIP_SUCCESS; } - else if ( !strcmp(func, "sfip_size") ) + else if ( !strcmp(func, "sfip_size") and arg2 ) { result = sfip_size(&ip1); result = (result == atoi(arg2)) ? SFIP_SUCCESS : SFIP_FAILURE;