]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Use unlikely in malloc failure test. 604/head
authorEric Leblond <eric@regit.org>
Mon, 28 Oct 2013 10:49:23 +0000 (11:49 +0100)
committerEric Leblond <eric@regit.org>
Mon, 28 Oct 2013 10:49:23 +0000 (11:49 +0100)
This patch is a result of applying the following coccinelle
transformation to suricata sources:

  @istested@
  identifier x;
  statement S1;
  identifier func =~ "(SCMalloc|SCStrdup|SCCalloc|SCMallocAligned|SCRealloc)";
  @@

  x = func(...)
  ... when != x
  - if (x == NULL) S1
  + if (unlikely(x == NULL)) S1

24 files changed:
src/app-layer-dns-common.c
src/app-layer-htp.c
src/app-layer-parser.c
src/detect-content.c
src/detect-engine-hcbd.c
src/detect-engine-hhd.c
src/detect-engine-mpm.c
src/detect-luajit-extensions.c
src/flow-storage.c
src/host-storage.c
src/runmode-tile.c
src/source-mpipe.c
src/source-napatech.c
src/stream-tcp.c
src/util-cuda-buffer.c
src/util-cuda-handlers.c
src/util-cuda.c
src/util-magic.c
src/util-mpm-ac-tile.c
src/util-mpm.c
src/util-pool-thread.c
src/util-runmodes.c
src/util-storage.c
src/util-threshold-config.c

