]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
fix static analysis issues
authorRuss Combs <rucombs@cisco.com>
Sun, 5 Jun 2016 00:37:06 +0000 (20:37 -0400)
committerRuss Combs <rucombs@cisco.com>
Sun, 5 Jun 2016 00:37:06 +0000 (20:37 -0400)
src/flow/flow_cache.cc
src/protocols/packet.h
src/sfip/sfip_test.cc

index ab8b55fa9b490872804d193105c78cf54f95675e..5d977a243e5185013ac8d58c8a901fb4061960a5 100644 (file)
@@ -247,8 +247,10 @@ unsigned FlowCache::prune_excess(const Flow* save_me)
         auto flow = static_cast<Flow*>(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;
 
index 81a8da0c37c402596efd934e01d7a82771f535af..34ba1d4a3f9e682c1c5348cd0fe0bce8ca7ecea6 100644 (file)
@@ -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
index d7f8c385b49a28430435973e55cfc46959e15b47..51d613a333e94788254e2c5c774d51f596d62a35 100644 (file)
@@ -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;