]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fix cppcheck analyzer warnings - bug 439
authorAnoop Saldanha <poonaatsoc@gmail.com>
Thu, 29 Mar 2012 04:39:18 +0000 (10:09 +0530)
committerVictor Julien <victor@inliniac.net>
Thu, 29 Mar 2012 11:39:28 +0000 (13:39 +0200)
src/detect-fast-pattern.c
src/util-debug.h
src/util-mem.h
src/util-mpm-b2g-cuda.c

index 4390e8e37a42df8ff7a9481e56f2048274631ae8..da68d33850a3f55e64ae18275fecae6b132b4bc8 100644 (file)
@@ -11209,8 +11209,8 @@ int DetectFastPatternTest387(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSMDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -11245,8 +11245,8 @@ int DetectFastPatternTest388(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSMDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@@ -12392,8 +12392,8 @@ int DetectFastPatternTest428(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -12428,8 +12428,8 @@ int DetectFastPatternTest429(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@@ -13576,8 +13576,8 @@ int DetectFastPatternTest469(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -13612,8 +13612,8 @@ int DetectFastPatternTest470(void)
 
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    DetectContentData *ud = sm->ctx;
     if (sm != NULL) {
+        DetectContentData *ud = sm->ctx;
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
index 8cf2a4ee9ed579ebdc23416c9cc560028d467a33..0d98d429c245daef2399a4cce5255970aa4727b7 100644 (file)
@@ -192,7 +192,7 @@ extern int sc_log_module_cleaned;
 
 
 #define SCLog(x, ...)         do {                                       \
-                                  char _sc_log_msg[SC_LOG_MAX_LOG_MSG_LEN]; \
+                                  char _sc_log_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                   char *_sc_log_temp = _sc_log_msg;      \
                                   if ( !(                                \
                                       (sc_log_global_log_level >= x) &&  \
@@ -211,7 +211,7 @@ extern int sc_log_module_cleaned;
                               } while(0)
 
 #define SCLogErr(x, err, ...) do {                                       \
-                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN]; \
+                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                   char *_sc_log_err_temp = _sc_log_err_msg; \
                                   if ( !(                                \
                                       (sc_log_global_log_level >= x) &&  \
@@ -360,7 +360,7 @@ extern int sc_log_module_cleaned;
                                                    __FUNCTION__) == SC_OK) {    \
                                       snprintf(_sc_enter_temp, (SC_LOG_MAX_LOG_MSG_LEN - \
                                                       (_sc_enter_msg - _sc_enter_temp)), \
-                                               "%s", "Entering ... >>");        \
+                                               "Entering ... >>");        \
                                       SCLogOutputBuffer(SC_LOG_DEBUG,           \
                                                         _sc_enter_msg);         \
                                   }                                             \
@@ -467,9 +467,12 @@ extern int sc_log_module_cleaned;
  */
 #define SCReturnCharPtr(x)    do {                                           \
                                   if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
-                                      SCLogDebug("Returning: %s ... <<", x); \
-                                      SCLogCheckFDFilterExit(__FUNCTION__);  \
-                                  }                                          \
+                                      if ((x) != NULL) {                    \
+                                          SCLogDebug("Returning: %s ... <<", x); \
+                                      } else {                          \
+                                          SCLogDebug("Returning: NULL ... <<"); \
+                                      } SCLogCheckFDFilterExit(__FUNCTION__); \
+                                  }                                     \
                                  return x;                                   \
                               } while(0)
 
index 6aedaa1fcf37500ba759570b1dac7a04a9eb1b58..2bcf0ed5d7176713850758a32ddf7ed0d5c40ce9 100644 (file)
@@ -65,10 +65,10 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     } \
     \
     global_mem += (a); \
-    if (print_mem_flag == 1) \
+    if (print_mem_flag == 1) {                               \
         SCLogInfo("SCMalloc return at %p of size %"PRIuMAX, \
             ptrmem, (uintmax_t)(a)); \
-    \
+    }                                \
     (void*)ptrmem; \
 })
 
@@ -88,10 +88,10 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     } \
     \
     global_mem += (a); \
-    if (print_mem_flag == 1) \
+    if (print_mem_flag == 1) {                                         \
         SCLogInfo("SCRealloc return at %p (old:%p) of size %"PRIuMAX, \
             ptrmem, (x), (uintmax_t)(a)); \
-    \
+    }                                     \
     (void*)ptrmem; \
 })
 
@@ -111,10 +111,10 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     } \
     \
     global_mem += (a)*(nm); \
-    if (print_mem_flag == 1) \
+    if (print_mem_flag == 1) {                                          \
         SCLogInfo("SCCalloc return at %p of size %"PRIuMAX" (nm) %"PRIuMAX, \
             ptrmem, (uintmax_t)(a), (uintmax_t)(nm)); \
-    \
+    }                                                 \
     (void*)ptrmem; \
 })
 
@@ -135,17 +135,18 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     } \
     \
     global_mem += len; \
-    if (print_mem_flag == 1) \
+    if (print_mem_flag == 1) {                              \
         SCLogInfo("SCStrdup return at %p of size %"PRIuMAX, \
             ptrmem, (uintmax_t)len); \
-    \
+    }                                \
     (void*)ptrmem; \
 })
 
 #define SCFree(a) ({ \
     extern uint8_t print_mem_flag; \
-    if (print_mem_flag == 1) \
+    if (print_mem_flag == 1) {          \
         SCLogInfo("SCFree at %p", (a)); \
+    }                                   \
     free((a)); \
 })
 
index 3ef10d27fc6249f83ca4e6c828408324280fe30f..37756ae3af0dc256f5c3da78b012e23d5f27e69c 100644 (file)
@@ -1689,8 +1689,11 @@ TmEcode B2gCudaMpmDispThreadInit(ThreadVars *tv, void *initdata, void **data)
     MpmCudaConf *profile = NULL;
     SCCudaHlModuleData *module_data = (SCCudaHlModuleData *)initdata;
 
-    if (PatternMatchDefaultMatcher() != MPM_B2G_CUDA)
-        return TM_ECODE_OK;
+    if (PatternMatchDefaultMatcher() != MPM_B2G_CUDA) {
+        SCLogError(SC_ERR_B2G_CUDA_ERROR, "b2g cuda mpm sees mpm that is "
+                   "not b2g_cuda");
+        exit(EXIT_FAILURE);
+    }
 
     if (SCCudaCtxPushCurrent(module_data->cuda_context) == -1) {
         SCLogError(SC_ERR_B2G_CUDA_ERROR, "Error pushing cuda context");