index 48704635cdf17063c84d98a59ea634f4b0f8a5a3..feb3db99cfa60a708bbbe61ba7d1f21b1c40cd42 100644 (file)
@@ -129,7 +129,7 @@ void DNSSetEvent(DNSState *s, uint8_t e) {
  *  \retval tx or NULL */
 DNSTransaction *DNSTransactionAlloc(const uint16_t tx_id) {
     DNSTransaction *tx = SCMalloc(sizeof(DNSTransaction));
-    if (tx == NULL)
+    if (unlikely(tx == NULL))
         return NULL;
     memset(tx, 0x00, sizeof(DNSTransaction));
 
@@ -329,7 +329,7 @@ void DNSStoreQueryInState(DNSState *dns_state, const uint8_t *fqdn, const uint16
     }
 
     DNSQueryEntry *q = SCMalloc(sizeof(DNSQueryEntry) + fqdn_len);
-    if (q == NULL)
+    if (unlikely(q == NULL))
         return;
     q->type = type;
     q->class = class;
@@ -357,7 +357,7 @@ void DNSStoreAnswerInState(DNSState *dns_state, const int rtype, const uint8_t *
     }
 
     DNSAnswerEntry *q = SCMalloc(sizeof(DNSAnswerEntry) + fqdn_len + data_len);
-    if (q == NULL)
+    if (unlikely(q == NULL))
         return;
     q->type = type;
     q->class = class;
index 5fc2a4d62ca661d1079fbdfcda9aa22a30aa73bb..894bd93d3d173faea982d3e5a237991d6183c874 100644 (file)
@@ -2002,7 +2002,7 @@ static int HTPCallbackRequestLine(htp_tx_t *tx)
         return HTP_OK;
 
     tx_ud = SCMalloc(sizeof(*tx_ud));
-    if (tx_ud == NULL) {
+    if (unlikely(tx_ud == NULL)) {
         bstr_free(request_uri_normalized);
         return HTP_OK;
     }
@@ -2047,7 +2047,7 @@ static int HTPCallbackRequestHeaderData(htp_tx_data_t *tx_data)
     HtpTxUserData *tx_ud = htp_tx_get_user_data(tx_data->tx);
     if (tx_ud == NULL) {
         tx_ud = SCMalloc(sizeof(*tx_ud));
-        if (tx_ud == NULL)
+        if (unlikely(tx_ud == NULL))
             return HTP_OK;
         memset(tx_ud, 0, sizeof(*tx_ud));
         htp_tx_set_user_data(tx_data->tx, tx_ud);
@@ -2079,7 +2079,7 @@ static int HTPCallbackResponseHeaderData(htp_tx_data_t *tx_data)
     HtpTxUserData *tx_ud = htp_tx_get_user_data(tx_data->tx);
     if (tx_ud == NULL) {
         tx_ud = SCMalloc(sizeof(*tx_ud));
-        if (tx_ud == NULL)
+        if (unlikely(tx_ud == NULL))
             return HTP_OK;
         memset(tx_ud, 0, sizeof(*tx_ud));
         htp_tx_set_user_data(tx_data->tx, tx_ud);
@@ -4966,7 +4966,7 @@ libhtp:\n\
     HTPConfigure();
 
     httpbuf = SCMalloc(len);
-    if (httpbuf == NULL)
+    if (unlikely(httpbuf == NULL))
         goto end;
     memset(httpbuf, 0x00, len);
 
index 2a0e50b1ee2686e804d67765f156342d985574c4..7dc15e4663a1e39b0ea6ca6d2e411897640aade1 100644 (file)
@@ -1777,7 +1777,7 @@ static uint32_t AppLayerProbingParserGetMask(uint16_t al_proto)
 static inline AppLayerProbingParserElement *AllocAppLayerProbingParserElement(void)
 {
     AppLayerProbingParserElement *p = SCMalloc(sizeof(AppLayerProbingParserElement));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(AppLayerProbingParserElement));
@@ -1796,7 +1796,7 @@ static inline void DeAllocAppLayerProbingParserElement(AppLayerProbingParserElem
 static inline AppLayerProbingParserPort *AllocAppLayerProbingParserPort(void)
 {
     AppLayerProbingParserPort *p = SCMalloc(sizeof(AppLayerProbingParserPort));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(AppLayerProbingParserPort));
@@ -1830,7 +1830,7 @@ static inline void DeAllocAppLayerProbingParserPort(AppLayerProbingParserPort *p
 static inline AppLayerProbingParser *AllocAppLayerProbingParser(void)
 {
     AppLayerProbingParser *p = SCMalloc(sizeof(AppLayerProbingParser));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(AppLayerProbingParser));
index c124c44ff184f714d017d507797dce1a1ee4c6e4..25817eda25360bb0ffcd2429603b990a03678c01 100644 (file)
@@ -2079,7 +2079,7 @@ int DetectContentParseTest41(void)
     DetectContentData *cd = NULL;
     int patlen = 257;
     char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
-    if (teststring == NULL)
+    if (unlikely(teststring == NULL))
         return 0;
     int idx = 0;
     teststring[idx++] = '\"';
@@ -2106,7 +2106,7 @@ int DetectContentParseTest42(void)
     DetectContentData *cd = NULL;
     int patlen = 258;
     char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
-    if (teststring == NULL)
+    if (unlikely(teststring == NULL))
         return 0;
     int idx = 0;
     teststring[idx++] = '\"';
@@ -2133,7 +2133,7 @@ int DetectContentParseTest43(void)
     DetectContentData *cd = NULL;
     int patlen = 260;
     char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
-    if (teststring == NULL)
+    if (unlikely(teststring == NULL))
         return 0;
     int idx = 0;
     teststring[idx++] = '\"';
@@ -2164,7 +2164,7 @@ int DetectContentParseTest44(void)
     DetectContentData *cd = NULL;
     int patlen = 261;
     char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
-    if (teststring == NULL)
+    if (unlikely(teststring == NULL))
         return 0;
     int idx = 0;
     teststring[idx++] = '\"';
index 86857b8544e44e8b32bf6caefffee46eee10236c..0f49d2e6bf83dbcd7ccfccb6b783f3a6593ef01b 100644 (file)
@@ -3502,7 +3502,7 @@ static int DetectEngineHttpClientBodyTest29(void)
 
 #define TOTAL_REQUESTS 45
     uint8_t *http_buf = SCMalloc(TOTAL_REQUESTS * strlen(request_buffer));
-    if (http_buf == NULL)
+    if (unlikely(http_buf == NULL))
         goto end;
     for (int i = 0; i < TOTAL_REQUESTS; i++) {
         memcpy(http_buf + i * strlen(request_buffer), request_buffer,
index 973854f8c8d5d901119f50b0134251f2edf2fd6a..8bdc6acedb4a4e076ceea7c7ff07e7c4a1d22e5f 100644 (file)
@@ -157,7 +157,7 @@ static uint8_t *DetectEngineHHDGetBufferForTX(htp_tx_t *tx, uint64_t tx_id,
 
         /* the extra 4 bytes if for ": " and "\r\n" */
         headers_buffer = SCRealloc(headers_buffer, headers_buffer_len + size1 + size2 + 4);
-        if (headers_buffer == NULL) {
+        if (unlikely(headers_buffer == NULL)) {
             det_ctx->hhd_buffers[index] = NULL;
             det_ctx->hhd_buffers_len[index] = 0;
             goto end;
index dfbc947428b640db0b3359ecc6d04a83f32941bd..431e58e346288edeef3d094605c639285debb1be 100644 (file)
@@ -2838,7 +2838,7 @@ int DetectSetFastPatternAndItsId(DetectEngineCtx *de_ctx)
 
     /* array hash buffer - i've run out of ideas to name it */
     uint8_t *ahb = SCMalloc(sizeof(uint8_t) * (struct_total_size + content_total_size));
-    if (ahb == NULL)
+    if (unlikely(ahb == NULL))
         return -1;
 
     uint8_t *content = NULL;
index ffa708d62481c2fab3d8ddff2dbab7ce5e3b80fa..0519da5bd11c29219e1d460c3364570cd31cbb83 100644 (file)
@@ -250,7 +250,7 @@ int LuajitSetFlowvar(lua_State *luastate) {
     }
 
     buffer = SCMalloc(len+1);
-    if (buffer == NULL) {
+    if (unlikely(buffer == NULL)) {
         lua_pushnil(luastate);
         lua_pushstring(luastate, "out of memory");
         return 2;
index d1a3a9bc5f0449e0b2dfcd06941228408cdbf66e..ea2f1dd7c81da0833b4bdffcebc7bfc6ec749321 100644 (file)
@@ -174,7 +174,7 @@ static int FlowStorageTest02(void) {
     }
 
     void *ptr1a = SCMalloc(128);
-    if (ptr1a == NULL) {
+    if (unlikely(ptr1a == NULL)) {
         goto error;
     }
     FlowSetStorageById(f, id1, ptr1a);
@@ -230,13 +230,13 @@ static int FlowStorageTest03(void) {
     }
 
     void *ptr1a = SCMalloc(128);
-    if (ptr1a == NULL) {
+    if (unlikely(ptr1a == NULL)) {
         goto error;
     }
     FlowSetStorageById(f, id1, ptr1a);
 
     void *ptr2a = SCMalloc(256);
-    if (ptr2a == NULL) {
+    if (unlikely(ptr2a == NULL)) {
         goto error;
     }
     FlowSetStorageById(f, id2, ptr2a);
index 13df14e4582137756abfaa0c7cfa6ba9c3171825..a895538c4c3216cd00226671f85965fbce7d9dd6 100644 (file)
@@ -173,7 +173,7 @@ static int HostStorageTest02(void) {
     }
 
     void *ptr1a = SCMalloc(128);
-    if (ptr1a == NULL) {
+    if (unlikely(ptr1a == NULL)) {
         goto error;
     }
     HostSetStorageById(h, id1, ptr1a);
@@ -228,13 +228,13 @@ static int HostStorageTest03(void) {
     }
 
     void *ptr1a = SCMalloc(128);
-    if (ptr1a == NULL) {
+    if (unlikely(ptr1a == NULL)) {
         goto error;
     }
     HostSetStorageById(h, id1, ptr1a);
 
     void *ptr2a = SCMalloc(256);
-    if (ptr2a == NULL) {
+    if (unlikely(ptr2a == NULL)) {
         goto error;
     }
     HostSetStorageById(h, id2, ptr2a);
index 99c22754754d0cffa968093705afe9c4ef6d8e8c..5fadb4aaa8f5dd127cde7ec35f28d548ef9045ad 100644 (file)
@@ -81,7 +81,7 @@ void *ParseMpipeConfig(const char *iface)
     char *copymodestr;
     char *out_iface = NULL;
 
-    if (aconf == NULL) {
+    if (unlikely(aconf == NULL)) {
         return NULL;
     }
 
@@ -202,14 +202,14 @@ int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx)
         } else {
             mpipe_devc = SCStrdup(mpipe_dev);
         }
-        if (mpipe_devc == NULL) {
+        if (unlikely(mpipe_devc == NULL)) {
             printf("ERROR: SCStrdup failed for ReceiveMpipe\n");
             exit(EXIT_FAILURE);
         }
 
         snprintf(tname, sizeof(tname), "Worker%d", pipe+1);
         thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             printf("ERROR: SCStrdup failed for ReceiveMpipe\n");
             exit(EXIT_FAILURE);
         }
index 14af9bfdbfb33ddc28199150a11e952e8c7125d0..08de39ff4c57df0892ee6636fad69448d4b54c33 100644 (file)
@@ -787,7 +787,7 @@ TmEcode ReceiveMpipeThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     MpipeThreadVars *ptv = SCMalloc(sizeof(MpipeThreadVars));
-    if (ptv == NULL)
+    if (unlikely(ptv == NULL))
         SCReturnInt(TM_ECODE_FAILED);
 
     memset(ptv, 0, sizeof(MpipeThreadVars));
@@ -863,7 +863,7 @@ TmEcode ReceiveMpipeThreadInit(ThreadVars *tv, void *initdata, void **data)
 
     /* Allocate some ingress queues. */
     iqueues = SCCalloc(num_workers, sizeof(*iqueues));
-    if (iqueues == NULL)
+    if (unlikely(iqueues == NULL))
         SCReturnInt(TM_ECODE_FAILED);
 
     /* Allocate some NotifRings. */
@@ -984,7 +984,7 @@ TmEcode DecodeMpipe(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
 int MpipeLiveRegisterDevice(char *dev)
 {
     MpipeDevice *nd = SCMalloc(sizeof(MpipeDevice));
-    if (nd == NULL) {
+    if (unlikely(nd == NULL)) {
         return -1;
     }
 
index 86895ee3642869fdb98fe6a8d7f6b756e6620f61..1706a013f0d64ff9f2f64d76937d85010e273b8b 100644 (file)
@@ -156,9 +156,8 @@ TmEcode NapatechStreamThreadInit(ThreadVars *tv, void *initdata, void **data)
     SCLogInfo("Napatech  Thread Stream ID:%lu", stream_id);
 
     NapatechThreadVars *ntv = SCMalloc(sizeof(NapatechThreadVars));
-    if (ntv == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                "Failed to allocate memory for NAPATECH  thread vars.");
+    if (unlikely(ntv == NULL)) {
+        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH  thread vars.");
         exit(EXIT_FAILURE);
     }
 
index ac2f083ca5b509a51b60763811b53a6e67dd831e..c7e3e95182c98b83bc63f15b4e00f12289d087b0 100644 (file)
@@ -1054,7 +1054,7 @@ int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) {
     }
 
     TcpStateQueue *q = SCMalloc(sizeof(*q));
-    if (q == NULL) {
+    if (unlikely(q == NULL)) {
         SCLogDebug("ssn %p: =~ SYN/ACK queue failed: alloc failed", ssn);
         return -1;
     }
index acbeaed072a660bf65b12a3953734795bffe3533..cb3c51df9e404c3970cd8dbdfa8e27f072c3f62e 100644 (file)
@@ -382,7 +382,7 @@ CudaBufferData *CudaBufferRegisterNew(uint8_t *d_buffer, uint32_t d_buffer_len,
     }
 
     CudaBufferData *new = SCMalloc(sizeof(CudaBufferData));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         return NULL;
     }
     memset(new, 0, sizeof(CudaBufferData));
@@ -406,7 +406,7 @@ CudaBufferData *CudaBufferRegisterNew(uint8_t *d_buffer, uint32_t d_buffer_len,
 static void *CudaBufferSlicePoolAlloc(void *null)
 {
     void *ptr = SCMalloc(sizeof(CudaBufferSlice));
-    if (ptr == NULL)
+    if (unlikely(ptr == NULL))
         return NULL;
     memset(ptr, 0, sizeof(CudaBufferSlice));
 
index 79532e5f1e2c183d900615c7f5816e96da533ed7..07d42f97194f716b6352a582e0caffd54430ef77 100644 (file)
@@ -83,7 +83,7 @@ void CudaHandlerAddCudaProfileFromConf(const char *name,
     }
 
     CudaHandlerConfProfile *new_cp = SCMalloc(sizeof(CudaHandlerConfProfile));
-    if (new_cp == NULL)
+    if (unlikely(new_cp == NULL))
         exit(EXIT_FAILURE);
     memset(new_cp, 0, sizeof(CudaHandlerConfProfile));
     new_cp->name = SCStrdup(name);
@@ -188,7 +188,7 @@ CUcontext CudaHandlerModuleGetContext(const char *name, int device_id)
     }
 
     CudaHandlerModule *new_module = SCMalloc(sizeof(CudaHandlerModule));
-    if (new_module == NULL)
+    if (unlikely(new_module == NULL))
         exit(EXIT_FAILURE);
     memset(new_module, 0, sizeof(CudaHandlerModule));
     new_module->device_id = device_id;
@@ -204,7 +204,7 @@ CUcontext CudaHandlerModuleGetContext(const char *name, int device_id)
 
     if (no_of_cuda_contexts <= device_id) {
         cuda_contexts = SCRealloc(cuda_contexts, sizeof(CUcontext) * (device_id + 1));
-        if (cuda_contexts == NULL)
+        if (unlikely(cuda_contexts == NULL))
             exit(EXIT_FAILURE);
         memset(cuda_contexts + no_of_cuda_contexts, 0,
                sizeof(CUcontext) * ((device_id + 1) - no_of_cuda_contexts));
@@ -253,7 +253,7 @@ void CudaHandlerModuleStoreData(const char *module_name,
     }
 
     CudaHandlerModuleData *new_data = SCMalloc(sizeof(CudaHandlerModuleData));
-    if (new_data == NULL)
+    if (unlikely(new_data == NULL))
         exit(EXIT_FAILURE);
     memset(new_data, 0, sizeof(CudaHandlerModuleData));
     new_data->name = SCStrdup(data_name);
index a7044c85c8ac74837d88d8f6daab27729ea2a911..3ada56b26c6d86d24ca3804d8a94d2330f1b72d2 100644 (file)
@@ -796,7 +796,7 @@ int SCCudaDeviceTotalMem(size_t *bytes, CUdevice dev)
 static SCCudaDevice *SCCudaAllocSCCudaDevice(void)
 {
     SCCudaDevice *device = SCMalloc(sizeof(SCCudaDevice));
-    if (device == NULL)
+    if (unlikely(device == NULL))
         return NULL;
     memset(device, 0 , sizeof(SCCudaDevice));
 
@@ -825,7 +825,7 @@ static void SCCudaDeAllocSCCudaDevice(SCCudaDevice *device)
 static SCCudaDevices *SCCudaAllocSCCudaDevices(void)
 {
     SCCudaDevices *devices = SCMalloc(sizeof(SCCudaDevices));
-    if (devices == NULL)
+    if (unlikely(devices == NULL))
         return NULL;
     memset(devices, 0 , sizeof(SCCudaDevices));
 
index 25f898e1b598eb1a38255761b147050839c659b5..eb2b49e564cc0e211cbbdc958170b45630a44902 100644 (file)
@@ -105,7 +105,7 @@ char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen)
         result = magic_buffer(g_magic_ctx, (void *)buf, (size_t)buflen);
         if (result != NULL) {
             magic = SCStrdup(result);
-            if (magic == NULL) {
+            if (unlikely(magic == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup magic");
             }
         }
@@ -132,7 +132,7 @@ char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen)
         result = magic_buffer(*ctx, (void *)buf, (size_t)buflen);
         if (result != NULL) {
             magic = SCStrdup(result);
-            if (magic == NULL) {
+            if (unlikely(magic == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup magic");
             }
         }
index 3a1e263a115b49e41d406f476e52b3fafbb220c8..b65926ada5cab73b25af1fa915102c359ec2f980 100644 (file)
@@ -826,7 +826,7 @@ static inline void SCACTileCreateDeltaTable(MpmCtx *mpm_ctx)
         }
         int size = ctx->state_count * sizeof(SC_AC_TILE_STATE_TYPE_U16) * alpha_size;
         SC_AC_TILE_STATE_TYPE_U16 *state_table = SCMalloc(size);
-        if (state_table == NULL) {
+        if (unlikely(state_table == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
index 4fd6b77ef8aceb66fc94ebc5888238a42b39dbaa..736c13322107210ffd900bb33fde9a2025bb3709 100644 (file)
@@ -144,7 +144,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         /* let's make the new entry */
         items = SCRealloc(items,
                           (de_ctx->mpm_ctx_factory_container->no_of_items + 1) * sizeof(MpmCtxFactoryItem));
-        if (items == NULL) {
+        if (unlikely(items == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
@@ -283,7 +283,7 @@ static void *MpmCudaConfParse(ConfNode *node)
     const char *value;
 
     MpmCudaConf *conf = SCMalloc(sizeof(MpmCudaConf));
-    if (conf == NULL)
+    if (unlikely(conf == NULL))
         exit(EXIT_FAILURE);
     memset(conf, 0, sizeof(*conf));
 
index c075642eb0b65c1defa284424c1e74d867d0c744..23607fd08b5ce6e4dab02c78e660498ba90c5981 100644 (file)
@@ -46,7 +46,7 @@ PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, u
     }
 
     pt = SCMalloc(sizeof(*pt));
-    if (pt == NULL) {
+    if (unlikely(pt == NULL)) {
         SCLogDebug("memory alloc error");
         goto error;
     }
index 860e30a11d9e9e56b80e12e7b511a106dd5811ab..c6a4cbf83fbb045d3b728ef7e0d568178781b97b 100644 (file)
@@ -299,7 +299,7 @@ char *RunmodeAutoFpCreatePickupQueuesString(int n) {
     char qname[TM_QUEUE_NAME_MAX];
 
     queues = SCMalloc(queues_size);
-    if (queues == NULL) {
+    if (unlikely(queues == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "failed to alloc queues buffer: %s", strerror(errno));
         return NULL;
     }
index 8a858fb78cea3c72d2abce248da9f31b5246d58b..cfba8461a0367c8918653e2b3216c34f3871f3fc 100644 (file)
@@ -114,7 +114,7 @@ int StorageRegister(const StorageEnum type, const char *name, const unsigned int
     }
 
     StorageList *entry = SCMalloc(sizeof(StorageList));
-    if (entry == NULL)
+    if (unlikely(entry == NULL))
         return -1;
 
     memset(entry, 0x00, sizeof(StorageList));
@@ -147,7 +147,7 @@ int StorageFinalize(void)
         return 0;
 
     storage_map = SCMalloc(sizeof(StorageMapping *) * STORAGE_MAX);
-    if (storage_map == NULL) {
+    if (unlikely(storage_map == NULL)) {
         return -1;
     }
     memset(storage_map, 0x00, sizeof(StorageMapping *) * STORAGE_MAX);
@@ -258,8 +258,8 @@ void *StorageAllocById(Storage **storage, StorageEnum type, int id)
     Storage *store = *storage;
     if (store == NULL) {
         store = SCMalloc(sizeof(void *) * storage_max_id[type]);
-        if (store == NULL)
-            return NULL;
+        if (unlikely(store == NULL))
+        return NULL;
         memset(store, 0x00, sizeof(void *) * storage_max_id[type]);
     }
     SCLogDebug("store %p", store);
index 1cda1a87fb4ac779ae5f17eaa401a679bdd716e8..7a0ea7df3ab9d5f50e67be72a099946f0454ce8b 100644 (file)
@@ -1154,7 +1154,7 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
             else
                 line = SCRealloc(line, strlen(line) + len + 1);
 
-            if (line == NULL) {
+            if (unlikely(line == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
                 break;
             }