]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Use unlikely for error treatment.
authorEric Leblond <eric@regit.org>
Sun, 23 Sep 2012 13:56:00 +0000 (15:56 +0200)
committerEric Leblond <eric@regit.org>
Tue, 25 Sep 2012 14:24:39 +0000 (16:24 +0200)
When handling error case on SCMallog, SCCalloc or SCStrdup
we are in an unlikely case. This patch adds the unlikely()
expression to indicate this to gcc.

This patch has been obtained via coccinelle. The transformation
is the following:

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

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

182 files changed:
src/alert-debuglog.c
src/alert-fastlog.c
src/alert-pcapinfo.c
src/alert-prelude.c
src/alert-syslog.c
src/alert-unified2-alert.c
src/app-layer-dcerpc-udp.c
src/app-layer-dcerpc.c
src/app-layer-detect-proto.c
src/app-layer-ftp.c
src/app-layer-htp.c
src/app-layer-parser.c
src/app-layer-smb.c
src/app-layer-smb2.c
src/app-layer-smtp.c
src/app-layer-ssh.c
src/app-layer-ssl.c
src/conf.c
src/cuda-packet-batcher.c
src/decode-ethernet.c
src/decode-events.c
src/decode-gre.c
src/decode-icmpv4.c
src/decode-icmpv6.c
src/decode-ipv4.c
src/decode-ipv6.c
src/decode-ppp.c
src/decode-pppoe.c
src/decode-raw.c
src/decode-tcp.c
src/decode-vlan.c
src/decode.c
src/defrag-hash.c
src/defrag.c
src/detect-ack.c
src/detect-app-layer-event.c
src/detect-asn1.c
src/detect-byte-extract.c
src/detect-bytejump.c
src/detect-bytetest.c
src/detect-content.c
src/detect-csum.c
src/detect-depth.c
src/detect-detection-filter.c
src/detect-distance.c
src/detect-dsize.c
src/detect-engine-address.c
src/detect-engine-event.c
src/detect-engine-iponly.c
src/detect-engine-mpm.c
src/detect-engine-port.c
src/detect-engine-proto.c
src/detect-engine-siggroup.c
src/detect-engine-state.c
src/detect-engine-tag.c
src/detect-engine-threshold.c
src/detect-engine.c
src/detect-fast-pattern.c
src/detect-fileext.c
src/detect-filemagic.c
src/detect-filemd5.c
src/detect-filename.c
src/detect-filesize.c
src/detect-filestore.c
src/detect-flags.c
src/detect-flow.c
src/detect-flowbits.c
src/detect-flowint.c
src/detect-flowvar.c
src/detect-fragbits.c
src/detect-fragoffset.c
src/detect-ftpbounce.c
src/detect-icmp-id.c
src/detect-icmp-seq.c
src/detect-icode.c
src/detect-id.c
src/detect-ipopts.c
src/detect-ipproto.c
src/detect-isdataat.c
src/detect-itype.c
src/detect-l3proto.c
src/detect-luajit.c
src/detect-mark.c
src/detect-msg.c
src/detect-offset.c
src/detect-parse.c
src/detect-pcre.c
src/detect-pktvar.c
src/detect-reference.c
src/detect-replace.c
src/detect-rev.c
src/detect-rpc.c
src/detect-seq.c
src/detect-sid.c
src/detect-ssh-proto-version.c
src/detect-ssh-software-version.c
src/detect-ssl-version.c
src/detect-stream_size.c
src/detect-tag.c
src/detect-threshold.c
src/detect-tls-version.c
src/detect-tls.c
src/detect-tos.c
src/detect-ttl.c
src/detect-uricontent.c
src/detect-urilen.c
src/detect-window.c
src/detect-within.c
src/detect.c
src/flow-alert-sid.c
src/flow-bit.c
src/flow-util.c
src/flow-var.c
src/flow.c
src/host.c
src/log-droplog.c
src/log-file.c
src/log-filestore.c
src/log-httplog.c
src/log-pcap.c
src/log-tlslog.c
src/output.c
src/pkt-var.c
src/runmode-af-packet.c
src/runmode-erf-file.c
src/runmode-napatech.c
src/runmode-pcap-file.c
src/runmode-pcap.c
src/runmode-pfring.c
src/runmodes.c
src/source-af-packet.c
src/source-erf-dag.c
src/source-erf-file.c
src/source-napatech.c
src/source-pcap-file.c
src/source-pcap.c
src/source-pfring.c
src/stream-tcp-inline.c
src/stream-tcp-reassemble.c
src/stream-tcp-sack.c
src/stream-tcp.c
src/stream.c
src/suricata.c
src/tm-queues.c
src/tm-threads.c
src/tmqh-flow.c
src/tmqh-packetpool.c
src/util-bloomfilter-counting.c
src/util-bloomfilter.c
src/util-buffer.c
src/util-cuda-handlers.c
src/util-cuda.c
src/util-debug.c
src/util-decode-asn1.c
src/util-device.c
src/util-file.c
src/util-hash.c
src/util-hashlist.c
src/util-mpm-ac-bs.c
src/util-mpm-ac-gfbs.c
src/util-mpm-ac.c
src/util-mpm-b2g-cuda.c
src/util-mpm-b2g.c
src/util-mpm-b2gc.c
src/util-mpm-b2gm.c
src/util-mpm-b3g.c
src/util-mpm-wumanber.c
src/util-mpm.c
src/util-pool.c
src/util-profiling-rules.c
src/util-profiling.c
src/util-radix-tree.c
src/util-ringbuffer.c
src/util-rohash.c
src/util-runmodes.c
src/util-spm-bm.c
src/util-spm.c
src/util-threshold-config.c
src/util-unittest-helper.c
src/util-unittest.c
src/util-var-name.c
src/win32-misc.c

index 92f5cbad0ff336e8c6965616855892566e262f9b..af2eb2da620baf177edaf1a40e7786c054a6a2c0 100644 (file)
@@ -426,7 +426,7 @@ TmEcode AlertDebugLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, P
 TmEcode AlertDebugLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     AlertDebugLogThread *aft = SCMalloc(sizeof(AlertDebugLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(AlertDebugLogThread));
 
@@ -507,7 +507,7 @@ OutputCtx *AlertDebugLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         goto error;
 
     memset(output_ctx, 0x00, sizeof(OutputCtx));
index 3ed3042a33295a471d623e4ddf5f87b30fc2c762..22309afdfdfeeeaa89ae44c605d2cd035d0c2251 100644 (file)
@@ -282,7 +282,7 @@ TmEcode AlertFastLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa
 TmEcode AlertFastLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     AlertFastLogThread *aft = SCMalloc(sizeof(AlertFastLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(AlertFastLogThread));
     if(initdata == NULL)
@@ -340,7 +340,7 @@ OutputCtx *AlertFastLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         return NULL;
     output_ctx->data = logfile_ctx;
     output_ctx->DeInit = AlertFastLogDeInitCtx;
index a953de8ce004c768b03243f42eafee6b8d43df28..ec68262e694ae1a4ac44028d2c7e374438cd9a86 100644 (file)
@@ -121,7 +121,7 @@ TmEcode AlertPcapInfo (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, P
 TmEcode AlertPcapInfoThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     AlertPcapInfoThread *aft = SCMalloc(sizeof(AlertPcapInfoThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(AlertPcapInfoThread));
     if(initdata == NULL)
@@ -187,7 +187,7 @@ OutputCtx *AlertPcapInfoInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         return NULL;
     output_ctx->data = logfile_ctx;
     output_ctx->DeInit = AlertPcapInfoDeInitCtx;
index c8b471e064f4429407e5f7636d6162bb893d5537..8abcd77b2bd464f74d3190a573679b571a7e16bc 100644 (file)
@@ -772,7 +772,7 @@ TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
     }
 
     aun = SCMalloc(sizeof(AlertPreludeThread));
-    if (aun == NULL)
+    if (unlikely(aun == NULL))
         SCReturnInt(TM_ECODE_FAILED);
     memset(aun, 0, sizeof(AlertPreludeThread));
 
@@ -865,7 +865,7 @@ OutputCtx *AlertPreludeInitCtx(ConfNode *conf)
     }
 
     ctx = SCMalloc(sizeof(AlertPreludeCtx));
-    if ( ctx == NULL ) {
+    if (unlikely(ctx == NULL)) {
         prelude_perror(ret, "Unable to allocate memory");
         prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
         SCReturnPtr(NULL, "AlertPreludeCtx");
@@ -880,9 +880,8 @@ OutputCtx *AlertPreludeInitCtx(ConfNode *conf)
         ctx->log_packet_header = 0;
 
     output_ctx = SCMalloc(sizeof(OutputCtx));
-    if (output_ctx == NULL) {
+    if (unlikely(output_ctx == NULL)) {
         SCFree(ctx);
-
         prelude_perror(ret, "Unable to allocate memory");
         prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
         SCReturnPtr(NULL, "AlertPreludeCtx");
index 806070043b545936c2fae4d648867b19a69431ed..fd0ce71ef5d5124cf1e7de56518eae998003f38b 100644 (file)
@@ -158,7 +158,7 @@ OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
     openlog(ident, LOG_PID|LOG_NDELAY, facility);
 
     OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
-    if (output_ctx == NULL) {
+    if (unlikely(output_ctx == NULL)) {
         SCLogDebug("AlertSyslogInitCtx: Could not create new OutputCtx");
         return NULL;
     }
@@ -207,7 +207,7 @@ TmEcode AlertSyslogThreadInit(ThreadVars *t, void *initdata, void **data)
     }
 
     AlertSyslogThread *ast = SCMalloc(sizeof(AlertSyslogThread));
-    if (ast == NULL)
+    if (unlikely(ast == NULL))
         return TM_ECODE_FAILED;
 
     memset(ast, 0, sizeof(AlertSyslogThread));
index 39671e5d0f54798726e911683e7227a0c4047d2b..07bd44d7f7de0af32cba041ae6a1033e1487385d 100644 (file)
@@ -901,7 +901,7 @@ int Unified2IPv4TypeAlert (ThreadVars *tv, Packet *p, void *data, PacketQueue *p
 TmEcode Unified2AlertThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     Unified2AlertThread *aun = SCMalloc(sizeof(Unified2AlertThread));
-    if (aun == NULL)
+    if (unlikely(aun == NULL))
         return TM_ECODE_FAILED;
     memset(aun, 0, sizeof(Unified2AlertThread));
     if(initdata == NULL)
@@ -1017,7 +1017,7 @@ OutputCtx *Unified2AlertInitCtx(ConfNode *conf)
         goto error;
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         goto error;
     output_ctx->data = file_ctx;
     output_ctx->DeInit = Unified2AlertDeInitCtx;
@@ -1125,7 +1125,7 @@ static int Unified2Test01 (void)   {
         0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
         0x03, 0x06};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int ret;
 
@@ -1214,7 +1214,7 @@ static int Unified2Test02 (void)   {
         0x08, 0x0a, 0x00, 0x0a, 0x22, 0xa8, 0x00, 0x00,
         0x00, 0x00, 0x01, 0x03, 0x03, 0x05 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int ret;
 
@@ -1309,7 +1309,7 @@ static int Unified2Test03 (void) {
         0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x65, 0x74,
         0x0d, 0x0a};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int ret;
 
@@ -1398,7 +1398,7 @@ static int Unified2Test04 (void)   {
         0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x10, 0x20,
         0xdd, 0xe1, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int ret;
 
@@ -1485,7 +1485,7 @@ static int Unified2Test05 (void)   {
         0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
         0x03, 0x06};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int ret;
 
@@ -1569,7 +1569,7 @@ static int Unified2TestRotate01(void)
     if (lf == NULL)
         return 0;
     filename = SCStrdup(lf->filename);
-    if (filename == NULL)
+    if (unlikely(filename == NULL))
         return 0;
 
     memset(&tv, 0, sizeof(ThreadVars));
index 129bcbad1bf7412f34b61becbb5ae2bb208dba1c..fd519baa0da492394ec7b72f37a19e75db9474fd 100644 (file)
@@ -684,7 +684,7 @@ static int DCERPCUDPParse(Flow *f, void *dcerpc_state,
 
 static void *DCERPCUDPStateAlloc(void) {
        void *s = SCMalloc(sizeof(DCERPCUDPState));
-       if (s == NULL)
+       if (unlikely(s == NULL))
                return NULL;
 
        memset(s, 0, sizeof(DCERPCUDPState));
index b4f7f0f8ed26b7306836b2844a46139e86611ccd..27162d8991f3131940da78971a09e44aae517be6 100644 (file)
@@ -1798,7 +1798,7 @@ static void *DCERPCStateAlloc(void) {
     SCEnter();
 
     DCERPCState *s = SCMalloc(sizeof(DCERPCState));
-    if (s == NULL) {
+    if (unlikely(s == NULL)) {
         SCReturnPtr(NULL, "void");
     }
     memset(s, 0, sizeof(DCERPCState));
index 26317560b8eaa99506da402fde708a51bcf53496..18c8494b2e1c8fc58e8b9f9f4c0a0d1119a41308 100644 (file)
@@ -108,7 +108,7 @@ void AlpProtoInit(AlpProtoDetectCtx *ctx) {
  */
 static void AlpProtoAddSignature(AlpProtoDetectCtx *ctx, DetectContentData *co, uint16_t ip_proto, uint16_t proto) {
     AlpProtoSignature *s = SCMalloc(sizeof(AlpProtoSignature));
-    if (s == NULL) {
+    if (unlikely(s == NULL)) {
         SCLogError(SC_ERR_FATAL, "Error allocating memory. Signature not loaded. Not enough memory so.. exiting..");
         exit(EXIT_FAILURE);
     }
@@ -413,7 +413,7 @@ uint16_t AppLayerDetectGetProtoPMParser(AlpProtoDetectCtx *ctx,
                                                 searchlen);
 #else
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         goto end;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
index 985b7818044f4a1cfba05b94730c6d51ba1abf56..403f3c4eaedb5535fd1aa219a0c886854c1e637d 100644 (file)
@@ -235,7 +235,7 @@ static uint64_t ftp_state_memcnt = 0;
 
 static void *FTPStateAlloc(void) {
     void *s = SCMalloc(sizeof(FtpState));
-    if (s == NULL)
+    if (unlikely(s == NULL))
         return NULL;
 
     memset(s, 0, sizeof(FtpState));
index 7edd41660a5f1719a0df90bdb7963882d56ab337..38ea904a81f2dfee18fddef297ca2bf86f881a41 100644 (file)
@@ -220,7 +220,7 @@ static void *HTPStateAlloc(void)
     SCEnter();
 
     HtpState *s = SCMalloc(sizeof(HtpState));
-    if (s == NULL)
+    if (unlikely(s == NULL))
         goto error;
 
     memset(s, 0x00, sizeof(HtpState));
@@ -1791,7 +1791,7 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d)
     HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(d->tx);
     if (htud == NULL) {
         htud = SCMalloc(sizeof(HtpTxUserData));
-        if (htud == NULL) {
+        if (unlikely(htud == NULL)) {
             SCReturnInt(HOOK_OK);
         }
         memset(htud, 0, sizeof(HtpTxUserData));
@@ -1908,7 +1908,7 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d)
     HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(d->tx);
     if (htud == NULL) {
         htud = SCMalloc(sizeof(HtpTxUserData));
-        if (htud == NULL) {
+        if (unlikely(htud == NULL)) {
             SCReturnInt(HOOK_OK);
         }
         memset(htud, 0, sizeof(HtpTxUserData));
index e470a7d5ddf7be853cad850742138f0d669b642c..f78597a19c4fbd8e0a3f16d0a3f5fb260b245624 100644 (file)
@@ -1499,7 +1499,7 @@ AppLayerCreateAppLayerProbingParserElement(const char *al_proto_name,
                                            (uint8_t *input, uint32_t input_len))
 {
     AppLayerProbingParserElement *pe = SCMalloc(sizeof(AppLayerProbingParserElement));
-    if (pe == NULL) {
+    if (unlikely(pe == NULL)) {
         return NULL;
     }
 
@@ -1541,7 +1541,7 @@ static AppLayerProbingParserElement *
 AppLayerDuplicateAppLayerProbingParserElement(AppLayerProbingParserElement *pe)
 {
     AppLayerProbingParserElement *new_pe = SCMalloc(sizeof(AppLayerProbingParserElement));
-    if (new_pe == NULL) {
+    if (unlikely(new_pe == NULL)) {
         return NULL;
     }
 
@@ -1576,7 +1576,7 @@ AppLayerInsertNewProbingParserSingleElement(AppLayerProbingParser *pp,
 {
     if (pp == NULL) {
         AppLayerProbingParser *new_pp = SCMalloc(sizeof(AppLayerProbingParser));
-        if (new_pp == NULL)
+        if (unlikely(new_pp == NULL))
             return;
         memset(new_pp, 0, sizeof(AppLayerProbingParser));
 
@@ -1830,7 +1830,7 @@ int AppLayerProbingParserInfoAdd(AlpProtoDetectCtx *ctx,
 
     if (ppi == NULL) {
         new_ppi = SCMalloc(sizeof(AppLayerProbingParserInfo));
-        if (new_ppi == NULL) {
+        if (unlikely(new_ppi == NULL)) {
             return -1;
         }
         memset(new_ppi, 0, sizeof(AppLayerProbingParserInfo));
@@ -2009,7 +2009,7 @@ static int TestProtocolParser(Flow *f, void *test_state, AppLayerParserState *ps
 static void *TestProtocolStateAlloc(void)
 {
     void *s = SCMalloc(sizeof(TestState));
-    if (s == NULL)
+    if (unlikely(s == NULL))
         return NULL;
 
     memset(s, 0, sizeof(TestState));
index 251bee10833360982d4ea8f9fdfe103b554a2990..3e8eaffa456ab8dd3c170a68fd295cee4a2d883a 100644 (file)
@@ -1292,7 +1292,7 @@ static void *SMBStateAlloc(void) {
     SCEnter();
 
     void *s = SCMalloc(sizeof(SMBState));
-    if (s == NULL) {
+    if (unlikely(s == NULL)) {
         SCReturnPtr(NULL, "void");
     }
 
index 7518648fe1de15a289c393ca63acb6af5be37255..a2dc7c611b066d2c8dd4301b0b51a395bd2f356a 100644 (file)
@@ -503,7 +503,7 @@ static int SMB2Parse(Flow *f, void *smb2_state, AppLayerParserState *pstate,
 
 static void *SMB2StateAlloc(void) {
     void *s = SCMalloc(sizeof(SMB2State));
-    if (s == NULL)
+    if (unlikely(s == NULL))
         return NULL;
 
     memset(s, 0, sizeof(SMB2State));
index e6c9a67d6577d06d649ea7f6d445ecdd4cc38069..a309369a7a26f255bb6a0e601a7c73c225fd4e7e 100644 (file)
@@ -746,7 +746,7 @@ static int SMTPParseServerRecord(Flow *f, void *alstate,
 static void *SMTPStateAlloc(void)
 {
     SMTPState *smtp_state = SCMalloc(sizeof(SMTPState));
-    if (smtp_state == NULL)
+    if (unlikely(smtp_state == NULL))
         return NULL;
     memset(smtp_state, 0, sizeof(SMTPState));
 
@@ -765,8 +765,7 @@ static void *SMTPLocalStorageAlloc(void)
 {
     /* needed by the mpm */
     PatternMatcherQueue *pmq = SCMalloc(sizeof(PatternMatcherQueue));
-    if (pmq == NULL) {
-        /* we need to exit here, since it is load time */
+    if (unlikely(pmq == NULL)) {
         exit(EXIT_FAILURE);
     }
     PmqSetup(pmq, 0,
@@ -811,15 +810,13 @@ static void SMTPStateFree(void *p)
 static void SMTPSetMpmState(void)
 {
     smtp_mpm_ctx = SCMalloc(sizeof(MpmCtx));
-    if (smtp_mpm_ctx == NULL) {
-        /* we need to exit here, since it is load time */
+    if (unlikely(smtp_mpm_ctx == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(smtp_mpm_ctx, 0, sizeof(MpmCtx));
 
     smtp_mpm_thread_ctx = SCMalloc(sizeof(MpmThreadCtx));
-    if (smtp_mpm_thread_ctx == NULL) {
-        /* we need to exit here, since it is load time */
+    if (unlikely(smtp_mpm_thread_ctx == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(smtp_mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
index 5a40c3f17a87b88f5b91dd102e1904049f41b63b..b2c64892784fee43eef665b5ab88b9ec37f82588 100644 (file)
@@ -718,7 +718,7 @@ static int SSHParseClientRecord(Flow *f, void *ssh_state, AppLayerParserState *p
 static void *SSHStateAlloc(void)
 {
     void *s = SCMalloc(sizeof(SshState));
-    if (s == NULL)
+    if (unlikely(s == NULL))
         return NULL;
 
     memset(s, 0, sizeof(SshState));
index 1571636317bf2f96a4d3d3943e7266fb62c00bf0..ba1d668afd5b9d8e034542df09529b290c53551d 100644 (file)
@@ -857,7 +857,7 @@ int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
 void *SSLStateAlloc(void)
 {
     void *ssl_state = SCMalloc(sizeof(SSLState));
-    if (ssl_state == NULL)
+    if (unlikely(ssl_state == NULL))
         return NULL;
     memset(ssl_state, 0, sizeof(SSLState));
     ((SSLState*)ssl_state)->client_connp.cert_log_flag = 0;
index dd11948a1e20fe21e46ba7d229f63815440c86a0..be06794861bfdac8a94479ea7fe9bf215c5bb86a 100644 (file)
@@ -78,7 +78,7 @@ ConfNodeNew(void)
     ConfNode *new;
 
     new = SCCalloc(1, sizeof(*new));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         return NULL;
     }
     /* By default we allow an override. */
@@ -129,7 +129,7 @@ ConfGetNode(char *key)
 
     /* Need to dup the key for tokenization... */
     char *tokstr = SCStrdup(key);
-    if (tokstr == NULL) {
+    if (unlikely(tokstr == NULL)) {
         return NULL;
     }
 
@@ -198,7 +198,7 @@ ConfSet(char *name, char *val, int allow_override)
     }
     else {
         char *tokstr = SCStrdup(name);
-        if (tokstr == NULL) {
+        if (unlikely(tokstr == NULL)) {
             return 0;
         }
 #if defined(__WIN32) || defined(_WIN32)
@@ -725,7 +725,7 @@ char *ConfLoadCompleteIncludePath(char *file)
             size_t path_len = sizeof(char) * (strlen(defaultpath) +
                           strlen(file) + 2);
             path = SCMalloc(path_len);
-            if (path == NULL)
+            if (unlikely(path == NULL))
                 return NULL;
             strlcpy(path, defaultpath, path_len);
             if (path[strlen(path) - 1] != '/')
@@ -733,12 +733,12 @@ char *ConfLoadCompleteIncludePath(char *file)
             strlcat(path, file, path_len);
        } else {
             path = SCStrdup(file);
-            if (path == NULL)
+            if (unlikely(path == NULL))
                 return NULL;
         }
     } else {
         path = SCStrdup(file);
-        if (path == NULL)
+        if (unlikely(path == NULL))
             return NULL;
     }
     return path;
index 16b1b2448a10199150dba343233964f070c492d7..35c01a19263f61ab35e65e800d27308e81602ade 100644 (file)
@@ -439,7 +439,7 @@ void SCCudaPBDeAllocSCCudaPBPacketsBuffer(SCCudaPBPacketsBuffer *pb)
 SCCudaPBPacketsBuffer *SCCudaPBAllocSCCudaPBPacketsBuffer(void)
 {
     SCCudaPBPacketsBuffer *pb = SCMalloc(sizeof(SCCudaPBPacketsBuffer));
-    if (pb == NULL) {
+    if (unlikely(pb == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -591,7 +591,7 @@ TmEcode SCCudaPBThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     tctx = SCMalloc(sizeof(SCCudaPBThreadCtx));
-    if (tctx == NULL) {
+    if (unlikely(tctx == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -1149,7 +1149,7 @@ int SCCudaPBTest01(void)
     SCCudaPBThreadCtx *tctx = NULL;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     DecodeThreadVars dtv;
     ThreadVars tv;
@@ -1415,7 +1415,7 @@ int SCCudaPBTest02(void)
     SCCudaPBThreadCtx *tctx = NULL;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
     ThreadVars tv;
index 3a257f52da4f5384402b9f372a4e0088e4e244c3..18cd822d640dcfc7a084834e44964c6fa510eb45 100644 (file)
@@ -113,7 +113,7 @@ static int DecodeEthernetTest01 (void)   {
         0xab, 0xcd };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index c0c649984cadc28c4f3b1f5553e5208e80c7e338..6b06df43ab12af267e498b78f1b4f38e609e2f2e 100644 (file)
@@ -48,7 +48,7 @@ void AppLayerDecoderEventsModuleRegister(uint16_t alproto, SCEnumCharMap *table)
 
     AppLayerDecoderEventsModule *new_dev =
         SCMalloc(sizeof(AppLayerDecoderEventsModule));
-    if (new_dev == NULL)
+    if (unlikely(new_dev == NULL))
         return;
 
     new_dev->alproto = alproto;
index dc5271aa784fb11bb9b969d51ec1ea5b74f15719..b7ae22915cfbc811b9d3c3bd491202943a08aad5 100644 (file)
@@ -267,7 +267,7 @@ static int DecodeGREtest01 (void)   {
 
     uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -309,7 +309,7 @@ static int DecodeGREtest02 (void)   {
         0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -352,7 +352,7 @@ static int DecodeGREtest03 (void)   {
         0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index c281b3c5a4bd805cd4fab6fa4274b3900d843536..9cf1e03424d476a42356187a04a90a2e79d93b98 100644 (file)
@@ -320,7 +320,7 @@ static int DecodeICMPV4test01(void) {
         0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
         0xab };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -372,7 +372,7 @@ static int DecodeICMPV4test02(void) {
         0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
         0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -421,7 +421,7 @@ static int DecodeICMPV4test03(void) {
         0xd1, 0x55, 0xe3, 0x93, 0x8b, 0x12, 0x82, 0xaa,
         0x00, 0x28, 0x7c, 0xdd };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -501,7 +501,7 @@ static int DecodeICMPV4test04(void) {
         0xa0, 0x02, 0x16, 0xd0, 0x72, 0x04, 0x00, 0x00,
         0x02, 0x04, 0x05, 0x8a, 0x04, 0x02, 0x08, 0x0a };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -571,7 +571,7 @@ static int DecodeICMPV4test05(void) {
        0x23, 0x04, 0x18, 0x00, 0x50, 0xd2, 0x08, 0xc2, 0x48,
          };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -676,7 +676,7 @@ static int ICMPV4InvalidType07(void) {
         0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38};
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -720,7 +720,7 @@ static int DecodeICMPV4test08(void) {
         0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 01023a05faa32b27da3c28a4bfbe8b706d77bc5a..d0150535d5c182293d2462502ba8146031900879 100644 (file)
@@ -367,7 +367,7 @@ static int ICMPV6ParamProbTest01(void)
         0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -439,7 +439,7 @@ static int ICMPV6PktTooBigTest01(void)
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -513,7 +513,7 @@ static int ICMPV6TimeExceedTest01(void)
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -589,7 +589,7 @@ static int ICMPV6DestUnreachTest01(void)
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -657,7 +657,7 @@ static int ICMPV6EchoReqTest01(void)
         0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -710,7 +710,7 @@ static int ICMPV6EchoRepTest01(void)
         0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -770,7 +770,7 @@ static int ICMPV6ParamProbTest02(void)
         0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -831,7 +831,7 @@ static int ICMPV6PktTooBigTest02(void)
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -883,7 +883,7 @@ static int ICMPV6TimeExceedTest02(void)
     /* The icmpv6 header is broken in the checksum (so we dont have a complete header) */
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -932,7 +932,7 @@ static int ICMPV6DestUnreachTest02(void)
         0x00, 0x00, 0x00, 0x00, 0x00 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -977,7 +977,7 @@ static int ICMPV6EchoReqTest02(void)
         0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -1022,7 +1022,7 @@ static int ICMPV6EchoRepTest02(void)
         0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
@@ -1070,7 +1070,7 @@ static int ICMPV6PayloadTest01(void)
         0x00, 0x00, 0x00, 0x00, 0x00 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
index f96b09fc048973387ca8f652b0430c85c13691b0..7dbaaf0192628bca225e1653194e8e9e830285e0 100644 (file)
@@ -638,7 +638,7 @@ void DecodeIPV4OptionsPrint(Packet *p) {
 int DecodeIPV4OptionsNONETest01(void) {
     uint8_t raw_opts[] = { };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     uint8_t *data = (uint8_t *)p;
     uint16_t i;
@@ -674,7 +674,7 @@ int DecodeIPV4OptionsEOLTest01(void) {
         IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     uint8_t *data = (uint8_t *)p;
     uint16_t i;
@@ -710,7 +710,7 @@ int DecodeIPV4OptionsNOPTest01(void) {
         IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     uint8_t *data = (uint8_t *)p;
     uint16_t i;
@@ -750,7 +750,7 @@ int DecodeIPV4OptionsRRTest01(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -784,7 +784,7 @@ int DecodeIPV4OptionsRRTest02(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -813,7 +813,7 @@ int DecodeIPV4OptionsRRTest03(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -842,7 +842,7 @@ int DecodeIPV4OptionsRRTest04(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -867,7 +867,7 @@ int DecodeIPV4OptionsQSTest01(void) {
         IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -897,7 +897,7 @@ int DecodeIPV4OptionsQSTest02(void) {
         IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -926,7 +926,7 @@ int DecodeIPV4OptionsTSTest01(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -960,7 +960,7 @@ int DecodeIPV4OptionsTSTest02(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -989,7 +989,7 @@ int DecodeIPV4OptionsTSTest03(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1018,7 +1018,7 @@ int DecodeIPV4OptionsTSTest04(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1044,7 +1044,7 @@ int DecodeIPV4OptionsSECTest01(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1075,7 +1075,7 @@ int DecodeIPV4OptionsSECTest02(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1104,7 +1104,7 @@ int DecodeIPV4OptionsLSRRTest01(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1138,7 +1138,7 @@ int DecodeIPV4OptionsLSRRTest02(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1167,7 +1167,7 @@ int DecodeIPV4OptionsLSRRTest03(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1196,7 +1196,7 @@ int DecodeIPV4OptionsLSRRTest04(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1223,7 +1223,7 @@ int DecodeIPV4OptionsCIPSOTest01(void) {
         0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1253,7 +1253,7 @@ int DecodeIPV4OptionsSIDTest01(void) {
         IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1283,7 +1283,7 @@ int DecodeIPV4OptionsSIDTest02(void) {
         IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1312,7 +1312,7 @@ int DecodeIPV4OptionsSSRRTest01(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1346,7 +1346,7 @@ int DecodeIPV4OptionsSSRRTest02(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1375,7 +1375,7 @@ int DecodeIPV4OptionsSSRRTest03(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1404,7 +1404,7 @@ int DecodeIPV4OptionsSSRRTest04(void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1429,7 +1429,7 @@ int DecodeIPV4OptionsRTRALTTest01(void) {
         IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1459,7 +1459,7 @@ int DecodeIPV4OptionsRTRALTTest02(void) {
         IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     int rc;
 
@@ -1545,7 +1545,7 @@ int DecodeIPV4DefragTest01(void)
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -1683,7 +1683,7 @@ int DecodeIPV4DefragTest02(void)
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -1812,7 +1812,7 @@ int DecodeIPV4DefragTest03(void)
 
     Flow *f = NULL;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index a3bebb7689021ae54a587f6df97c8d41e5e25fe0..67e4ac6f097017d84f068db23933baef3b88fe48 100644 (file)
@@ -712,12 +712,12 @@ static int DecodeIPV6FragTest01 (void)   {
         0x20, 0x20, 0x20, 0x20,
     };
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
-        return 0;
+    if (unlikely(p1 == NULL))
+    return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
-        SCFree(p1);
-        return 0;
+    if (unlikely(p2 == NULL)) {
+    SCFree(p1);
+    return 0;
     }
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -789,8 +789,8 @@ static int DecodeIPV6RouteTest01 (void)   {
         0xfa, 0x87, 0x00, 0x00,
     };
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
-        return 0;
+    if (unlikely(p1 == NULL))
+    return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
     int result = 0;
index 8085603e8b8433ec3bb0681d18b413c65a1b9c2c..9c465a8ef1ad740d5ba404b08ebfffb5ba6597f4 100644 (file)
@@ -139,7 +139,7 @@ void DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
 static int DecodePPPtest01 (void)   {
     uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -173,7 +173,7 @@ static int DecodePPPtest02 (void)   {
                            0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
                            0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -209,7 +209,7 @@ static int DecodePPPtest03 (void)   {
                            0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
                            0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -268,7 +268,7 @@ static int DecodePPPtest04 (void)   {
                            0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
                            0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 647d33973b9e7610d37284e92468da6a332a9faf..1dd260a6e1667f9343b3e56344976cff1b6f5531 100644 (file)
@@ -229,7 +229,7 @@ static int DecodePPPOEtest01 (void)   {
 
     uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -268,7 +268,7 @@ static int DecodePPPOEtest02 (void)   {
         0x46, 0x47, 0x48, 0x49 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -317,7 +317,7 @@ static int DecodePPPOEtest03 (void)   {
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -350,7 +350,7 @@ static int DecodePPPOEtest04 (void)   {
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -386,7 +386,7 @@ static int DecodePPPOEtest05 (void)   {
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 97c479fe6808dd9b74ffdb721a52798493a18351..2b4db29bdd2ebfb9800b5a19432bafe5862c3b13 100644 (file)
@@ -84,7 +84,7 @@ static int DecodeRawTest01 (void)   {
         0x04, 0x02, 0x08, 0x0a, 0x00, 0xdd, 0x1a, 0x39,
         0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -130,7 +130,7 @@ static int DecodeRawTest02 (void)   {
         0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -176,7 +176,7 @@ static int DecodeRawTest03 (void)   {
         0x20, 0x6b, 0x65, 0x79, 0x3b };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index ae3292915837c4938eb2834369022b4c0fb8ac80..4f96f3291f0a3aab32bd196594139e936a8052ff 100644 (file)
@@ -302,7 +302,7 @@ static int TCPGetWscaleTest01(void)
                                 0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
                                 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV4Hdr ip4h;
     ThreadVars tv;
@@ -350,7 +350,7 @@ static int TCPGetWscaleTest02(void)
                                 0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
                                 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x0f};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV4Hdr ip4h;
     ThreadVars tv;
@@ -396,7 +396,7 @@ static int TCPGetWscaleTest03(void)
                                 0x7c, 0x70, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
                                 0x00, 0x62, 0x88, 0x9e, 0x00, 0x00, 0x00, 0x00};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV4Hdr ip4h;
     ThreadVars tv;
@@ -446,7 +446,7 @@ static int TCPGetSackTest01(void)
         0xf1, 0x59, 0x13, 0xfc, 0xf1, 0x59, 0x1f, 0x64,
         0xf1, 0x59, 0x08, 0x94, 0xf1, 0x59, 0x0e, 0x48 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV4Hdr ip4h;
     ThreadVars tv;
index 4c1841e012faaef9beac2b83a13d1a78542875e4..4bbaab424d9e89e666cef4ace817a1ee08bc8ab3 100644 (file)
@@ -112,7 +112,7 @@ void DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
 static int DecodeVLANtest01 (void)   {
     uint8_t raw_vlan[] = { 0x00, 0x20, 0x08 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -149,7 +149,7 @@ static int DecodeVLANtest02 (void)   {
         0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
         0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -187,7 +187,7 @@ static int DecodeVLANtest03 (void)   {
         0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
         0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 91fca2869a1714af660064ac9f5db6870c150357..99c664e1e055a7688dea902eb8e79597ad8cb785 100644 (file)
@@ -85,7 +85,7 @@ void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 Packet *PacketGetFromAlloc(void)
 {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         return NULL;
     }
 
index e7dc32b2ff6acc39b98a0839152727dd04a7e48f..f617d3f62ab35156cd129d59a7b2a08793d74af2 100644 (file)
@@ -46,7 +46,7 @@ DefragTracker *DefragTrackerAlloc(void) {
     (void) SC_ATOMIC_ADD(defrag_memuse, sizeof(DefragTracker));
 
     DefragTracker *dt = SCMalloc(sizeof(DefragTracker));
-    if (dt == NULL)
+    if (unlikely(dt == NULL))
         goto error;
 
     memset(dt, 0x00, sizeof(DefragTracker));
@@ -184,7 +184,7 @@ void DefragInitConfig(char quiet)
         exit(EXIT_FAILURE);
     }
     defragtracker_hash = SCCalloc(defrag_config.hash_size, sizeof(DefragTrackerHashRow));
-    if (defragtracker_hash == NULL) {
+    if (unlikely(defragtracker_hash == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
         exit(EXIT_FAILURE);
     }
index ee7e43729bd59d88298f8329b6888a40ff399dce..cb8fba25a0fc4bcdfa8911a5a25b7aa568b792db 100644 (file)
@@ -173,7 +173,7 @@ DefragContextNew(void)
     DefragContext *dc;
 
     dc = SCCalloc(1, sizeof(*dc));
-    if (dc == NULL)
+    if (unlikely(dc == NULL))
         return NULL;
 
     /* Initialize the pool of trackers. */
@@ -912,7 +912,7 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
     IPV4Hdr ip4h;
 
     p = SCCalloc(1, sizeof(*p) + default_packet_size);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
 
     PACKET_INITIALIZE(p);
@@ -941,7 +941,7 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
     SET_IPV4_DST_ADDR(p, &p->dst);
 
     pcontent = SCCalloc(1, content_len);
-    if (pcontent == NULL)
+    if (unlikely(pcontent == NULL))
         return NULL;
     memset(pcontent, content, content_len);
     PacketCopyDataOffset(p, hlen, pcontent, content_len);
@@ -984,7 +984,7 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content,
     IPV6Hdr ip6h;
 
     p = SCCalloc(1, sizeof(*p) + default_packet_size);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
 
     PACKET_INITIALIZE(p);
@@ -1016,7 +1016,7 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content,
     p->ip6eh.ip6fh->ip6fh_offlg = htons((off << 3) | mf);
 
     pcontent = SCCalloc(1, content_len);
-    if (pcontent == NULL)
+    if (unlikely(pcontent == NULL))
         return NULL;
     memset(pcontent, content, content_len);
     PacketCopyDataOffset(p, sizeof(IPV6Hdr) + sizeof(IPV6FragHdr), pcontent, content_len);
index e3ac7d3f6207e792aa563800fa44a7d8ca061d60..e82aef2fc9134c0ccd621c907fbd0461550414af 100644 (file)
@@ -97,7 +97,7 @@ static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr)
     SigMatch *sm = NULL;
 
     data = SCMalloc(sizeof(DetectAckData));
-    if (data == NULL)
+    if (unlikely(data == NULL))
         goto error;
 
     sm = SigMatchAlloc();
index bf9aae40f0dcb97142056295c885e524fa7a5358..415c5db02e713ed445aff97cbd737405ab93685b 100644 (file)
@@ -125,7 +125,7 @@ static DetectAppLayerEventData *DetectAppLayerEventParse(const char *arg)
         return NULL;
 
     DetectAppLayerEventData *aled = SCMalloc(sizeof(DetectAppLayerEventData));
-    if (aled == NULL)
+    if (unlikely(aled == NULL))
         return NULL;
     aled->alproto = alproto;
     aled->event_id = event_id;
index 22034be461a8077ce1630410f1fbea0e1c513254..f9cb41e36b14a8253e38dc088ec1e975e53b1678 100644 (file)
@@ -259,7 +259,7 @@ DetectAsn1Data *DetectAsn1Parse(char *asn1str) {
     }
 
     fd = SCMalloc(sizeof(DetectAsn1Data));
-    if (fd == NULL) {
+    if (unlikely(fd == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(fd, 0x00, sizeof(DetectAsn1Data));
index 8bbbb295cf136a4fb4841cc97c92111e4f4cac29..35c2e27c51a2a690797329c133ab62de157587e7 100644 (file)
@@ -260,7 +260,7 @@ static inline DetectByteExtractData *DetectByteExtractParse(char *arg)
     }
 
     bed = SCMalloc(sizeof(DetectByteExtractData));
-    if (bed == NULL)
+    if (unlikely(bed == NULL))
         goto error;
     memset(bed, 0, sizeof(DetectByteExtractData));
 
index 359e684ce5a3fc1289fae7c40d56cda54c98c93b..ee25e7521d9813959cca1d6e18c82afa4c13a838 100644 (file)
@@ -395,7 +395,7 @@ DetectBytejumpData *DetectBytejumpParse(char *optstr, char **offset)
 
     /* Initialize the data */
     data = SCMalloc(sizeof(DetectBytejumpData));
-    if (data == NULL)
+    if (unlikely(data == NULL))
         goto error;
     data->base = DETECT_BYTEJUMP_BASE_UNSET;
     data->flags = 0;
@@ -1223,7 +1223,7 @@ int DetectByteJumpTestPacket03(void)
     uint8_t *buf = NULL;
     uint16_t buflen = 0;
     buf = SCMalloc(4);
-    if (buf == NULL) {
+    if (unlikely(buf == NULL)) {
         printf("malloc failed\n");
         exit(EXIT_FAILURE);
     }
index 51705e19a004fe4c5d667291905f47f62b262e54..e1c86ba157b34d576c4c7e4bd123606bbaa845d4 100644 (file)
@@ -293,7 +293,7 @@ DetectBytetestData *DetectBytetestParse(char *optstr, char **value, char **offse
 
     /* Initialize the data */
     data = SCMalloc(sizeof(DetectBytetestData));
-    if (data == NULL)
+    if (unlikely(data == NULL))
         goto error;
     data->base = DETECT_BYTETEST_BASE_UNSET;
     data->flags = 0;
@@ -1394,7 +1394,7 @@ int DetectByteTestTestPacket03(void)
     uint8_t *buf = NULL;
     uint16_t buflen = 0;
     buf = SCMalloc(4);
-    if (buf == NULL) {
+    if (unlikely(buf == NULL)) {
         printf("malloc failed\n");
         exit(EXIT_FAILURE);
     }
index 7ff1dd90c91693194463a4e3bacda8e074a8b905..f09c77686c4ed33de75a879e747b77e5b434ffce 100644 (file)
@@ -222,7 +222,7 @@ DetectContentData *DetectContentParse (char *contentstr)
     }
 
     cd = SCMalloc(sizeof(DetectContentData) + len);
-    if (cd == NULL) {
+    if (unlikely(cd == NULL)) {
         SCFree(str);
         exit(EXIT_FAILURE);
     }
@@ -620,7 +620,7 @@ int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, ch
     int result = 0;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
 
index 418f87c67de4191823f5a5935007aec21994d7b3..3b7cac724111a312f4712a4f5a5459a9d2df033d 100644 (file)
@@ -186,13 +186,13 @@ static int DetectCsumParseArg(const char *key, DetectCsumData *cd)
 
     if (key[0] == '\"' && key[strlen(key) - 1] == '\"') {
         str = SCStrdup(key + 1);
-        if (str == NULL) {
+        if (unlikely(str == NULL)) {
             goto error;
         }
         str[strlen(key) - 2] = '\0';
     } else {
         str = SCStrdup(key);
-        if (str == NULL) {
+        if (unlikely(str == NULL)) {
             goto error;
         }
     }
index a6c4b31c0d7fab79019a0364dace2e432bbb2255..c167a301caa94aa63d3e34e7db91fb2890e9fec3 100644 (file)
@@ -62,7 +62,7 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
     /* strip "'s */
     if (depthstr[0] == '\"' && depthstr[strlen(depthstr) - 1] == '\"') {
         str = SCStrdup(depthstr + 1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(depthstr) - 2] = '\0';
         dubbed = 1;
index e4aeed52641e2fa76d84a2fef2475ec7c005aef3..4b74765f15115d0043e340d7a232458738e56344 100644 (file)
@@ -118,7 +118,7 @@ DetectThresholdData *DetectDetectionFilterParse (char *rawstr) {
     int i = 0;
 
     copy_str = SCStrdup(rawstr);
-    if (copy_str == NULL) {
+    if (unlikely(copy_str == NULL)) {
         goto error;
     }
 
@@ -147,7 +147,7 @@ DetectThresholdData *DetectDetectionFilterParse (char *rawstr) {
     }
 
     df = SCMalloc(sizeof(DetectThresholdData));
-    if (df == NULL)
+    if (unlikely(df == NULL))
         goto error;
 
     memset(df,0,sizeof(DetectThresholdData));
index 75220670a45a35151847cdce24028e4f5a9b0cad..10afa11b4c8f6e79ce951a1cf7be7ce59c04b245 100644 (file)
@@ -69,7 +69,7 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
     /* strip "'s */
     if (distancestr[0] == '\"' && distancestr[strlen(distancestr) - 1] == '\"') {
         str = SCStrdup(distancestr + 1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(distancestr) - 2] = '\0';
         dubbed = 1;
index d8a1afcfe715bcf57e651c066a7209fd4f026545..d033fd52f9fb4f5660a97acec18f4d2ad570ad08 100644 (file)
@@ -184,7 +184,7 @@ DetectDsizeData *DetectDsizeParse (char *rawstr)
     }
 
     dd = SCMalloc(sizeof(DetectDsizeData));
-    if (dd == NULL)
+    if (unlikely(dd == NULL))
         goto error;
     dd->dsize = 0;
     dd->dsize2 = 0;
@@ -720,7 +720,7 @@ int DetectDsizeIcmpv6Test01 (void) {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     IPV6Hdr ip6h;
     ThreadVars tv;
index 001fd7ba8527a7a8696ef735e1af70b3265c3ca1..b90a23a8cfff4e4595909fef5850a9a1021c6db3 100644 (file)
@@ -73,7 +73,7 @@ static uint32_t detect_address_group_head_free_cnt = 0;
 DetectAddress *DetectAddressInit(void)
 {
     DetectAddress *ag = SCMalloc(sizeof(DetectAddress));
-    if (ag == NULL)
+    if (unlikely(ag == NULL))
         return NULL;
     memset(ag, 0, sizeof(DetectAddress));
 
@@ -602,7 +602,7 @@ int DetectAddressParseString(DetectAddress *dd, char *str)
     char *mask = NULL;
     int r = 0;
 
-    if (ipdup == NULL)
+    if (unlikely(ipdup == NULL))
         return -1;
     SCLogDebug("str %s", str);
 
@@ -978,7 +978,7 @@ int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
                 temp_rule_var_address = rule_var_address;
                 if ((negate + n_set) % 2) {
                     temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
-                    if (temp_rule_var_address == NULL)
+                    if (unlikely(temp_rule_var_address == NULL))
                         goto error;
                     snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
                              "[%s]", rule_var_address);
@@ -1027,7 +1027,7 @@ int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
                 temp_rule_var_address = rule_var_address;
                 if ((negate + n_set) % 2) {
                     temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
-                    if (temp_rule_var_address == NULL)
+                    if (unlikely(temp_rule_var_address == NULL))
                         goto error;
                     snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
                             "[%s]", rule_var_address);
@@ -1344,7 +1344,7 @@ error:
 DetectAddressHead *DetectAddressHeadInit(void)
 {
     DetectAddressHead *gh = SCMalloc(sizeof(DetectAddressHead));
-    if (gh == NULL)
+    if (unlikely(gh == NULL))
         return NULL;
     memset(gh, 0, sizeof(DetectAddressHead));
 
index bde932042a979a23a6b715174a85a904ad1885d1..d276313de8f583536bef455a1ce09effae7f84f4 100644 (file)
@@ -168,7 +168,7 @@ DetectEngineEventData *DetectEngineEventParse (char *rawstr)
     }
 
     de = SCMalloc(sizeof(DetectEngineEventData));
-    if (de == NULL)
+    if (unlikely(de == NULL))
         goto error;
 
     de->event = DEvents[i].code;
@@ -335,7 +335,7 @@ int EngineEventTestParse05 (void) {
  */
 int EngineEventTestParse06 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
index 355b2b4ef7ba0f55051ac8bfedd099f7d5e858a1..c14c610d2208e96d7df080f3021cad6a8386dab6 100644 (file)
@@ -70,7 +70,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRItemNew() {
     IPOnlyCIDRItem *item = NULL;
 
     item = SCMalloc(sizeof(IPOnlyCIDRItem));
-    if (item == NULL)
+    if (unlikely(item == NULL))
         SCReturnPtr(NULL, "NULL");
     memset(item, 0, sizeof(IPOnlyCIDRItem));
 
@@ -108,7 +108,7 @@ static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, char *str)
     char *mask = NULL;
     int r = 0;
 
-    if (ipdup == NULL)
+    if (unlikely(ipdup == NULL))
         return -1;
     SCLogDebug("str %s", str);
 
@@ -508,7 +508,7 @@ static SigNumArray *SigNumArrayNew(DetectEngineCtx *de_ctx,
 {
     SigNumArray *new = SCMalloc(sizeof(SigNumArray));
 
-    if (new == NULL){
+    if (unlikely(new == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayNew. Exiting...");
         exit(EXIT_FAILURE);
     }
@@ -538,7 +538,7 @@ static SigNumArray *SigNumArrayNew(DetectEngineCtx *de_ctx,
 static SigNumArray *SigNumArrayCopy(SigNumArray *orig) {
     SigNumArray *new = SCMalloc(sizeof(SigNumArray));
 
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayCopy. Exiting...");
         exit(EXIT_FAILURE);
     }
@@ -638,7 +638,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(char *s, int negate)
                 if ((negate + n_set) % 2) {
                     temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
 
-                    if (temp_rule_var_address == NULL) {
+                    if (unlikely(temp_rule_var_address == NULL)) {
                         goto error;
                     }
 
@@ -697,7 +697,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(char *s, int negate)
                 temp_rule_var_address = rule_var_address;
                 if ((negate + n_set) % 2) {
                     temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
-                    if (temp_rule_var_address == NULL) {
+                    if (unlikely(temp_rule_var_address == NULL)) {
                         goto error;
                     }
                     snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
index 3646643a7f7e1c348eeb637f123815238c41e9de..b0f3170b6eb2c03916cedab311a535ebb73f4fe3 100644 (file)
@@ -1129,7 +1129,7 @@ char UricontentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t
 
 ContentHash *ContentHashAlloc(DetectContentData *ptr) {
     ContentHash *ch = SCMalloc(sizeof(ContentHash));
-    if (ch == NULL)
+    if (unlikely(ch == NULL))
         return NULL;
 
     ch->ptr = ptr;
@@ -1141,7 +1141,7 @@ ContentHash *ContentHashAlloc(DetectContentData *ptr) {
 
 UricontentHash *UricontentHashAlloc(DetectContentData *ptr) {
     UricontentHash *ch = SCMalloc(sizeof(UricontentHash));
-    if (ch == NULL)
+    if (unlikely(ch == NULL))
         return NULL;
 
     ch->ptr = ptr;
@@ -2948,7 +2948,7 @@ uint32_t DetectPatternGetId(MpmPatternIdStore *ht, void *ctx, uint8_t sm_list)
     PatIntId id = 0;
 
     e = SCMalloc(sizeof(MpmPatternIdTableElmt));
-    if (e == NULL) {
+    if (unlikely(e == NULL)) {
         exit(EXIT_FAILURE);
     }
 
index afa7e88bdbb5cec9a8c26e146ae2429c30dbb469..1b8c10445ea841414b8a35bcab8b71234b6d2726 100644 (file)
@@ -67,7 +67,7 @@ static uint32_t detect_port_free_cnt = 0;
  */
 DetectPort *DetectPortInit(void) {
     DetectPort *dp = SCMalloc(sizeof(DetectPort));
-    if (dp == NULL)
+    if (unlikely(dp == NULL))
         return NULL;
     memset(dp, 0, sizeof(DetectPort));
 
@@ -1059,7 +1059,7 @@ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
                 temp_rule_var_port = rule_var_port;
                 if (negate == 1 || n_set == 1) {
                     temp_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
-                    if (temp_rule_var_port == NULL)
+                    if (unlikely(temp_rule_var_port == NULL))
                         goto error;
                     snprintf(temp_rule_var_port, strlen(rule_var_port) + 3,
                              "[%s]", rule_var_port);
@@ -1115,7 +1115,7 @@ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
                 temp_rule_var_port = rule_var_port;
                 if ((negate + n_set) % 2) {
                     temp_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
-                    if (temp_rule_var_port == NULL)
+                    if (unlikely(temp_rule_var_port == NULL))
                         goto error;
                     snprintf(temp_rule_var_port, strlen(rule_var_port) + 3,
                             "[%s]", rule_var_port);
@@ -1383,7 +1383,7 @@ DetectPort *PortParse(char *str) {
     char *port2 = NULL;
     DetectPort *dp = NULL;
 
-    if (portdup == NULL) {
+    if (unlikely(portdup == NULL)) {
         return NULL;
     }
     dp = DetectPortInit();
index 952896467220c329b95e1b499ec0feac658777ea..7994e486e6f4e2d9f770e0f9c8183750ed1c51de 100644 (file)
@@ -54,7 +54,7 @@
 DetectProto *DetectProtoInit(void)
 {
     DetectProto *dp = SCMalloc(sizeof(DetectProto));
-    if (dp == NULL)
+    if (unlikely(dp == NULL))
         return NULL;
     memset(dp,0,sizeof(DetectProto));
 
index 8c833bd76bdfb25d458a3c2d3909c0345aa58c89..c5344497ceea0bca72ab09dae20b5edc84c53daf 100644 (file)
@@ -92,7 +92,7 @@ void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid) {
 
 static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size) {
     SigGroupHeadInitData *sghid = SCMalloc(sizeof(SigGroupHeadInitData));
-    if (sghid == NULL)
+    if (unlikely(sghid == NULL))
         return NULL;
 
     memset(sghid, 0x00, sizeof(SigGroupHeadInitData));
@@ -142,7 +142,7 @@ void SigGroupHeadStore(DetectEngineCtx *de_ctx, SigGroupHead *sgh) {
 static SigGroupHead *SigGroupHeadAlloc(DetectEngineCtx *de_ctx, uint32_t size)
 {
     SigGroupHead *sgh = SCMalloc(sizeof(SigGroupHead));
-    if (sgh == NULL)
+    if (unlikely(sgh == NULL))
         return NULL;
     memset(sgh, 0, sizeof(SigGroupHead));
 
index 5bf178cb66501e177a433c797b7ca3d471b2fa74..3b24b02d578185c8ffa6eeb79eee0377043b1c87 100644 (file)
@@ -130,7 +130,7 @@ DeStateStore *DeStateStoreAlloc(void) {
     SCEnter();
 
     DeStateStore *d = SCMalloc(sizeof(DeStateStore));
-    if (d == NULL) {
+    if (unlikely(d == NULL)) {
         SCReturnPtr(NULL, "DeStateStore");
     }
     memset(d, 0x00, sizeof(DeStateStore));
@@ -165,7 +165,7 @@ DetectEngineState *DetectEngineStateAlloc(void) {
     SCEnter();
 
     DetectEngineState *d = SCMalloc(sizeof(DetectEngineState));
-    if (d == NULL) {
+    if (unlikely(d == NULL)) {
         SCReturnPtr(NULL, "DetectEngineState");
     }
     memset(d, 0x00, sizeof(DetectEngineState));
index 08fca69e6c8e16b7bebb28c7f7ca3c9966f5429e..63d930a71d50a867f706f7ce02b67bf273400e8e 100644 (file)
@@ -65,7 +65,7 @@ void TagRestartCtx() {
 
 static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
     DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
-    if (tde == NULL) {
+    if (unlikely(tde == NULL)) {
         return NULL;
     }
     memset(tde, 0, sizeof(DetectTagDataEntry));
index a06338cd6f8c487f23c6d748b121dd426e190828..3c69609089759f5dc057c6099dcd7d32ec39d634 100644 (file)
@@ -175,7 +175,7 @@ static inline DetectThresholdEntry *DetectThresholdEntryAlloc(DetectThresholdDat
     SCEnter();
 
     DetectThresholdEntry *ste = SCMalloc(sizeof(DetectThresholdEntry));
-    if (ste == NULL) {
+    if (unlikely(ste == NULL)) {
         SCReturnPtr(NULL, "DetectThresholdEntry");
     }
 
index 1db62a5b4382c6a912483b79180e057cd3fca4cb..0f280cd86ecc737efa83bf457810bf17083ff176 100644 (file)
@@ -349,7 +349,7 @@ DetectEngineCtx *DetectEngineCtxInit(void) {
     char *insp_recursion_limit = NULL;
 
     de_ctx = SCMalloc(sizeof(DetectEngineCtx));
-    if (de_ctx == NULL)
+    if (unlikely(de_ctx == NULL))
         goto error;
 
     memset(de_ctx,0,sizeof(DetectEngineCtx));
@@ -741,7 +741,7 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) {
         return TM_ECODE_FAILED;
 
     DetectEngineThreadCtx *det_ctx = SCMalloc(sizeof(DetectEngineThreadCtx));
-    if (det_ctx == NULL)
+    if (unlikely(det_ctx == NULL))
         return TM_ECODE_FAILED;
     memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
 
@@ -828,7 +828,7 @@ static TmEcode DetectEngineThreadCtxInitForLiveRuleSwap(ThreadVars *tv, void *in
         return TM_ECODE_FAILED;
 
     DetectEngineThreadCtx *det_ctx = SCMalloc(sizeof(DetectEngineThreadCtx));
-    if (det_ctx == NULL)
+    if (unlikely(det_ctx == NULL))
         return TM_ECODE_FAILED;
     memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
 
@@ -981,7 +981,7 @@ int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void
     BUG_ON(de_ctx == NULL || InitFunc == NULL || FreeFunc == NULL || data == NULL);
 
     DetectEngineThreadKeywordCtxItem *item = SCMalloc(sizeof(DetectEngineThreadKeywordCtxItem));
-    if (item == NULL)
+    if (unlikely(item == NULL))
         return -1;
     memset(item, 0x00, sizeof(DetectEngineThreadKeywordCtxItem));
 
index 994cd20ae829143abc88bfdc56d016be330bbf15..1a9781aae5252b3716affc561b16688951041777 100644 (file)
@@ -67,7 +67,7 @@ static void SupportFastPatternForSigMatchList(int list_id)
     }
 
     SCFPSupportSMList *new_smlist_fp = SCMalloc(sizeof(SCFPSupportSMList));
-    if (new_smlist_fp == NULL) {
+    if (unlikely(new_smlist_fp == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
index 520f60881caecec965b8e34c5ffd1803b8f8dc56..80a5cef53a99faf5e7c27455f08dc58f7e34af69 100644 (file)
@@ -139,7 +139,7 @@ static DetectFileextData *DetectFileextParse (char *str)
 
     /* We have a correct filename option */
     fileext = SCMalloc(sizeof(DetectFileextData));
-    if (fileext == NULL)
+    if (unlikely(fileext == NULL))
         goto error;
 
     memset(fileext, 0x00, sizeof(DetectFileextData));
index ed2e78fa5359fa6e98312e6d8f675e64250faefa..3100308bffc0e1df084b28208e7c12480f9f7323 100644 (file)
@@ -201,7 +201,7 @@ static DetectFilemagicData *DetectFilemagicParse (char *str)
 
     /* We have a correct filemagic option */
     filemagic = SCMalloc(sizeof(DetectFilemagicData));
-    if (filemagic == NULL)
+    if (unlikely(filemagic == NULL))
         goto error;
 
     memset(filemagic, 0x00, sizeof(DetectFilemagicData));
index 6ceece9b9ea1e5c82343004017e302b0e27a0521..27c9ee3d1f2df828a8f4607ab4136c16d67632bd 100644 (file)
@@ -218,7 +218,7 @@ static DetectFileMd5Data *DetectFileMd5Parse (char *str)
 
     /* We have a correct filemd5 option */
     filemd5 = SCMalloc(sizeof(DetectFileMd5Data));
-    if (filemd5 == NULL)
+    if (unlikely(filemd5 == NULL))
         goto error;
 
     memset(filemd5, 0x00, sizeof(DetectFileMd5Data));
index 2940f17c013328102dc1655e5fda9e3e93dbbce6..31fc0b6c6ce6d23fb1c9afe8ef7b41e52a9f61c9 100644 (file)
@@ -144,7 +144,7 @@ static DetectFilenameData *DetectFilenameParse (char *str)
 
     /* We have a correct filename option */
     filename = SCMalloc(sizeof(DetectFilenameData));
-    if (filename == NULL)
+    if (unlikely(filename == NULL))
         goto error;
 
     memset(filename, 0x00, sizeof(DetectFilenameData));
index 1b7c77cee91eb0ae4707939900c925b169e123e7..a56c8a068880427af137b92853cbe4fc5ff71195 100644 (file)
@@ -211,8 +211,8 @@ static DetectFilesizeData *DetectFilesizeParse (char *str)
     }
 
     fsd = SCMalloc(sizeof (DetectFilesizeData));
-    if (fsd == NULL)
-        goto error;
+    if (unlikely(fsd == NULL))
+    goto error;
     memset(fsd, 0, sizeof(DetectFilesizeData));
 
     if (arg1[0] == '<')
index d39cf08eaeb9e0fbcdef6308f3e01028bf60c105..535e22d44c6d739d8429207cfe1666f10d997a24 100644 (file)
@@ -354,7 +354,7 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, char *st
         }
 
         fd = SCMalloc(sizeof(DetectFilestoreData));
-        if (fd == NULL)
+        if (unlikely(fd == NULL))
             goto error;
         memset(fd, 0x00, sizeof(DetectFilestoreData));
 
index f5ae3141f0dbe541756557bcc66a9e9a7a1fb332..f47f5cd955c5ae8668255bc0f24ca58c5865d8b5 100644 (file)
@@ -206,7 +206,7 @@ static DetectFlagsData *DetectFlagsParse (char *rawstr)
     }
 
     de = SCMalloc(sizeof(DetectFlagsData));
-    if (de == NULL)
+    if (unlikely(de == NULL))
         goto error;
 
     memset(de,0,sizeof(DetectFlagsData));
@@ -567,7 +567,7 @@ static int FlagsTestParse02 (void) {
  */
 static int FlagsTestParse03 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -622,7 +622,7 @@ error:
  */
 static int FlagsTestParse04 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -677,7 +677,7 @@ error:
  */
 static int FlagsTestParse05 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -732,7 +732,7 @@ error:
  */
 static int FlagsTestParse06 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -787,7 +787,7 @@ error:
  */
 static int FlagsTestParse07 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -842,7 +842,7 @@ error:
  */
 static int FlagsTestParse08 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -897,7 +897,7 @@ error:
  */
 static int FlagsTestParse09 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -952,7 +952,7 @@ error:
  */
 static int FlagsTestParse10 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -1007,7 +1007,7 @@ error:
  */
 static int FlagsTestParse11 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -1062,7 +1062,7 @@ error:
  */
 static int FlagsTestParse12 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -1148,7 +1148,7 @@ static int FlagsTestParse14(void)
 static int FlagsTestParse15(void)
 {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -1202,7 +1202,7 @@ error:
 static int FlagsTestParse16(void)
 {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -1259,7 +1259,7 @@ error:
 static int FlagsTestParse17(void)
 {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
index d437421d52259d786d02386a8f7ec4827685360f..a22659663e1bf336205570279f36a9008c07ea43 100644 (file)
@@ -199,7 +199,7 @@ DetectFlowData *DetectFlowParse (char *flowstr)
     }
 
     fd = SCMalloc(sizeof(DetectFlowData));
-    if (fd == NULL)
+    if (unlikely(fd == NULL))
         goto error;
     fd->flags = 0;
     fd->match_cnt = 0;
index 30c13497f98f25774ae25a3219febf2664a8fd94..9d97bab2f015047ab89d6f05b790d19999f5db50 100644 (file)
@@ -226,7 +226,7 @@ int DetectFlowbitSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
     }
 
     cd = SCMalloc(sizeof(DetectFlowbitsData));
-    if (cd == NULL)
+    if (unlikely(cd == NULL))
         goto error;
 
     cd->idx = VariableNameGetIdx(de_ctx, fb_name, DETECT_FLOWBITS);
@@ -306,7 +306,7 @@ static int FlowBitsTestSig01(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -381,7 +381,7 @@ static int FlowBitsTestSig02(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -503,7 +503,7 @@ static int FlowBitsTestSig03(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -581,7 +581,7 @@ static int FlowBitsTestSig04(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -663,7 +663,7 @@ static int FlowBitsTestSig05(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -742,7 +742,7 @@ static int FlowBitsTestSig06(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -846,7 +846,7 @@ static int FlowBitsTestSig07(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -953,7 +953,7 @@ static int FlowBitsTestSig08(void) {
                     "\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
index 2798c272e816c1a8b13b2a3a2824b159548b5306..61b6f984bf135be1d72934a553fee9db89e74905 100644 (file)
@@ -291,7 +291,7 @@ DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx,
     }
 
     sfd = SCMalloc(sizeof(DetectFlowintData));
-    if (sfd == NULL)
+    if (unlikely(sfd == NULL))
         goto error;
 
     /* If we need another arg, check it out(isset doesn't need another arg) */
@@ -311,7 +311,7 @@ DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx,
         /* get the target value to operate with
         *(it should be a value or another var) */
         str = SCStrdup(varval);
-        if (str == NULL) {
+        if (unlikely(str == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "malloc from strdup failed");
             goto error;
         }
@@ -1322,7 +1322,7 @@ int DetectFlowintTestPacket01Real()
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
     ThreadVars th_v;
@@ -1656,7 +1656,7 @@ int DetectFlowintTestPacket02Real()
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
 
@@ -1994,7 +1994,7 @@ int DetectFlowintTestPacket03Real()
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
 
index ed7e7de135969bf7e2ae9641e14ac15b2ad6f1da..744376817efbb3b1e56fde319b68a6a06b438799 100644 (file)
@@ -140,7 +140,7 @@ static int DetectFlowvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *raws
 
     if (varcontent[0] == '\"' && varcontent[strlen(varcontent)-1] == '\"') {
         str = SCStrdup(varcontent+1);
-        if (str == NULL) {
+        if (unlikely(str == NULL)) {
             return -1;
         }
         str[strlen(varcontent)-2] = '\0';
@@ -154,7 +154,7 @@ static int DetectFlowvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *raws
     }
 
     cd = SCMalloc(sizeof(DetectFlowvarData));
-    if (cd == NULL)
+    if (unlikely(cd == NULL))
         goto error;
 
     char converted = 0;
index 127d61d58b02b06bdf0e72b7ab0b2e16634d8601..e61f0b45ef4e0745ea763ff110a30f54640422ae 100644 (file)
@@ -193,7 +193,7 @@ static DetectFragBitsData *DetectFragBitsParse (char *rawstr)
     }
 
     de = SCMalloc(sizeof(DetectFragBitsData));
-    if (de == NULL)
+    if (unlikely(de == NULL))
         goto error;
 
     memset(de,0,sizeof(DetectFragBitsData));
@@ -403,7 +403,7 @@ static int FragBitsTestParse03 (void) {
         0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b,
         0x51};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -500,7 +500,7 @@ static int FragBitsTestParse04 (void) {
         0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b,
         0x51};
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 785bed841bb669cf9acdbaf56a64bbf5ce45bf8e..3d6f528959acf59cdb6292c1d359861ee87ca921 100644 (file)
@@ -159,7 +159,7 @@ DetectFragOffsetData *DetectFragOffsetParse (char *fragoffsetstr) {
     }
 
     fragoff = SCMalloc(sizeof(DetectFragOffsetData));
-    if (fragoff == NULL)
+    if (unlikely(fragoff == NULL))
         goto error;
 
     fragoff->frag_off = 0;
@@ -302,7 +302,7 @@ int DetectFragOffsetParseTest03 (void) {
 int DetectFragOffsetMatchTest01 (void) {
     int result = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     DecodeThreadVars dtv;
index e53bcdebae070d93912e94692d188ab10f38f234..80379bc317105648150d7a856937a0cbe0f194e8 100644 (file)
@@ -448,7 +448,7 @@ static int DetectFtpbounceTestALMatch03(void) {
     TcpSession ssn;
     Flow f;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     ThreadVars th_v;
index 4ff1792d6177542c2b4af1335a0c747d8709920e..62f977e1e2e7b468ef6179c6e9fb6bee107e3e3f 100644 (file)
@@ -170,7 +170,7 @@ DetectIcmpIdData *DetectIcmpIdParse (char *icmpidstr) {
     }
 
     iid = SCMalloc(sizeof(DetectIcmpIdData));
-    if (iid == NULL)
+    if (unlikely(iid == NULL))
         goto error;
     iid->id = 0;
 
@@ -407,7 +407,7 @@ int DetectIcmpIdMatchTest02 (void) {
         0x00, 0x14, 0x00, 0x00 };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Signature *s = NULL;
     DecodeThreadVars dtv;
index 548184bffacecac24ebb07b217cbd0684b04db29..34afe3bb6484bdda454665ece396f0cd6b50215b 100644 (file)
@@ -170,7 +170,7 @@ DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) {
     }
 
     iseq = SCMalloc(sizeof(DetectIcmpSeqData));
-    if (iseq == NULL)
+    if (unlikely(iseq == NULL))
         goto error;
 
     iseq->seq = 0;
index 1a3362405d9d64f45490dbb36ea9d206e051954c..9a3112c865b5a95ffa8d40e9b6c0de03311846fc 100644 (file)
@@ -163,7 +163,7 @@ DetectICodeData *DetectICodeParse(char *icodestr) {
     }
 
     icd = SCMalloc(sizeof(DetectICodeData));
-    if (icd == NULL)
+    if (unlikely(icd == NULL))
         goto error;
     icd->code1 = 0;
     icd->code2 = 0;
index a7973b15fb884b29cfef61612fdb9f19bdc9e44b..38005083eabd424965f56f599e30bba76147b6c4 100644 (file)
@@ -161,11 +161,11 @@ DetectIdData *DetectIdParse (char *idstr)
 
         /* We have a correct id option */
         id_d = SCMalloc(sizeof(DetectIdData));
-        if (id_d == NULL)
+        if (unlikely(id_d == NULL))
             goto error;
 
         orig = SCStrdup((char*)str_ptr);
-        if (orig == NULL) {
+        if (unlikely(orig == NULL)) {
             goto error;
         }
         tmp_str=orig;
index b6c7384418005ba006e1cb9ae4b9c39a916abd39..a59aa377cbc2a63a0c3bae7151519c2bb2e607b8 100644 (file)
@@ -161,7 +161,7 @@ DetectIpOptsData *DetectIpOptsParse (char *rawstr)
         goto error;
 
     de = SCMalloc(sizeof(DetectIpOptsData));
-    if (de == NULL)
+    if (unlikely(de == NULL))
         goto error;
 
     de->ipopt = DIpOpts[i].code;
@@ -269,7 +269,7 @@ int IpOptsTestParse02 (void) {
  */
 int IpOptsTestParse03 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
@@ -321,7 +321,7 @@ error:
  */
 int IpOptsTestParse04 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     int ret = 0;
index 419f2d67ba0ca0487a8859abda73ae29c58d7119..11e5f5a3e9496ca2958b370a8d832662faf3ff7c 100644 (file)
@@ -129,7 +129,7 @@ static DetectIPProtoData *DetectIPProtoParse(const char *optstr)
 
     /* Initialize the data */
     data = SCMalloc(sizeof(DetectIPProtoData));
-    if (data == NULL)
+    if (unlikely(data == NULL))
         goto error;
     data->op = DETECT_IPPROTO_OP_EQ;
     data->proto = 0;
@@ -8867,7 +8867,7 @@ static int DetectIPProtoTestSig2(void)
     };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
index ba4773693fab9454e50102f84e8cd2aeb4a65abc..2a4f59aee0e53cd325cb0cd37b2bd591e2d1fc7e 100644 (file)
@@ -176,7 +176,7 @@ DetectIsdataatData *DetectIsdataatParse (char *isdataatstr, char **offset)
         }
 
         idad = SCMalloc(sizeof(DetectIsdataatData));
-        if (idad == NULL)
+        if (unlikely(idad == NULL))
             goto error;
 
         idad->flags = 0;
index 7941ebbd969a4b058d8fc7b5436ae135e568c513..f59cd1a3ebdd5377a26f4bc4d7c75676fdd98157 100644 (file)
@@ -163,7 +163,7 @@ DetectITypeData *DetectITypeParse(char *itypestr) {
     }
 
     itd = SCMalloc(sizeof(DetectITypeData));
-    if (itd == NULL)
+    if (unlikely(itd == NULL))
         goto error;
     itd->type1 = 0;
     itd->type2 = 0;
index 14329130301cda2616bade51afc80bdf92157b56..cb208e04a10dda1a3652e6c42c7b5508fbf5a9e5 100644 (file)
@@ -76,7 +76,7 @@ static int DetectL3ProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
     /* strip "'s */
     if (optstr[0] == '\"' && optstr[strlen(optstr) - 1] == '\"') {
         str = SCStrdup(optstr + 1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(optstr) - 2] = '\0';
         dubbed = 1;
@@ -133,7 +133,7 @@ error:
 static int DetectL3protoTestSig1(void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -218,7 +218,7 @@ end:
 static int DetectL3protoTestSig2(void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature *s = NULL;
     ThreadVars th_v;
@@ -302,7 +302,7 @@ end:
 static int DetectL3protoTestSig3(void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature *s = NULL;
     ThreadVars th_v;
index 572d4ba77dc83007fb7ef5b9643b45019a68e2c1..64ec14ed8807fd4d30be5e7b5ea1bb8e547f1ef5 100644 (file)
@@ -461,7 +461,7 @@ static void *DetectLuajitThreadInit(void *data) {
     BUG_ON(luajit == NULL);
 
     DetectLuajitThreadData *t = SCMalloc(sizeof(DetectLuajitThreadData));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         SCLogError(SC_ERR_LUAJIT_ERROR, "couldn't alloc ctx memory");
         return NULL;
     }
@@ -522,7 +522,7 @@ static DetectLuajitData *DetectLuajitParse (char *str)
 
     /* We have a correct luajit option */
     luajit = SCMalloc(sizeof(DetectLuajitData));
-    if (luajit == NULL)
+    if (unlikely(luajit == NULL))
         goto error;
 
     memset(luajit, 0x00, sizeof(DetectLuajitData));
index 0e24e10fc160275cf87aba330bad1a5afacacf25..926c1a6e9aeab04c89a0ff4cfcd0b7ab86322299 100644 (file)
@@ -148,7 +148,7 @@ static void * DetectMarkParse (char *rawstr)
 
     if (ptr == NULL) {
         data = SCMalloc(sizeof(DetectMarkData));
-        if (data == NULL) {
+        if (unlikely(data == NULL)) {
             return NULL;
         }
         data->mark = mark;
@@ -179,7 +179,7 @@ static void * DetectMarkParse (char *rawstr)
     SCFree(ptr);
 
     data = SCMalloc(sizeof(DetectMarkData));
-    if (data == NULL) {
+    if (unlikely(data == NULL)) {
         return NULL;
     }
     data->mark = mark;
index c3254fc79b8455d42ee061e5291ff3060bb8389b..4bcd65d83da443127f943540c517d70a5ff50db4 100644 (file)
@@ -55,13 +55,13 @@ static int DetectMsgSetup (DetectEngineCtx *de_ctx, Signature *s, char *msgstr)
     /* strip "'s */
     if (msgstr[0] == '\"' && msgstr[strlen(msgstr)-1] == '\"') {
         str = SCStrdup(msgstr+1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(msgstr)-2] = '\0';
     } else if (msgstr[1] == '\"' && msgstr[strlen(msgstr)-1] == '\"') {
         /* XXX do this parsing in a better way */
         str = SCStrdup(msgstr+2);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(msgstr)-3] = '\0';
         //printf("DetectMsgSetup: format hack applied: \'%s\'\n", str);
index d331b0a57957b27e719174914a3de66092c89620..e5412d7a35fbd3f7963b0d5fcc00d496c6cc6eae 100644 (file)
@@ -60,7 +60,7 @@ int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *offsetstr)
     /* strip "'s */
     if (offsetstr[0] == '\"' && offsetstr[strlen(offsetstr)-1] == '\"') {
         str = SCStrdup(offsetstr+1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(offsetstr)-2] = '\0';
         dubbed = 1;
index 19ac780a9dc3d3bceb7b41417ab4eb7f5364c3b3..a52176e2db7de78aedff2c7388162416e0ffc9e8 100644 (file)
@@ -105,7 +105,7 @@ uint32_t DbgGetDstPortAnyCnt(void) {
 
 SigMatch *SigMatchAlloc(void) {
     SigMatch *sm = SCMalloc(sizeof(SigMatch));
-    if (sm == NULL)
+    if (unlikely(sm == NULL))
         return NULL;
 
     memset(sm, 0, sizeof(SigMatch));
@@ -369,8 +369,8 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr)
     char *optname = NULL, *optvalue = NULL, *optmore = NULL;
 
     const char **arr = SCCalloc(OPTION_PARTS+1, sizeof(char *));
-    if (arr == NULL)
-        return -1;
+    if (unlikely(arr == NULL))
+    return -1;
 
     ret = pcre_exec(option_pcre, option_pcre_extra, optstr, strlen(optstr), 0, 0, ov, MAX_SUBSTRINGS);
     /* if successful, we either have:
@@ -653,8 +653,8 @@ static int SigParseBasics(Signature *s, char *sigstr, char ***result, uint8_t ad
     int ret = 0, i = 0;
 
     const char **arr = SCCalloc(CONFIG_PARTS + 1, sizeof(char *));
-    if (arr == NULL)
-        return -1;
+    if (unlikely(arr == NULL))
+    return -1;
 
     ret = pcre_exec(config_pcre, config_pcre_extra, sigstr, strlen(sigstr), 0, 0, ov, MAX_SUBSTRINGS);
     if (ret != 8 && ret != 9) {
@@ -784,7 +784,7 @@ int SigParse(DetectEngineCtx *de_ctx, Signature *s, char *sigstr, uint8_t addrs_
 
 Signature *SigAlloc (void) {
     Signature *sig = SCMalloc(sizeof(Signature));
-    if (sig == NULL)
+    if (unlikely(sig == NULL))
         return NULL;
 
     memset(sig, 0, sizeof(Signature));
@@ -1467,7 +1467,7 @@ static inline int DetectEngineSignatureIsDuplicate(DetectEngineCtx *de_ctx,
 
     /* used for making a duplicate_sig_hash_table entry */
     sw = SCMalloc(sizeof(SigDuplWrapper));
-    if (sw == NULL) {
+    if (unlikely(sw == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(sw, 0, sizeof(SigDuplWrapper));
@@ -1794,7 +1794,7 @@ int DetectParseContentString (char *contentstr, uint8_t **result, uint16_t *resu
     }
 
     content = SCMalloc(len);
-    if (content == NULL) {
+    if (unlikely(content == NULL)) {
         exit(EXIT_FAILURE);
     }
 
@@ -2786,7 +2786,7 @@ int SigTestBidirec04 (void) {
         0x76,0x65,0x0d,0x0a,0x0d,0x0a }; /* end rawpkt1_ether */
 
     p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
     ThreadVars th_v;
index e12880efa2ba7e6bc6cbd288e4fe6030826aca3f..a0c51e34a7f8a38a30dc2b6298297348f6823dcc 100644 (file)
@@ -309,7 +309,7 @@ DetectPcreData *DetectPcreParse (DetectEngineCtx *de_ctx, char *regexstr)
     //printf("ret %" PRId32 " re \'%s\', op \'%s\'\n", ret, re, op);
 
     pd = SCMalloc(sizeof(DetectPcreData));
-    if (pd == NULL)
+    if (unlikely(pd == NULL))
         goto error;
     memset(pd, 0, sizeof(DetectPcreData));
 
index 6973ede5a7f3816795ab5cd1e2c166392f71bcb1..fb14f68bdfd5a93bb3cce374ac1b6eed13c9f815 100644 (file)
@@ -136,7 +136,7 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst
 
     if (varcontent[0] == '\"' && varcontent[strlen(varcontent)-1] == '\"') {
         str = SCStrdup(varcontent+1);
-        if (str == NULL) {
+        if (unlikely(str == NULL)) {
             return -1;
         }
         str[strlen(varcontent)-2] = '\0';
@@ -150,7 +150,7 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst
     }
 
     cd = SCMalloc(sizeof(DetectPktvarData));
-    if (cd == NULL)
+    if (unlikely(cd == NULL))
         goto error;
 
     char converted = 0;
index 284324118809dc553932dc2ae42398092f77651b..08303ebc36d078e1b6e16a5b41a635cbbe1cda4e 100644 (file)
@@ -128,7 +128,7 @@ static DetectReference *DetectReferenceParse(char *rawstr, DetectEngineCtx *de_c
     }
 
     ref = SCMalloc(sizeof(DetectReference));
-    if (ref == NULL) {
+    if (unlikely(ref == NULL)) {
         goto error;
     }
     memset(ref, 0, sizeof(DetectReference));
index aa8fa06542b2b61d39caa724caf83fefc15a8ab9..6b06875a0f64aa30828c2b44bc7ecfeaf5c09de6 100644 (file)
@@ -155,7 +155,7 @@ DetectReplaceList * DetectReplaceAddToList(DetectReplaceList *replist, uint8_t *
     SCLogDebug("replace: Adding match");
 
     newlist = SCMalloc(sizeof(DetectReplaceList));
-    if (newlist == NULL)
+    if (unlikely(newlist == NULL))
         return NULL;
     newlist->found = found;
     newlist->cd = cd;
@@ -218,7 +218,7 @@ int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, ch
 
     Packet *p = NULL;
     p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
 
     DecodeThreadVars dtv;
index 9d5673590774aba29b047a849ae549e72447d856..74cc5a77ad717889124bde537e8f711b2b4e0dc2 100644 (file)
@@ -46,7 +46,7 @@ static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
     /* strip "'s */
     if (rawstr[0] == '\"' && rawstr[strlen(rawstr)-1] == '\"') {
         str = SCStrdup(rawstr+1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             return -1;
 
         str[strlen(rawstr)-2] = '\0';
index 6341c80efbff133fdba0118605050a7050f1162d..8e7d64be50d6421be5387ce141d262e6d74d1f9e 100644 (file)
@@ -200,7 +200,7 @@ DetectRpcData *DetectRpcParse (char *rpcstr)
     }
 
     rd = SCMalloc(sizeof(DetectRpcData));
-    if (rd == NULL)
+    if (unlikely(rd == NULL))
         goto error;
     rd->flags = 0;
     rd->program = 0;
index 064782c1b2234e2e9ffa1edc8eb04397f91f8edc..d757a450dd180650ffb4ef08d3d1967d7b56f24c 100644 (file)
@@ -96,7 +96,7 @@ static int DetectSeqSetup (DetectEngineCtx *de_ctx, Signature *s, char *optstr)
     SigMatch *sm = NULL;
 
     data = SCMalloc(sizeof(DetectSeqData));
-    if (data == NULL)
+    if (unlikely(data == NULL))
         goto error;
 
     sm = SigMatchAlloc();
index 7af28709e9edadabc12e7a2ec274025989b7bf9f..d67c1282fddaa812c25636af7218f57fde8878e4 100644 (file)
@@ -46,7 +46,7 @@ static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, char *sidstr)
     /* strip "'s */
     if (sidstr[0] == '\"' && sidstr[strlen(sidstr)-1] == '\"') {
         str = SCStrdup(sidstr+1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             return -1;
 
         str[strlen(sidstr)-2] = '\0';
index 474959a088d6e11956e6d678fef018c05ceed169..e6e180d940cbed5816e1f0e8c30962b5d27e93f4 100644 (file)
@@ -187,7 +187,7 @@ DetectSshVersionData *DetectSshVersionParse (char *str)
 
         /* We have a correct id option */
         ssh = SCMalloc(sizeof(DetectSshVersionData));
-        if (ssh == NULL)
+        if (unlikely(ssh == NULL))
             goto error;
 
         memset(ssh, 0x00, sizeof(DetectSshVersionData));
index 3161bdcbfc7e64f45bf847f0163ea976cad214fa..d39aaecc0e1beb6e694b2dd7e68a88b868209055 100644 (file)
@@ -176,7 +176,7 @@ DetectSshSoftwareVersionData *DetectSshSoftwareVersionParse (char *str)
 
         /* We have a correct id option */
         ssh = SCMalloc(sizeof(DetectSshSoftwareVersionData));
-        if (ssh == NULL)
+        if (unlikely(ssh == NULL))
             goto error;
 
         ssh->software_ver = (uint8_t *)SCStrdup((char*)str_ptr);
index 186769f5d3c0d9351c917fc8cba230dc8ec60460..5298f509e9aa1477016649480d4a86b839ca2ce8 100644 (file)
@@ -210,7 +210,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
 
         /* We have a correct ssl_version options */
         ssl = SCCalloc(1, sizeof (DetectSslVersionData));
-        if (ssl == NULL)
+        if (unlikely(ssl == NULL))
             goto error;
 
         int i;
@@ -224,7 +224,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
             }
 
             orig = SCStrdup((char*) str_ptr[i]);
-            if (orig == NULL) {
+            if (unlikely(orig == NULL)) {
                 goto error;
             }
             tmp_str = orig;
index be7f39528b03a0633a3792041aec351db78dbf5d..2866d621f296a239fae296f5381d5ce225291f62 100644 (file)
@@ -231,8 +231,8 @@ DetectStreamSizeData *DetectStreamSizeParse (char *streamstr) {
     value = (char *)str_ptr;
 
     sd = SCMalloc(sizeof(DetectStreamSizeData));
-    if (sd == NULL)
-        goto error;
+    if (unlikely(sd == NULL))
+    goto error;
     sd->ssize = 0;
     sd->flags = 0;
 
@@ -386,7 +386,7 @@ static int DetectStreamSizeParseTest03 (void) {
     ThreadVars tv;
     DetectEngineThreadCtx dtx;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature s;
     SigMatch sm;
@@ -463,7 +463,7 @@ static int DetectStreamSizeParseTest04 (void) {
     ThreadVars tv;
     DetectEngineThreadCtx dtx;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature s;
     SigMatch sm;
index 1715eafef85e252bd02bcb73eadef8aecfbdf237..9d7d8590b88828fdb16b1ef1ecb6c6af9a8d85a7 100644 (file)
@@ -271,7 +271,7 @@ DetectTagData *DetectTagParse (char *tagstr)
     }
 
     DetectTagData *real_td = SCMalloc(sizeof(DetectTagData));
-    if (real_td == NULL) {
+    if (unlikely(real_td == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         goto error;
     }
index 035ee71a5781a6e59b6b025c88ba90bad651cedc..8074f3702035b1bf104e8b8c79eadad58a390e50 100644 (file)
@@ -132,7 +132,7 @@ static DetectThresholdData *DetectThresholdParse (char *rawstr)
     int i = 0;
 
     copy_str = SCStrdup(rawstr);
-    if (copy_str == NULL) {
+    if (unlikely(copy_str == NULL)) {
         goto error;
     }
 
@@ -164,7 +164,7 @@ static DetectThresholdData *DetectThresholdParse (char *rawstr)
     }
 
     de = SCMalloc(sizeof(DetectThresholdData));
-    if (de == NULL)
+    if (unlikely(de == NULL))
         goto error;
 
     memset(de,0,sizeof(DetectThresholdData));
index f4435c3e9769078f423ef4167ed753bd763c06a7..ffad7c945d9f965dfebadb631f09360486e63bb4 100644 (file)
@@ -175,11 +175,11 @@ DetectTlsVersionData *DetectTlsVersionParse (char *str)
 
         /* We have a correct id option */
         tls = SCMalloc(sizeof(DetectTlsVersionData));
-        if (tls == NULL)
+        if (unlikely(tls == NULL))
             goto error;
 
         orig = SCStrdup((char*)str_ptr);
-        if (orig == NULL) {
+        if (unlikely(orig == NULL)) {
             goto error;
         }
         tmp_str=orig;
index ae48b3607bb1b246bbfe851339013f534aa70c98..5f4b7835ab2a8d8c4775f2310723ac5207dc185b 100644 (file)
@@ -278,13 +278,13 @@ static DetectTlsData *DetectTlsSubjectParse (char *str)
 
     /* We have a correct id option */
     tls = SCMalloc(sizeof(DetectTlsData));
-    if (tls == NULL)
+    if (unlikely(tls == NULL))
         goto error;
     tls->subject = NULL;
     tls->flags = flag;
 
     orig = SCStrdup((char*)str_ptr);
-    if (orig == NULL) {
+    if (unlikely(orig == NULL)) {
         goto error;
     }
     tmp_str=orig;
@@ -477,13 +477,13 @@ static DetectTlsData *DetectTlsIssuerDNParse(char *str)
 
     /* We have a correct id option */
     tls = SCMalloc(sizeof(DetectTlsData));
-    if (tls == NULL)
+    if (unlikely(tls == NULL))
         goto error;
     tls->issuerdn = NULL;
     tls->flags = flag;
 
     orig = SCStrdup((char*)str_ptr);
-    if (orig == NULL) {
+    if (unlikely(orig == NULL)) {
         goto error;
     }
     tmp_str=orig;
@@ -613,13 +613,13 @@ static DetectTlsData *DetectTlsFingerprintParse (char *str)
 
     /* We have a correct id option */
     tls = SCMalloc(sizeof(DetectTlsData));
-    if (tls == NULL)
+    if (unlikely(tls == NULL))
         goto error;
     tls->fingerprint = NULL;
     tls->flags = flag;
 
     orig = SCStrdup((char*)str_ptr);
-    if (orig == NULL) {
+    if (unlikely(orig == NULL)) {
         goto error;
     }
     tmp_str=orig;
index aa4f9342e778214a1e14d41cc2b1ad41993f6092..90d9e81433800f3efcae8473d58f69c3bfd9d39f 100644 (file)
@@ -175,7 +175,7 @@ DetectTosData *DetectTosParse(char *arg)
     }
 
     tosd = SCMalloc(sizeof(DetectTosData));
-    if (tosd == NULL)
+    if (unlikely(tosd == NULL))
         goto error;
     tosd->tos = (uint8_t)tos;
     tosd->negated = negated;
index a83451bbc71c04b5c358170a0cf38f853aae7a47..e2534e52c4557927eecd429a472aaad60f6c3aca 100644 (file)
@@ -177,8 +177,8 @@ DetectTtlData *DetectTtlParse (char *ttlstr) {
     }
 
     ttld = SCMalloc(sizeof (DetectTtlData));
-    if (ttld == NULL)
-        goto error;
+    if (unlikely(ttld == NULL))
+    goto error;
     ttld->ttl1 = 0;
     ttld->ttl2 = 0;
 
@@ -524,7 +524,7 @@ end:
 static int DetectTtlTestSig1(void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Signature *s = NULL;
     ThreadVars th_v;
index 5fa4040faf39300547910c16719d1ba36e400191..e1d258b1b09406435649d258a16ca66d25a4c888 100644 (file)
@@ -118,7 +118,7 @@ void DetectUricontentPrint(DetectContentData *cd)
         return;
     }
     char *tmpstr = SCMalloc(sizeof(char) * cd->content_len + 1);
-    if (tmpstr == NULL)
+    if (unlikely(tmpstr == NULL))
         return;
 
     if (tmpstr != NULL) {
@@ -170,7 +170,7 @@ DetectContentData *DoDetectUricontentSetup (char *contentstr)
     }
 
     cd = SCMalloc(sizeof(DetectContentData) + len);
-    if (cd == NULL) {
+    if (unlikely(cd == NULL)) {
         SCFree(str);
         exit(EXIT_FAILURE);
     }
index 937eefb3da1a0492ca57212edb3a44bcb656015f..e8da8e25ee3558386f0cf8d707023aeedc1a9b3c 100644 (file)
@@ -237,8 +237,8 @@ DetectUrilenData *DetectUrilenParse (char *urilenstr)
     }
 
     urilend = SCMalloc(sizeof (DetectUrilenData));
-    if (urilend == NULL)
-        goto error;
+    if (unlikely(urilend == NULL))
+    goto error;
     memset(urilend, 0, sizeof(DetectUrilenData));
 
     if (arg1[0] == '<')
index d9ce412d1236d54591470bfe9ae49387c86e844e..4d7c7c8988f26a70a90b41cbbc8459240b2c9ce4 100644 (file)
@@ -140,7 +140,7 @@ DetectWindowData *DetectWindowParse(char *windowstr) {
     }
 
     wd = SCMalloc(sizeof(DetectWindowData));
-    if (wd == NULL)
+    if (unlikely(wd == NULL))
         goto error;
 
     if (ret > 1) {
index 94a391f087e321aea5ac690d165c7069edbb0618..a267c3c85a19fa8dd60e85830992c4be096358c6 100644 (file)
@@ -72,7 +72,7 @@ static int DetectWithinSetup (DetectEngineCtx *de_ctx, Signature *s, char *withi
     /* strip "'s */
     if (withinstr[0] == '\"' && withinstr[strlen(withinstr)-1] == '\"') {
         str = SCStrdup(withinstr+1);
-        if (str == NULL)
+        if (unlikely(str == NULL))
             goto error;
         str[strlen(withinstr)-2] = '\0';
         dubbed = 1;
index 0f64639731882f3126bc2a46686a4623d1575a93..20e8bbda52e3d8875b00fe7dec0e076ba3f4c38c 100644 (file)
@@ -244,7 +244,7 @@ char *DetectLoadCompleteSigPath(char *sig_file)
             size_t path_len = sizeof(char) * (strlen(defaultpath) +
                           strlen(sig_file) + 2);
             path = SCMalloc(path_len);
-            if (path == NULL)
+            if (unlikely(path == NULL))
                 return NULL;
             strlcpy(path, defaultpath, path_len);
 #if defined OS_WIN32 || defined __CYGWIN__
@@ -257,12 +257,12 @@ char *DetectLoadCompleteSigPath(char *sig_file)
             strlcat(path, sig_file, path_len);
        } else {
             path = SCStrdup(sig_file);
-            if (path == NULL)
+            if (unlikely(path == NULL))
                 return NULL;
         }
     } else {
         path = SCStrdup(sig_file);
-        if (path == NULL)
+        if (unlikely(path == NULL))
             return NULL;
     }
     return path;
@@ -333,7 +333,7 @@ static inline void EngineAnalysisWriteFastPattern(Signature *s, SigMatch *mpm_sm
 
     uint16_t patlen = fp_cd->content_len;
     uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
-    if (pat == NULL) {
+    if (unlikely(pat == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -347,7 +347,7 @@ static inline void EngineAnalysisWriteFastPattern(Signature *s, SigMatch *mpm_sm
         SCFree(pat);
         patlen = fp_cd->fp_chop_len;
         pat = SCMalloc(fp_cd->fp_chop_len + 1);
-        if (pat == NULL) {
+        if (unlikely(pat == NULL)) {
             exit(EXIT_FAILURE);
         }
         memcpy(pat, fp_cd->content + fp_cd->fp_chop_offset, fp_cd->fp_chop_len);
@@ -5894,7 +5894,7 @@ static int SigTest15Real (int mpm_type) {
                     "CONNECT 213.92.8.7:31204 HTTP/1.1";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -6102,7 +6102,7 @@ static int SigTest18Real (int mpm_type) {
                     "220 (vsFTPd 2.0.5)\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -6166,7 +6166,7 @@ int SigTest19Real (int mpm_type) {
                     "220 (vsFTPd 2.0.5)\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -6237,7 +6237,7 @@ static int SigTest20Real (int mpm_type) {
                     "220 (vsFTPd 2.0.5)\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -6579,10 +6579,10 @@ int SigTest24IPV4Keyword(void)
         0xc0, 0xa8, 0x01, 0x06};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -6685,10 +6685,10 @@ int SigTest25NegativeIPV4Keyword(void)
         0xc0, 0xa8, 0x01, 0x06};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -6797,11 +6797,11 @@ int SigTest26TCPV4Keyword(void)
         0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
 
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -6913,10 +6913,10 @@ static int SigTest27NegativeTCPV4Keyword(void)
 
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7041,10 +7041,10 @@ int SigTest28TCPV6Keyword(void)
         0x00, 0x01, 0x69, 0x28};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7171,10 +7171,10 @@ int SigTest29NegativeTCPV6Keyword(void)
         0x00, 0x01, 0x69, 0x28};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7296,10 +7296,10 @@ int SigTest30UDPV4Keyword(void)
         0x67, 0x6c, 0x65, 0xc0, 0x27};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7421,10 +7421,10 @@ int SigTest31NegativeUDPV4Keyword(void)
         0x67, 0x6c, 0x65, 0xc0, 0x27};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7540,10 +7540,10 @@ int SigTest32UDPV6Keyword(void)
         0x09, 0x01};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7657,10 +7657,10 @@ int SigTest33NegativeUDPV6Keyword(void)
         0x09, 0x01};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7776,10 +7776,10 @@ int SigTest34ICMPV4Keyword(void)
         0x34, 0x35, 0x36, 0x38};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -7898,10 +7898,10 @@ int SigTest35NegativeICMPV4Keyword(void)
         0x34, 0x35, 0x36, 0x38};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -8031,10 +8031,10 @@ int SigTest36ICMPV6Keyword(void)
         0x08, 0x01};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -8161,10 +8161,10 @@ int SigTest37NegativeICMPV6Keyword(void)
         0x08, 0x01};
 
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL) {
+    if (unlikely(p2 == NULL)) {
         SCFree(p1);
         return 0;
     }
@@ -8255,7 +8255,7 @@ end:
 int SigTest38Real(int mpm_type)
 {
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
@@ -8398,7 +8398,7 @@ static int SigTest38Wm (void) {
 int SigTest39Real(int mpm_type)
 {
     Packet *p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
@@ -8587,7 +8587,7 @@ int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) {
        ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
 
@@ -8705,7 +8705,7 @@ int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) {
        ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DecodeThreadVars dtv;
 
@@ -8826,7 +8826,7 @@ int SigTest40NoPacketInspection01(void) {
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
     TCPHdr tcphdr;
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -8901,7 +8901,7 @@ int SigTest40NoPayloadInspection02(void) {
                     "220 (vsFTPd 2.0.5)\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -8963,7 +8963,7 @@ static int SigTestMemory01 (void) {
                     "\r\n\r\n";
     uint16_t buflen = strlen((char *)buf);
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -9433,7 +9433,7 @@ static int SigTestSgh03 (void) {
     ThreadVars th_v;
     int result = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DetectEngineThreadCtx *det_ctx;
 
@@ -9605,7 +9605,7 @@ static int SigTestSgh04 (void) {
     ThreadVars th_v;
     int result = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DetectEngineThreadCtx *det_ctx;
 
@@ -9798,7 +9798,7 @@ static int SigTestSgh05 (void) {
     ThreadVars th_v;
     int result = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     DetectEngineThreadCtx *det_ctx;
 
@@ -10348,7 +10348,7 @@ static int SigTestWithinReal01 (int mpm_type) {
 
     /* packet 1 */
     p1 = SCMalloc(SIZE_OF_PACKET);
-    if (p1 == NULL)
+    if (unlikely(p1 == NULL))
         return 0;
     memset(p1, 0, SIZE_OF_PACKET);
     p1->pkt = (uint8_t *)(p1 + 1);
@@ -10361,7 +10361,7 @@ static int SigTestWithinReal01 (int mpm_type) {
 
     /* packet 2 */
     p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (unlikely(p2 == NULL))
         return 0;
     memset(p2, 0, SIZE_OF_PACKET);
     p2->pkt = (uint8_t *)(p2 + 1);
@@ -10374,7 +10374,7 @@ static int SigTestWithinReal01 (int mpm_type) {
 
     /* packet 3 */
     p3 = SCMalloc(SIZE_OF_PACKET);
-    if (p3 == NULL)
+    if (unlikely(p3 == NULL))
         return 0;
     memset(p3, 0, SIZE_OF_PACKET);
     p3->pkt = (uint8_t *)(p3 + 1);
@@ -10387,7 +10387,7 @@ static int SigTestWithinReal01 (int mpm_type) {
 
     /* packet 4 */
     p4 = SCMalloc(SIZE_OF_PACKET);
-    if (p4 == NULL)
+    if (unlikely(p4 == NULL))
         return 0;
     memset(p4, 0, SIZE_OF_PACKET);
     p4->pkt = (uint8_t *)(p4 + 1);
index 7ca2b42d8d7fb9f2393a9d813d8cf96b40734337..4dfc0a0c01a63b65e3f2bfa6b090fdd97da87376 100644 (file)
@@ -64,7 +64,7 @@ static void FlowAlertSidAdd(Flow *f, uint32_t sid) {
     FlowAlertSid *fb = FlowAlertSidGet(f, sid);
     if (fb == NULL) {
         fb = SCMalloc(sizeof(FlowAlertSid));
-        if (fb == NULL)
+        if (unlikely(fb == NULL))
             return;
 
         fb->type = DETECT_FLOWALERTSID;
index 6bd62d7e874290cafc8e58e77a9f5a3e8a1def42..be08c2bf79864c8100ae8c6f86b5d849b79c6b83 100644 (file)
@@ -59,7 +59,7 @@ static void FlowBitAdd(Flow *f, uint16_t idx) {
     FlowBit *fb = FlowBitGet(f, idx);
     if (fb == NULL) {
         fb = SCMalloc(sizeof(FlowBit));
-        if (fb == NULL)
+        if (unlikely(fb == NULL))
             return;
 
         fb->type = DETECT_FLOWBITS;
index 44f3fa1a17fc81e99720e6514d3c5667609a5767..5b4b3a715dcde3815d5f93669b469371ecfa97f1 100644 (file)
@@ -56,8 +56,8 @@ Flow *FlowAlloc(void)
     (void) SC_ATOMIC_ADD(flow_memuse, sizeof(Flow));
 
     f = SCMalloc(sizeof(Flow));
-    if (f == NULL) {
-        (void) SC_ATOMIC_SUB(flow_memuse, sizeof(Flow));
+    if (unlikely(f == NULL)) {
+        (void)SC_ATOMIC_SUB(flow_memuse, sizeof(Flow));
         return NULL;
     }
 
index 713d5022482f1b1680549e480a915188c76cd572..26db5eb17de35ca0b9b4723256f4be807e9401c3 100644 (file)
@@ -67,7 +67,7 @@ void FlowVarAddStr(Flow *f, uint8_t idx, uint8_t *value, uint16_t size) {
     FlowVar *fv = FlowVarGet(f, idx);
     if (fv == NULL) {
         fv = SCMalloc(sizeof(FlowVar));
-        if (fv == NULL)
+        if (unlikely(fv == NULL))
             goto out;
 
         fv->type = DETECT_FLOWVAR;
@@ -95,7 +95,7 @@ void FlowVarAddInt(Flow *f, uint8_t idx, uint32_t value) {
     FlowVar *fv = FlowVarGet(f, idx);
     if (fv == NULL) {
         fv = SCMalloc(sizeof(FlowVar));
-        if (fv == NULL)
+        if (unlikely(fv == NULL))
             goto out;
 
         fv->type = DETECT_FLOWVAR;
index 5242d2f2d76f2af424f588da6bda02b36f5db4ac..0a8462ce572029c8fb6fa6b44799a0f935e8bdfa 100644 (file)
@@ -394,7 +394,7 @@ void FlowInitConfig(char quiet)
         exit(EXIT_FAILURE);
     }
     flow_hash = SCCalloc(flow_config.hash_size, sizeof(FlowBucket));
-    if (flow_hash == NULL) {
+    if (unlikely(flow_hash == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowInitConfig. Exiting...");
         exit(EXIT_FAILURE);
     }
index 59cc09464b106fd92ad313b37dff7eea85e83b37..f62d7dfb649b9e3f233c94284410915aaedc2dae 100644 (file)
@@ -62,7 +62,7 @@ Host *HostAlloc(void) {
     (void) SC_ATOMIC_ADD(host_memuse, sizeof(Host));
 
     Host *h = SCMalloc(sizeof(Host));
-    if (h == NULL)
+    if (unlikely(h == NULL))
         goto error;
 
     memset(h, 0x00, sizeof(Host));
@@ -181,7 +181,7 @@ void HostInitConfig(char quiet)
         exit(EXIT_FAILURE);
     }
     host_hash = SCCalloc(host_config.hash_size, sizeof(HostHashRow));
-    if (host_hash == NULL) {
+    if (unlikely(host_hash == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostInitConfig. Exiting...");
         exit(EXIT_FAILURE);
     }
index caac9640de06a8cb4d77f95998c0bc3479499108..6f3edbaca117931c24cee9d756314ef5c7f28c65 100644 (file)
@@ -106,7 +106,7 @@ TmEcode LogDropLogThreadInit(ThreadVars *t, void *initdata, void **data)
     }
 
     LogDropLogThread *dlt = SCMalloc(sizeof(LogDropLogThread));
-    if (dlt == NULL)
+    if (unlikely(dlt == NULL))
         return TM_ECODE_FAILED;
     memset(dlt, 0, sizeof(LogDropLogThread));
 
@@ -158,7 +158,7 @@ OutputCtx *LogDropLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL) {
+    if (unlikely(output_ctx == NULL)) {
         LogFileFreeCtx(logfile_ctx);
         return NULL;
     }
index 52485fa0ebd81b49350914b192f321f7d430a3fa..5fa0e20c0e47472cdceda540a538571ed965edce 100644 (file)
@@ -363,7 +363,7 @@ TmEcode LogFileLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pack
 TmEcode LogFileLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     LogFileLogThread *aft = SCMalloc(sizeof(LogFileLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(LogFileLogThread));
 
@@ -422,7 +422,7 @@ static OutputCtx *LogFileLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         return NULL;
 
     output_ctx->data = logfile_ctx;
index 15c893ae896f24767985b747380b87ca2acaef91..60e8111c29edd3e3403a776cfd932e89132aa724 100644 (file)
@@ -424,7 +424,7 @@ TmEcode LogFilestoreLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq,
 TmEcode LogFilestoreLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     LogFilestoreLogThread *aft = SCMalloc(sizeof(LogFilestoreLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(LogFilestoreLogThread));
 
@@ -539,7 +539,7 @@ static OutputCtx *LogFilestoreLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         return NULL;
 
     output_ctx->data = NULL;
index 098473fac0367c81ae421130ff5c04649c82c7ca..15ff9e2cafb218d737d43b837d8a006fb6471be2 100644 (file)
@@ -571,7 +571,7 @@ TmEcode LogHttpLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pack
 TmEcode LogHttpLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     LogHttpLogThread *aft = SCMalloc(sizeof(LogHttpLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(LogHttpLogThread));
 
@@ -639,7 +639,7 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf)
     }
 
     LogHttpFileCtx *httplog_ctx = SCMalloc(sizeof(LogHttpFileCtx));
-    if (httplog_ctx == NULL) {
+    if (unlikely(httplog_ctx == NULL)) {
         LogFileFreeCtx(file_ctx);
         return NULL;
     }
@@ -713,8 +713,8 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL) {
-        for (n = 0; n < httplog_ctx->cf_n; n++) {
+    if (unlikely(output_ctx == NULL)) {
+        for (n = 0;n < httplog_ctx->cf_n;n++) {
             SCFree(httplog_ctx->cf_nodes[n]);
         }
         LogFileFreeCtx(file_ctx);
index d1a6cba93517733a0e6c940fecebd36e9bdd623f..f40fe2b0e036c94ade2b442dfc696966198cf4de 100644 (file)
@@ -378,9 +378,8 @@ TmEcode PcapLogDataDeinit(ThreadVars *t, void *data)
 OutputCtx *PcapLogInitCtx(ConfNode *conf)
 {
     PcapLogData *pl = SCMalloc(sizeof(PcapLogData));
-    if (pl == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate Memory for PcapLogData");
+    if (unlikely(pl == NULL)) {
+        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate Memory for PcapLogData");
         exit(EXIT_FAILURE);
     }
     memset(pl, 0, sizeof(PcapLogData));
@@ -561,7 +560,7 @@ OutputCtx *PcapLogInitCtx(ConfNode *conf)
     /* create the output ctx and send it back */
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL) {
+    if (unlikely(output_ctx == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for OutputCtx.");
         exit(EXIT_FAILURE);
     }
@@ -614,7 +613,7 @@ int PcapLogOpenFileCtx(PcapLogData *pl)
 
     /* Place to store the name of our PCAP file */
     PcapFileName *pf = SCMalloc(sizeof(PcapFileName));
-    if (pf == NULL) {
+    if (unlikely(pf == NULL)) {
         return -1;
     }
     memset(pf, 0, sizeof(PcapFileName));
index 365c56a5c509a2fbf867f9f458f00e00e137eb1a..a5c4602a1dacf52e0c52a116386a3155488ac7f1 100644 (file)
@@ -472,7 +472,7 @@ TmEcode LogTlsLog(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Packet
 TmEcode LogTlsLogThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     LogTlsLogThread *aft = SCMalloc(sizeof(LogTlsLogThread));
-    if (aft == NULL)
+    if (unlikely(aft == NULL))
         return TM_ECODE_FAILED;
     memset(aft, 0, sizeof(LogTlsLogThread));
 
@@ -566,7 +566,7 @@ OutputCtx *LogTlsLogInitCtx(ConfNode *conf)
     }
 
     LogTlsFileCtx *tlslog_ctx = SCCalloc(1, sizeof(LogTlsFileCtx));
-    if (tlslog_ctx == NULL)
+    if (unlikely(tlslog_ctx == NULL))
         goto filectx_error;
     tlslog_ctx->file_ctx = file_ctx;
 
@@ -580,7 +580,7 @@ OutputCtx *LogTlsLogInitCtx(ConfNode *conf)
     }
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
-    if (output_ctx == NULL)
+    if (unlikely(output_ctx == NULL))
         goto tlslog_error;
     output_ctx->data = tlslog_ctx;
     output_ctx->DeInit = LogTlsLogDeInitCtx;
index 5400ecbedd82ec3e92fe7896072ad62073ef25fc..33547c30001b6d4711ac6ffd104b753ae2602f0d 100644 (file)
@@ -47,7 +47,7 @@ OutputRegisterModule(char *name, char *conf_name,
     OutputCtx *(*InitFunc)(ConfNode *))
 {
     OutputModule *module = SCCalloc(1, sizeof(*module));
-    if (module == NULL) {
+    if (unlikely(module == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in OutputRegisterModule. Exiting...");
         exit(EXIT_FAILURE);
     }
index b15cb0ad753ec3568499ba7debdf12e4f41048c3..d4e48526c42d75850c14471f67cd2b7dec0b345b 100644 (file)
@@ -62,7 +62,7 @@ void PktVarAdd(Packet *p, char *name, uint8_t *value, uint16_t size) {
     PktVar *pv = PktVarGet(p, name);
     if (pv == NULL) {
         pv = SCMalloc(sizeof(PktVar));
-        if (pv == NULL)
+        if (unlikely(pv == NULL))
             return;
 
         pv->name = name;
index aaceb55ee82f22d64b182776873f7c0ffdb235c8..8d61c01a5cb37dbb52809ed840ac309dd8d23f4a 100644 (file)
@@ -121,7 +121,7 @@ void *ParseAFPConfig(const char *iface)
     char *bpf_filter = NULL;
     char *out_iface = NULL;
 
-    if (aconf == NULL) {
+    if (unlikely(aconf == NULL)) {
         return NULL;
     }
 
index b514944757042aedcd060fe3fbd6e973a85e693a..4e70e0713576e38695909d706efdacb4dcffd02f 100644 (file)
@@ -210,7 +210,7 @@ int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx)
         SCLogDebug("tname %s, qname %s", tname, qname);
 
         char *thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             printf("ERROR: Can't allocate thread name\n");
             exit(EXIT_FAILURE);
         }
@@ -253,7 +253,7 @@ int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx)
         }
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             printf("Error allocating memory\n");
             exit(EXIT_FAILURE);
         }
index cbc11221ad6417f9ee5009e6a301fd0cfcd0b3bd..5bf4451c1346837a28a7841ab32f885750303902 100644 (file)
@@ -95,24 +95,24 @@ int RunModeNapatechAuto(DetectEngineCtx *de_ctx) {
     for (feed=0; feed < feed_count; feed++) {
         snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
         feedName = SCStrdup(tname);
-        if (feedName == NULL) {
-            fprintf(stderr, "ERROR: Alloc feed name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(feedName == NULL)) {
+        fprintf(stderr, "ERROR: Alloc feed name\n");
+        exit(EXIT_FAILURE);
         }
 
         snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
         threadName = SCStrdup(tname);
-        if (threadName == NULL) {
-            fprintf(stderr, "ERROR: Alloc thread name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(threadName == NULL)) {
+        fprintf(stderr, "ERROR: Alloc thread name\n");
+        exit(EXIT_FAILURE);
         }
 
 
         snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
         outQueueName = SCStrdup(tname);
-        if (outQueueName == NULL) {
-            fprintf(stderr, "ERROR: Alloc output queue name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(outQueueName == NULL)) {
+        fprintf(stderr, "ERROR: Alloc output queue name\n");
+        exit(EXIT_FAILURE);
         }
 
         /* create the threads */
@@ -162,15 +162,15 @@ int RunModeNapatechAuto(DetectEngineCtx *de_ctx) {
         {
             snprintf(tname, sizeof(tname),"Detect%"PRIu16"/%"PRIu16,feed,detect++);
             threadName = SCStrdup(tname);
-            if (threadName == NULL) {
-                fprintf(stderr, "ERROR: can not strdup thread name\n");
-                exit(EXIT_FAILURE);
+            if (unlikely(threadName == NULL)) {
+            fprintf(stderr, "ERROR: can not strdup thread name\n");
+            exit(EXIT_FAILURE);
             }
             snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
             inQueueName = SCStrdup(tname);
-            if (inQueueName == NULL) {
-                fprintf(stderr, "ERROR: can not strdup in queue name\n");
-                exit(EXIT_FAILURE);
+            if (unlikely(inQueueName == NULL)) {
+            fprintf(stderr, "ERROR: can not strdup in queue name\n");
+            exit(EXIT_FAILURE);
             }
 
             ThreadVars *tv_detect = TmThreadCreatePacketHandler(threadName,
@@ -196,17 +196,17 @@ int RunModeNapatechAuto(DetectEngineCtx *de_ctx) {
             TmSlotSetFuncAppend(tv_detect,tm_module,(void *)de_ctx);
 
             thread_group_name = SCStrdup("Detect");
-            if (thread_group_name == NULL) {
-                fprintf(stderr, "Error allocating memory\n");
-                exit(EXIT_FAILURE);
+            if (unlikely(thread_group_name == NULL)) {
+            fprintf(stderr, "Error allocating memory\n");
+            exit(EXIT_FAILURE);
             }
             tv_detect->thread_group_name = thread_group_name;
 
             SetupOutputs(tv_detect);
             thread_group_name = SCStrdup("Outputs");
-            if (thread_group_name == NULL) {
-                fprintf(stderr, "Error allocating memory\n");
-                exit(EXIT_FAILURE);
+            if (unlikely(thread_group_name == NULL)) {
+            fprintf(stderr, "Error allocating memory\n");
+            exit(EXIT_FAILURE);
             }
             tv_detect->thread_group_name = thread_group_name;
 
@@ -262,23 +262,23 @@ int RunModeNapatechAuto2(DetectEngineCtx *de_ctx) {
     for (feed=0; feed < feed_count; feed++) {
         snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
         feedName = SCStrdup(tname);
-        if (feedName == NULL) {
-            fprintf(stderr, "ERROR: can not strdup feed name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(feedName == NULL)) {
+        fprintf(stderr, "ERROR: can not strdup feed name\n");
+        exit(EXIT_FAILURE);
         }
 
         snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
         threadName = SCStrdup(tname);
-        if (threadName == NULL) {
-            fprintf(stderr, "ERROR: can not strdup in thread name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(threadName == NULL)) {
+        fprintf(stderr, "ERROR: can not strdup in thread name\n");
+        exit(EXIT_FAILURE);
         }
 
         snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
         outQueueName = SCStrdup(tname);
-        if (outQueueName == NULL) {
-            fprintf(stderr, "ERROR: can not strdup out queue name\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(outQueueName == NULL)) {
+        fprintf(stderr, "ERROR: can not strdup out queue name\n");
+        exit(EXIT_FAILURE);
         }
 
         /* create the threads */
@@ -322,17 +322,17 @@ int RunModeNapatechAuto2(DetectEngineCtx *de_ctx) {
         TmSlotSetFuncAppend(tv_napatechFeed,tm_module,(void *)de_ctx);
 
         thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
-            fprintf(stderr, "Error allocating memory\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(thread_group_name == NULL)) {
+        fprintf(stderr, "Error allocating memory\n");
+        exit(EXIT_FAILURE);
         }
         tv_napatechFeed->thread_group_name = thread_group_name;
 
         SetupOutputs(tv_napatechFeed);
         thread_group_name = SCStrdup("Outputs");
-        if (thread_group_name == NULL) {
-            fprintf(stderr, "Error allocating memory\n");
-            exit(EXIT_FAILURE);
+        if (unlikely(thread_group_name == NULL)) {
+        fprintf(stderr, "Error allocating memory\n");
+        exit(EXIT_FAILURE);
         }
         tv_napatechFeed->thread_group_name = thread_group_name;
 
index 9829b8eee0bba907743299874b8bde0d07a92b04..e1ab4b09cb6e06c67fab711f662ac699aa81c36a 100644 (file)
@@ -293,7 +293,7 @@ int RunModeFilePcapAuto(DetectEngineCtx *de_ctx)
         snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1);
 
         char *thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             printf("ERROR: Can not strdup thread name\n");
             exit(EXIT_FAILURE);
         }
@@ -318,7 +318,7 @@ int RunModeFilePcapAuto(DetectEngineCtx *de_ctx)
         TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             printf("Error allocating memory\n");
             exit(EXIT_FAILURE);
         }
@@ -460,7 +460,7 @@ int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx)
         SCLogDebug("tname %s, qname %s", tname, qname);
 
         char *thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             printf("ERROR: Can not strdup thread name\n");
             exit(EXIT_FAILURE);
         }
@@ -503,7 +503,7 @@ int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx)
         }
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             printf("Error allocating memory\n");
             exit(EXIT_FAILURE);
         }
index 3281fdeee1fa4100d28df2daed37d53bd76b5829..afd20ef4b46bd736ff8d68c8e18e0dc0f1bc817e 100644 (file)
@@ -93,7 +93,7 @@ void *ParsePcapConfig(const char *iface)
     char *tmpctype;
     intmax_t value;
 
-    if (aconf == NULL) {
+    if (unlikely(aconf == NULL)) {
         return NULL;
     }
 
index 2aec1459c7551d08def1379b25de2a88d07ed493..d932864a8c880af763795cf7c31a3550a1d714f9 100644 (file)
@@ -114,7 +114,7 @@ void *OldParsePfringConfig(const char *iface)
     cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
 #endif
 
-    if (pfconf == NULL) {
+    if (unlikely(pfconf == NULL)) {
         return NULL;
     }
 
@@ -206,7 +206,7 @@ void *ParsePfringConfig(const char *iface)
     char *bpf_filter = NULL;
 #endif /* HAVE_PFRING_SET_BPF_FILTER */
 
-    if (pfconf == NULL) {
+    if (unlikely(pfconf == NULL)) {
         return NULL;
     }
 
index 4802eb8eba9b23d51a9353997efd7947bdfc6eb5..f766ccac1c07aead236335ad83d1ea2693a753c5 100644 (file)
@@ -433,7 +433,7 @@ void RunModeInitializeOutputs(void)
             debuglog_enabled = 1;
 
         RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
-        if (runmode_output == NULL)
+        if (unlikely(runmode_output == NULL))
             return;
         runmode_output->tm_module = tm_module;
         runmode_output->output_ctx = output_ctx;
index f91a39ce7f519f6cec1f818e6fc9f5d25c53104b..ccff2cd468e6cde69f4f822f43a450f7dd70369b 100644 (file)
@@ -339,7 +339,7 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
     AFPPeer *pitem;
     int mtu, out_mtu;
 
-    if (peer == NULL) {
+    if (unlikely(peer == NULL)) {
         SCReturnInt(TM_ECODE_FAILED);
     }
     memset(peer, 0, sizeof(AFPPeer));
@@ -1434,7 +1434,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) {
     }
 
     AFPThreadVars *ptv = SCMalloc(sizeof(AFPThreadVars));
-    if (ptv == NULL) {
+    if (unlikely(ptv == NULL)) {
         afpconfig->DerefFunc(afpconfig);
         SCReturnInt(TM_ECODE_FAILED);
     }
index bc9b992e36ef86a65a776d28e4b4b2505bbec123..150d21723bbf675e246630d8faa6251b2ed30010 100644 (file)
@@ -169,9 +169,8 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
-    if (ewtn == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                   "Failed to allocate memory for ERF DAG thread vars.");
+    if (unlikely(ewtn == NULL)) {
+        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF DAG thread vars.");
         exit(EXIT_FAILURE);
     }
 
index 8e8b23aa05f4887d0a6bcd273207d7435cd3a218..44c3642fef5e251262a9ddcea34d0898de86eb48 100644 (file)
@@ -227,9 +227,8 @@ ReceiveErfFileThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     ErfFileThreadVars *etv = SCMalloc(sizeof(ErfFileThreadVars));
-    if (etv == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate memory for ERF file thread vars.");
+    if (unlikely(etv == NULL)) {
+        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF file thread vars.");
         fclose(erf);
         SCReturnInt(TM_ECODE_FAILED);
     }
index f74d4ab16e5003ad3bf8e04bd47ca22fd75964b8..56c37e84b6346c97dff6963a82130450ff678848 100644 (file)
@@ -159,9 +159,8 @@ TmEcode NapatechFeedThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     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 5174ea92919089e84dfb8de89782b801d9f08922..e23e620b028e460b6651993e71afae86cbd1eafb 100644 (file)
@@ -217,7 +217,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) {
     SCLogInfo("reading pcap file %s", (char *)initdata);
 
     PcapFileThreadVars *ptv = SCMalloc(sizeof(PcapFileThreadVars));
-    if (ptv == NULL)
+    if (unlikely(ptv == NULL))
         SCReturnInt(TM_ECODE_FAILED);
     memset(ptv, 0, sizeof(PcapFileThreadVars));
 
index 657e1229db8e97c6030810babd04f32e4be4e28b..bb7cda15935967df59bfb2779bc1fdc1a27a3632 100644 (file)
@@ -340,7 +340,7 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
     }
 
     PcapThreadVars *ptv = SCMalloc(sizeof(PcapThreadVars));
-    if (ptv == NULL) {
+    if (unlikely(ptv == NULL)) {
         pcapconfig->DerefFunc(pcapconfig);
         SCReturnInt(TM_ECODE_FAILED);
     }
@@ -480,8 +480,7 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
     }
 
     PcapThreadVars *ptv = SCMalloc(sizeof(PcapThreadVars));
-    if (ptv == NULL) {
-        /* Dereference config */
+    if (unlikely(ptv == NULL)) {
         pcapconfig->DerefFunc(pcapconfig);
         SCReturnInt(TM_ECODE_FAILED);
     }
index e433fc40d555ed7ff9f21b4e6ed4e2fbce5d9dce..c169b36b6f77798d5014dda55b3aa7a3a8a0fc3b 100644 (file)
@@ -332,7 +332,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) {
         return TM_ECODE_FAILED;
 
     PfringThreadVars *ptv = SCMalloc(sizeof(PfringThreadVars));
-    if (ptv == NULL) {
+    if (unlikely(ptv == NULL)) {
         pfconf->DerefFunc(pfconf);
         return TM_ECODE_FAILED;
     }
index 60f6d38b2d82e28b9256ff65fcee2ff8ffa5ea9d..dbc2685a8d1feeaf28144692d313cdbe22e55212 100644 (file)
@@ -199,7 +199,7 @@ static int StreamTcpInlineTest01(void) {
     p->tcph->th_seq = htonl(10000000UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -259,7 +259,7 @@ static int StreamTcpInlineTest02(void) {
     p->tcph->th_seq = htonl(10000001UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -324,7 +324,7 @@ static int StreamTcpInlineTest03(void) {
     p->tcph->th_seq = htonl(10000000UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -389,7 +389,7 @@ static int StreamTcpInlineTest04(void) {
     p->tcph->th_seq = htonl(10000003UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -453,7 +453,7 @@ static int StreamTcpInlineTest05(void) {
     p->tcph->th_seq = htonl(10000000UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -518,7 +518,7 @@ static int StreamTcpInlineTest06(void) {
     p->tcph->th_seq = htonl(10000020UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
@@ -583,7 +583,7 @@ static int StreamTcpInlineTest07(void) {
     p->tcph->th_seq = htonl(10000000UL);
 
     t = SCMalloc(sizeof(TcpSegment));
-    if (t == NULL) {
+    if (unlikely(t == NULL)) {
         printf("alloc TcpSegment failed: ");
         goto end;
     }
index cc4df3afe805daf56353c9559417247e3ed6a691..9347c14509af50c36ae4945b7ec25f7e431e9b61 100644 (file)
@@ -163,7 +163,7 @@ void *TcpSegmentPoolAlloc()
     TcpSegment *seg = NULL;
 
     seg = SCMalloc(sizeof (TcpSegment));
-    if (seg == NULL)
+    if (unlikely(seg == NULL))
         return NULL;
     return seg;
 }
@@ -357,7 +357,7 @@ TcpReassemblyThreadCtx *StreamTcpReassembleInitThreadCtx(void)
 {
     SCEnter();
     TcpReassemblyThreadCtx *ra_ctx = SCMalloc(sizeof(TcpReassemblyThreadCtx));
-    if (ra_ctx == NULL)
+    if (unlikely(ra_ctx == NULL))
         return NULL;
 
     memset(ra_ctx, 0x00, sizeof(TcpReassemblyThreadCtx));
@@ -3607,7 +3607,7 @@ static int StreamTcpReassembleStreamTest(TcpStream *stream) {
 
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Flow f;
     uint8_t payload[4];
@@ -3967,7 +3967,7 @@ static int StreamTcpCheckQueue (uint8_t *stream_contents, StreamMsgQueue *q, uin
 static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     uint8_t payload[4];
@@ -4084,7 +4084,7 @@ static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
 static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     uint8_t payload[4];
@@ -4200,7 +4200,7 @@ static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
 static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     uint8_t payload[4];
@@ -4919,7 +4919,7 @@ static int StreamTcpTestMissedPacket (TcpReassemblyThreadCtx *ra_ctx,
         uint16_t len, uint8_t th_flags, uint8_t flowflags, uint8_t state)
 {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return -1;
     Flow f;
     TCPHdr tcph;
@@ -5517,7 +5517,7 @@ end:
 static int StreamTcpReassembleTest32(void) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -5607,7 +5607,7 @@ end:
 static int StreamTcpReassembleTest33(void) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -5688,7 +5688,7 @@ static int StreamTcpReassembleTest33(void) {
 static int StreamTcpReassembleTest34(void) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -5770,7 +5770,7 @@ static int StreamTcpReassembleTest34(void) {
 static int StreamTcpReassembleTest35(void) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -5839,7 +5839,7 @@ static int StreamTcpReassembleTest35(void) {
 static int StreamTcpReassembleTest36(void) {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -5915,7 +5915,7 @@ static int StreamTcpReassembleTest37(void) {
     ThreadVars tv;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
 
     StreamTcpInitConfig(TRUE);
@@ -6000,7 +6000,7 @@ static int StreamTcpReassembleTest37(void) {
 static int StreamTcpReassembleTest38 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -6158,7 +6158,7 @@ static int StreamTcpReassembleTest39 (void) {
 
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -6367,7 +6367,7 @@ end:
 static int StreamTcpReassembleTest40 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -6609,7 +6609,7 @@ end:
 static int StreamTcpReassembleTest41 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -6798,7 +6798,7 @@ end:
 static int StreamTcpReassembleTest42 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -6952,7 +6952,7 @@ end:
 static int StreamTcpReassembleTest43 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -7190,7 +7190,7 @@ end:
 static int StreamTcpReassembleTest45 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -7308,7 +7308,7 @@ end:
 static int StreamTcpReassembleTest46 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
@@ -7430,7 +7430,7 @@ end:
 static int StreamTcpReassembleTest47 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow *f = NULL;
     TCPHdr tcph;
index 2ec593af0c1eca112756bb2a81ec8402382de7b5..aae8d381b1620c284441d30976878c7c56d6a517 100644 (file)
@@ -63,7 +63,7 @@ static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re)
                     SCLogDebug("SEQ_LT(re, rec->le)");
                     // entirely before, prepend
                     StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
-                    if (stsr == NULL) {
+                    if (unlikely(stsr == NULL)) {
                         SCReturnInt(-1);
                     }
                     stsr->le = le;
@@ -149,7 +149,7 @@ static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re)
                     if (rec->next == NULL) {
                         SCLogDebug("rec->next == NULL");
                         StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
-                        if (stsr == NULL) {
+                        if (unlikely(stsr == NULL)) {
                             SCReturnInt(-1);
                         }
                         stsr->le = le;
@@ -164,7 +164,7 @@ static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re)
                         if (SEQ_LT(le, rec->next->le) && SEQ_LT(re, rec->next->le)) {
                             SCLogDebug("SEQ_LT(le, rec->next->le) && SEQ_LT(re, rec->next->le)");
                             StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
-                            if (stsr == NULL) {
+                            if (unlikely(stsr == NULL)) {
                                 SCReturnInt(-1);
                             }
                             stsr->le = le;
@@ -175,7 +175,7 @@ static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re)
                         } else if (SEQ_LT(le, rec->next->le) && SEQ_GEQ(re, rec->next->le)) {
                             SCLogDebug("SEQ_LT(le, rec->next->le) && SEQ_GEQ(re, rec->next->le)");
                             StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
-                            if (stsr == NULL) {
+                            if (unlikely(stsr == NULL)) {
                                 SCReturnInt(-1);
                             }
                             stsr->le = le;
@@ -192,7 +192,7 @@ static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re)
     } else {
         SCLogDebug("implied empty list");
         StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
-        if (stsr == NULL) {
+        if (unlikely(stsr == NULL)) {
             SCReturnInt(-1);
         }
         stsr->le = le;
index e1c97498bfc1b7eb5df9611dcb348a9fa22660fa..596928f01387c199af9c268264ad705fa446ffc8 100644 (file)
@@ -254,7 +254,7 @@ void *StreamTcpSessionPoolAlloc()
         return NULL;
 
     ptr = SCMalloc(sizeof(TcpSession));
-    if (ptr == NULL)
+    if (unlikely(ptr == NULL))
         return NULL;
 
     return ptr;
@@ -3767,7 +3767,7 @@ TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data)
 {
     SCEnter();
     StreamTcpThread *stt = SCMalloc(sizeof(StreamTcpThread));
-    if (stt == NULL)
+    if (unlikely(stt == NULL))
         SCReturnInt(TM_ECODE_FAILED);
     memset(stt, 0, sizeof(StreamTcpThread));
 
@@ -4671,7 +4671,7 @@ int StreamTcpSegmentForEach(Packet *p, uint8_t flag, StreamSegmentCallback Callb
 
 static int StreamTcpTest01 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     memset(p, 0, SIZE_OF_PACKET);
@@ -4717,7 +4717,7 @@ end:
 
 static int StreamTcpTest02 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -4816,7 +4816,7 @@ end:
 
 static int StreamTcpTest03 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -4890,7 +4890,7 @@ end:
 
 static int StreamTcpTest04 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -4957,7 +4957,7 @@ end:
 
 static int StreamTcpTest05 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5060,7 +5060,7 @@ end:
 
 static int StreamTcpTest06 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TcpSession ssn;
@@ -5123,7 +5123,7 @@ end:
 
 static int StreamTcpTest07 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5211,7 +5211,7 @@ end:
 static int StreamTcpTest08 (void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Flow f;
     ThreadVars tv;
@@ -5301,7 +5301,7 @@ end:
 static int StreamTcpTest09 (void) {
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     Flow f;
     ThreadVars tv;
@@ -5377,7 +5377,7 @@ end:
 
 static int StreamTcpTest10 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5477,7 +5477,7 @@ end:
 
 static int StreamTcpTest11 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5578,7 +5578,7 @@ end:
 
 static int StreamTcpTest12 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5672,7 +5672,7 @@ end:
 
 static int StreamTcpTest13 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -5870,7 +5870,7 @@ char *StreamTcpParseOSPolicy (char *conf_var_name)
 
 static int StreamTcpTest14 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6041,7 +6041,7 @@ end:
 static int StreamTcp4WHSTest01 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6121,7 +6121,7 @@ end:
 static int StreamTcp4WHSTest02 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6190,7 +6190,7 @@ end:
 static int StreamTcp4WHSTest03 (void) {
     int ret = 0;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6268,7 +6268,7 @@ end:
 
 static int StreamTcpTest15 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6438,7 +6438,7 @@ end:
 
 static int StreamTcpTest16 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6609,7 +6609,7 @@ end:
 
 static int StreamTcpTest17 (void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -6779,7 +6779,7 @@ static int StreamTcpTest18 (void) {
     char *ip_addr;
     TcpStream stream;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     IPV4Hdr ipv4h;
     int ret = 0;
@@ -6828,7 +6828,7 @@ static int StreamTcpTest19 (void) {
     char *ip_addr;
     TcpStream stream;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     IPV4Hdr ipv4h;
     int ret = 0;
@@ -6880,7 +6880,7 @@ static int StreamTcpTest20 (void) {
     char *ip_addr;
     TcpStream stream;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     IPV4Hdr ipv4h;
     int ret = 0;
@@ -6932,7 +6932,7 @@ static int StreamTcpTest21 (void) {
     char *ip_addr;
     TcpStream stream;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     IPV4Hdr ipv4h;
     int ret = 0;
@@ -6984,7 +6984,7 @@ static int StreamTcpTest22 (void) {
     char *ip_addr;
     TcpStream stream;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
     return 0;
     IPV4Hdr ipv4h;
     int ret = 0;
@@ -7041,7 +7041,7 @@ static int StreamTcpTest23(void)
     PacketQueue pq;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
 
     memset(&pq,0,sizeof(PacketQueue));
@@ -7123,7 +7123,7 @@ static int StreamTcpTest24(void)
 {
     TcpSession ssn;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     TCPHdr tcph;
@@ -7213,7 +7213,7 @@ end:
  */
 static int StreamTcpTest25(void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -7311,7 +7311,7 @@ end:
  */
 static int StreamTcpTest26(void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -7405,7 +7405,7 @@ end:
  */
 static int StreamTcpTest27(void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -8393,7 +8393,7 @@ end:
  */
 static int StreamTcpTest37(void) {
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     Flow f;
     ThreadVars tv;
@@ -8534,7 +8534,7 @@ static int StreamTcpTest38 (void) {
     memset(&pq,0,sizeof(PacketQueue));
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
@@ -8650,7 +8650,7 @@ static int StreamTcpTest39 (void) {
     memset(&pq,0,sizeof(PacketQueue));
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
@@ -8753,7 +8753,7 @@ static int StreamTcpTest40(void) {
         0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3
     };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
@@ -8811,7 +8811,7 @@ static int StreamTcpTest41(void) {
         0x04, 0x02, 0x08, 0x0a, 0x00, 0xdd, 0x1a, 0x39,
         0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02 };
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
index 96e896ba03202e1ffac61e1b7e6f44ed77956a55..d6f8a9a79cfa6d073f00fce90209e9dfd02e5345 100644 (file)
@@ -170,7 +170,7 @@ void StreamMsgQueuesDeinit(char quiet) {
  *  \retval smq ptr to the queue or NULL */
 StreamMsgQueue *StreamMsgQueueGetNew(void) {
     StreamMsgQueue *smq = SCMalloc(sizeof(StreamMsgQueue));
-    if (smq == NULL)
+    if (unlikely(smq == NULL))
         return NULL;
 
     memset(smq, 0x00, sizeof(StreamMsgQueue));
index 1a1c6b3eafd04d9020f133759df2a90298d5c0f6..aeb2c2d2e574a2ab7fb95b5ea86d2e9f36006038 100644 (file)
@@ -360,7 +360,7 @@ static void SetBpfString(int optind, char *argv[]) {
         return;
 
     bpf_filter = SCMalloc(bpf_len);
-    if (bpf_filter == NULL)
+    if (unlikely(bpf_filter == NULL))
         return;
     memset(bpf_filter, 0x00, bpf_len);
 
@@ -411,9 +411,8 @@ static void SetBpfStringFromFile(char *filename) {
     }
 
     bpf_filter = SCMalloc(bpf_len * sizeof(char));
-    if (bpf_filter == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                "Failed to allocate buffer for bpf filter in file %s", filename);
+    if (unlikely(bpf_filter == NULL)) {
+        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate buffer for bpf filter in file %s", filename);
         exit(EXIT_FAILURE);
     }
     memset(bpf_filter, 0x00, bpf_len);
index 80c392447c712c1967430f829a273681addfcbe1..e7afcb53c5a751f3e71b40043bd09459e141f5ad 100644 (file)
@@ -35,7 +35,7 @@ static Tmq tmqs[TMQ_MAX_QUEUES];
 
 Tmq* TmqAlloc(void) {
     Tmq *q = SCMalloc(sizeof(Tmq));
-    if (q == NULL)
+    if (unlikely(q == NULL))
         goto error;
 
     memset(q, 0, sizeof(Tmq));
index b14db4d8b57aec64b0ac5eb46084608a8242778b..3286da52d961bd25ebae19a493a99c035051f997 100644 (file)
@@ -907,7 +907,7 @@ ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *tm_slot)
 static inline TmSlot * _TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void *data)
 {
     TmSlot *slot = SCMalloc(sizeof(TmSlot));
-    if (slot == NULL)
+    if (unlikely(slot == NULL))
         return NULL;
     memset(slot, 0, sizeof(TmSlot));
     SC_ATOMIC_INIT(slot->slot_data);
@@ -987,7 +987,7 @@ void TmSlotSetFuncAppendDelayed(ThreadVars *tv, TmModule *tm, void *data,
     }
 
     dslot = SCMalloc(sizeof(TmDummySlot));
-    if (dslot == NULL) {
+    if (unlikely(dslot == NULL)) {
         return;
     }
 
@@ -1309,7 +1309,7 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
 
     /* XXX create separate function for this: allocate a thread container */
     tv = SCMalloc(sizeof(ThreadVars));
-    if (tv == NULL)
+    if (unlikely(tv == NULL))
         goto error;
     memset(tv, 0, sizeof(ThreadVars));
 
index 9ed6b2df0646332df8c86d8ca9481651251bfdfe..6382ac238ea0feaf7790e6d0475e65cb4ef5ab49 100644 (file)
@@ -154,12 +154,12 @@ void *TmqhOutputFlowSetupCtx(char *queue_str)
         return NULL;
 
     TmqhFlowCtx *ctx = SCMalloc(sizeof(TmqhFlowCtx));
-    if (ctx == NULL)
+    if (unlikely(ctx == NULL))
         return NULL;
     memset(ctx,0x00,sizeof(TmqhFlowCtx));
 
     char *str = SCStrdup(queue_str);
-    if (str == NULL) {
+    if (unlikely(str == NULL)) {
         goto error;
     }
     char *tstr = str;
index 1844f7cc12b6f36a93f15eafce3e08b15f135b66..84a7f6a02113347c50ea74331e77da682fd385e5 100644 (file)
@@ -116,7 +116,7 @@ void PacketPoolInit(intmax_t max_pending_packets) {
     for (i = 0; i < max_pending_packets; i++) {
         /* XXX pkt alloc function */
         Packet *p = SCMalloc(SIZE_OF_PACKET);
-        if (p == NULL) {
+        if (unlikely(p == NULL)) {
             SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
             exit(EXIT_FAILURE);
         }
index c6d58e055c9b4f1b342f7d6e02f1e02f8255097e..4e44e68ef20b5e61b4de7659f7beb4d88edd8705 100644 (file)
@@ -49,7 +49,7 @@ BloomFilterCounting *BloomFilterCountingInit(uint32_t size, uint8_t type, uint8_
 
     /* setup the filter */
     bf = SCMalloc(sizeof(BloomFilterCounting));
-    if (bf == NULL)
+    if (unlikely(bf == NULL))
         goto error;
     memset(bf,0,sizeof(BloomFilterCounting));
     bf->type = type; /* size of the type: 1, 2, 4 */
index 0bc17bbc20d7beb9fc942b14bac1ac736397f297..b2c9553dcbd9c36f4f08d7a78cae7165c1403953 100644 (file)
@@ -40,7 +40,7 @@ BloomFilter *BloomFilterInit(uint32_t size, uint8_t iter, uint32_t (*Hash)(void
 
     /* setup the filter */
     bf = SCMalloc(sizeof(BloomFilter));
-    if (bf == NULL)
+    if (unlikely(bf == NULL))
         goto error;
     memset(bf,0,sizeof(BloomFilter));
     bf->bitarray_size = size;
index 675ba066788763da684ab0d34129b38ec2c655fb..8dd108e8ef3779dabdc65fe3b10e638abe5ee9a3 100644 (file)
@@ -40,7 +40,7 @@ MemBuffer *MemBufferCreateNew(uint32_t size)
     uint32_t total_size = size + sizeof(MemBuffer);
 
     MemBuffer *buffer = SCMalloc(total_size);
-    if (buffer == NULL) {
+    if (unlikely(buffer == NULL)) {
         return NULL;
     }
     memset(buffer, 0, total_size);
index e3403573845c66f8c91058f39f9ce19319885ce0..f338426c6d587a7809dfe3e4de0d85b9414280e8 100644 (file)
@@ -118,7 +118,7 @@ void SCCudaHlGetYamlConf(void)
 
     /* "mpm" profile, found under "cuda.mpm" in the conf file */
     profile = SCMalloc(sizeof(SCCudaHlCudaProfile));
-    if (profile == NULL) {
+    if (unlikely(profile == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -309,7 +309,7 @@ int SCCudaHlGetCudaModuleFromFile(CUmodule *p_module, const char *filename, int
 
     /* Register new CUmodule in the module */
     new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule));
-    if (new_module_cumodule == NULL) {
+    if (unlikely(new_module_cumodule == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
@@ -462,7 +462,7 @@ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle)
 
     /* Register new CUmodule in the module */
     new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule));
-    if (new_module_cumodule == NULL) {
+    if (unlikely(new_module_cumodule == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
@@ -470,7 +470,7 @@ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle)
     /* select the ptx image based on the compute capability supported by all
      * devices (i.e. the lowest) */
     char* image = SCMalloc(strlen(ptx_image)+15);
-    if (image == NULL) {
+    if (unlikely(image == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(image, 0x0, sizeof(image));
@@ -623,7 +623,7 @@ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name,
     }
 
     new_module_device_ptr = SCMalloc(sizeof(SCCudaHlModuleDevicePointer));
-    if (new_module_device_ptr == NULL)
+    if (unlikely(new_module_device_ptr == NULL))
         goto error;
     memset(new_module_device_ptr, 0, sizeof(SCCudaHlModuleDevicePointer));
 
@@ -857,7 +857,7 @@ int SCCudaHlRegisterModule(const char *name)
 
     /* the module is not already registered.  Register the module */
     new_data = SCMalloc(sizeof(SCCudaHlModuleData));
-    if (new_data == NULL) {
+    if (unlikely(new_data == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(new_data, 0, sizeof(SCCudaHlModuleData));
index a494e2d64d922fd038abc808397b3fc3e72a8b32..d224f1316f4461151f157cd2ed1575633c2408c2 100644 (file)
@@ -4130,7 +4130,7 @@ static int SCCudaDeviceGetAttribute(int *pi, CUdevice_attribute attrib,
 static SCCudaDevice *SCCudaAllocSCCudaDevice(void)
 {
     SCCudaDevice *device = SCMalloc(sizeof(SCCudaDevice));
-    if (device == NULL)
+    if (unlikely(device == NULL))
         return NULL;
     memset(device, 0 , sizeof(SCCudaDevice));
 
@@ -4159,7 +4159,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 4297bf9d04fc95e6a7aa20916e5c6113ea007c56..a0f6031739f42afb382894477324a24ae45c50d0 100644 (file)
@@ -299,7 +299,7 @@ SCError SCLogMessage(SCLogLevel log_level, char **msg, const char *file,
     }
 
     char *temp_fmt = SCStrdup(sc_log_config->log_format);
-    if (temp_fmt == NULL) {
+    if (unlikely(temp_fmt == NULL)) {
         return SC_ERR_MEM_ALLOC;
     }
     char *temp_fmt_h = temp_fmt;
@@ -1362,7 +1362,7 @@ static char *SCLogGetLogFilename(char *filearg)
         log_dir = DEFAULT_LOG_DIR;
 
     log_filename = SCMalloc(PATH_MAX);
-    if (log_filename == NULL)
+    if (unlikely(log_filename == NULL))
         return NULL;
     snprintf(log_filename, PATH_MAX, "%s/%s", log_dir, filearg);
 
index 793b9aa37af97b06f295df9704289e1d66095ec1..71e974d1d317916429e44b18c8d3609d7a415212 100644 (file)
@@ -338,7 +338,7 @@ uint8_t SCAsn1CheckBounds(Asn1Ctx *ac) {
 Asn1Ctx *SCAsn1CtxNew(void) {
     Asn1Ctx *ac = SCMalloc(sizeof(Asn1Ctx));
 
-    if (ac == NULL) {
+    if (unlikely(ac == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         return NULL;
     }
index 6d880edbfe671e5122aa9d3dc9f7441f7231f8eb..1a4f402ec0091d0cf4556790667467e97da419fe 100644 (file)
@@ -43,7 +43,7 @@ static TAILQ_HEAD(, LiveDevice_) live_devices =
 int LiveRegisterDevice(char *dev)
 {
     LiveDevice *pd = SCMalloc(sizeof(LiveDevice));
-    if (pd == NULL) {
+    if (unlikely(pd == NULL)) {
         return -1;
     }
 
index 5486d8aa159ce0b495e0fb03def3ca7885416c08..690e489be5cd80ec2cd6ab12f3f005997edfce96 100644 (file)
@@ -182,7 +182,7 @@ void FilePrune(FileContainer *ffc) {
  */
 FileContainer *FileContainerAlloc(void) {
     FileContainer *new = SCMalloc(sizeof(FileContainer));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
         return NULL;
     }
@@ -240,7 +240,7 @@ void FileContainerFree(FileContainer *ffc) {
  */
 static FileData *FileDataAlloc(uint8_t *data, uint32_t data_len) {
     FileData *new = SCMalloc(sizeof(FileData));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         return NULL;
     }
     memset(new, 0, sizeof(FileData));
@@ -286,7 +286,7 @@ static void FileDataFree(FileData *ffd) {
  */
 static File *FileAlloc(uint8_t *name, uint16_t name_len) {
     File *new = SCMalloc(sizeof(File));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
         return NULL;
     }
index b74415fa6179af64b59d5ae6b673f6b7e9e7cac5..125165f266440a839b8cc7a3b0eadce16c4967ca 100644 (file)
@@ -46,8 +46,8 @@ HashTable* HashTableInit(uint32_t size, uint32_t (*Hash)(struct HashTable_ *, vo
 
     /* setup the filter */
     ht = SCMalloc(sizeof(HashTable));
-    if (ht == NULL)
-        goto error;
+    if (unlikely(ht == NULL))
+    goto error;
     memset(ht,0,sizeof(HashTable));
     ht->array_size = size;
     ht->Hash = Hash;
@@ -115,7 +115,7 @@ int HashTableAdd(HashTable *ht, void *data, uint16_t datalen) {
     uint32_t hash = ht->Hash(ht, data, datalen);
 
     HashTableBucket *hb = SCMalloc(sizeof(HashTableBucket));
-    if (hb == NULL)
+    if (unlikely(hb == NULL))
         goto error;
     memset(hb, 0, sizeof(HashTableBucket));
     hb->data = data;
index 6da8e8511279c2401842cedd7295d58c68568b2b..19c209ed2d9b182f000bf8b286e6402c7e2c5ade 100644 (file)
@@ -47,8 +47,8 @@ HashListTable* HashListTableInit(uint32_t size, uint32_t (*Hash)(struct HashList
 
     /* setup the filter */
     ht = SCMalloc(sizeof(HashListTable));
-    if (ht == NULL)
-        goto error;
+    if (unlikely(ht == NULL))
+    goto error;
     memset(ht,0,sizeof(HashListTable));
     ht->array_size = size;
     ht->Hash = Hash;
@@ -120,7 +120,7 @@ int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen) {
     SCLogDebug("ht %p hash %"PRIu32"", ht, hash);
 
     HashListTableBucket *hb = SCMalloc(sizeof(HashListTableBucket));
-    if (hb == NULL)
+    if (unlikely(hb == NULL))
         goto error;
     memset(hb, 0, sizeof(HashListTableBucket));
     hb->data = data;
index a9c00d1bc3566f1ef4d3e60d9707e7c35a3e3fc3..44ff034816b8636705b322f41d539e61a8eb38d7 100644 (file)
@@ -217,7 +217,7 @@ static inline SCACBSPattern *SCACBSInitHashLookup(SCACBSCtx *ctx, uint8_t *pat,
 static inline SCACBSPattern *SCACBSAllocPattern(MpmCtx *mpm_ctx)
 {
     SCACBSPattern *p = SCMalloc(sizeof(SCACBSPattern));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(SCACBSPattern));
index abfa86d5c6a19deed930ceeb31c441207ba8262d..0f18c451ea32cfd185a05a8114e4b4cac1e6a3d5 100644 (file)
@@ -211,7 +211,7 @@ static inline SCACGfbsPattern *SCACGfbsInitHashLookup(SCACGfbsCtx *ctx, uint8_t
 static inline SCACGfbsPattern *SCACGfbsAllocPattern(MpmCtx *mpm_ctx)
 {
     SCACGfbsPattern *p = SCMalloc(sizeof(SCACGfbsPattern));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(SCACGfbsPattern));
index e6306e2aa62594bcc76ff07b4eda12a357fe1764..bde8e914b2a23d097248d5ef9e03e27c98428972 100644 (file)
@@ -217,7 +217,7 @@ static inline SCACPattern *SCACInitHashLookup(SCACCtx *ctx, uint8_t *pat,
 static inline SCACPattern *SCACAllocPattern(MpmCtx *mpm_ctx)
 {
     SCACPattern *p = SCMalloc(sizeof(SCACPattern));
-    if (p == NULL) {
+    if (unlikely(p == NULL)) {
         exit(EXIT_FAILURE);
     }
     memset(p, 0, sizeof(SCACPattern));
index 7c11e51d2896a913f6c75f4fa3c4293c9999b097..d9416ca492ab287e00157ea1d383816b5c2b37ae 100644 (file)
@@ -142,7 +142,7 @@ void B2gCudaPrintInfo(MpmCtx *mpm_ctx)
 static inline B2gCudaPattern *B2gCudaAllocPattern(MpmCtx *mpm_ctx)
 {
     B2gCudaPattern *p = SCMalloc(sizeof(B2gCudaPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p, 0, sizeof(B2gCudaPattern));
 
@@ -155,7 +155,7 @@ static inline B2gCudaPattern *B2gCudaAllocPattern(MpmCtx *mpm_ctx)
 static inline B2gCudaHashItem *B2gCudaAllocHashItem(MpmCtx *mpm_ctx)
 {
     B2gCudaHashItem *hi = SCMalloc(sizeof(B2gCudaHashItem));
-    if (hi == NULL)
+    if (unlikely(hi == NULL))
         return NULL;
     memset(hi, 0, sizeof(B2gCudaHashItem));
 
@@ -1700,7 +1700,7 @@ TmEcode B2gCudaMpmDispThreadInit(ThreadVars *tv, void *initdata, void **data)
     }
 
     B2gCudaMpmThreadCtxData *tctx = SCMalloc(sizeof(B2gCudaMpmThreadCtxData));
-    if (tctx == NULL) {
+    if (unlikely(tctx == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -2455,7 +2455,7 @@ static int B2gCudaTest01(void)
     pb->packets_payload_offset_buffer[0] = 0;
 
     p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         goto end;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
index 0d7880baed53a41afc71beee2effba84f4628daa..293f01ee879fd8ca6f8b72a9e46858f160c4dff6 100644 (file)
@@ -133,7 +133,7 @@ void B2gPrintInfo(MpmCtx *mpm_ctx) {
  */
 static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) {
     B2gPattern *p = SCMalloc(sizeof(B2gPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p,0,sizeof(B2gPattern));
 
@@ -145,7 +145,7 @@ static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) {
 static inline B2gPattern *
 B2gAllocHashItem(MpmCtx *mpm_ctx) {
     B2gPattern *hi = SCMalloc(sizeof(B2gPattern));
-    if (hi == NULL)
+    if (unlikely(hi == NULL))
         return NULL;
     memset(hi,0,sizeof(B2gPattern));
 
index f68adb69af1d684ef5ff2199d1b7e92bebdf1668..f7ab47c9796af5abb8f54a7620725b596c708741 100644 (file)
@@ -173,7 +173,7 @@ static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) {
 
 static inline B2gcPattern *B2gcAllocPattern(MpmCtx *mpm_ctx) {
     B2gcPattern *p = SCMalloc(sizeof(B2gcPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p,0,sizeof(B2gcPattern));
 
index 3c4307761f854b49a1089c598ad221ebd5b7c543..9217310178b797186dd8cbe8370e299848513808 100644 (file)
@@ -126,7 +126,7 @@ void B2gmPrintInfo(MpmCtx *mpm_ctx) {
 
 static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) {
     B2gmPattern *p = SCMalloc(sizeof(B2gmPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p,0,sizeof(B2gmPattern));
 
@@ -138,7 +138,7 @@ static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) {
 static inline B2gmPattern *
 B2gmAllocHashItem(MpmCtx *mpm_ctx) {
     B2gmPattern *hi = SCMalloc(sizeof(B2gmPattern));
-    if (hi == NULL)
+    if (unlikely(hi == NULL))
         return NULL;
     memset(hi,0,sizeof(B2gmPattern));
 
index 4a45f5bac3a59aba155aa3224015d9cd1e8588f6..73985e8c1c7b2ef26abea45bd2ddd7ab7a244a86 100644 (file)
@@ -105,7 +105,7 @@ void B3gPrintInfo(MpmCtx *mpm_ctx) {
 
 static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) {
     B3gPattern *p = SCMalloc(sizeof(B3gPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p,0,sizeof(B3gPattern));
 
@@ -117,7 +117,7 @@ static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) {
 static inline B3gHashItem *
 B3gAllocHashItem(MpmCtx *mpm_ctx) {
     B3gHashItem *hi = SCMalloc(sizeof(B3gHashItem));
-    if (hi == NULL)
+    if (unlikely(hi == NULL))
         return NULL;
     memset(hi,0,sizeof(B3gHashItem));
 
index 5b19c82c458d52e3076f881f3a7c33f312921378..9ecf8237ecdba620a9806502abfee001ca97d6f1 100644 (file)
@@ -136,7 +136,7 @@ void WmPrintInfo(MpmCtx *mpm_ctx) {
 
 static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) {
     WmPattern *p = SCMalloc(sizeof(WmPattern));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p,0,sizeof(WmPattern));
 
@@ -148,7 +148,7 @@ static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) {
 static inline WmHashItem *
 WmAllocHashItem(MpmCtx *mpm_ctx) {
     WmHashItem *hi = SCMalloc(sizeof(WmHashItem));
-    if (hi == NULL)
+    if (unlikely(hi == NULL))
         return NULL;
     memset(hi,0,sizeof(WmHashItem));
 
index bca6789f35ba1854bc55551b78b3747b4f227811..64a0c633d2507295b4a37952f33202386aebccb2 100644 (file)
@@ -67,7 +67,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
 
         MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
-        if (item == NULL) {
+        if (unlikely(item == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
@@ -205,7 +205,7 @@ MpmCtx *MpmFactoryGetMpmCtxForProfile(DetectEngineCtx *de_ctx, int32_t id, int d
 {
     if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
         MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
-        if (mpm_ctx == NULL) {
+        if (unlikely(mpm_ctx == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
index 581824f9d223a7bf63200eb4117f51b60c81f086..7a3d775e4c307f4938402a550d81e8a474e65170 100644 (file)
@@ -93,7 +93,7 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *
 
     /* setup the filter */
     p = SCMalloc(sizeof(Pool));
-    if (p == NULL)
+    if (unlikely(p == NULL))
         goto error;
 
     memset(p,0,sizeof(Pool));
@@ -140,7 +140,7 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *
     for (u32 = 0; u32 < prealloc_size; u32++) {
         if (size == 0) { /* unlimited */
             PoolBucket *pb = SCMalloc(sizeof(PoolBucket));
-            if (pb == NULL)
+            if (unlikely(pb == NULL))
                 goto error;
 
             memset(pb, 0, sizeof(PoolBucket));
@@ -350,7 +350,7 @@ void PoolPrintSaturation(Pool *p) {
 
 void *PoolTestAlloc() {
     void *ptr = SCMalloc(10);
-    if (ptr == NULL)
+    if (unlikely(ptr == NULL))
         return NULL;
     return ptr;
 }
index 086db4af8718c65f275643083de865dcd9638905..4b7c3c7615d8ebf6b38be7ae6aeb9eb8d71cfca5 100644 (file)
@@ -168,7 +168,7 @@ void SCProfilingRulesGlobalInit(void) {
                     log_dir = DEFAULT_LOG_DIR;
 
                 profiling_file_name = SCMalloc(PATH_MAX);
-                if (profiling_file_name == NULL) {
+                if (unlikely(profiling_file_name == NULL)) {
                     SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
                     exit(EXIT_FAILURE);
                 }
@@ -289,7 +289,7 @@ SCProfilingRuleDump(SCProfileDetectCtx *rules_ctx)
 
     int summary_size = sizeof(SCProfileSummary) * rules_ctx->size;
     SCProfileSummary *summary = SCMalloc(summary_size);
-    if (summary == NULL) {
+    if (unlikely(summary == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for profiling summary");
         return;
     }
index ee54a5dd2ff2e1b1530d27341fc0825916e60e57..397063a5e9192bad5f23a2eb552f1a8b4fad2100 100644 (file)
@@ -141,7 +141,7 @@ SCProfilingInit(void)
                     log_dir = DEFAULT_LOG_DIR;
 
                 profiling_packets_file_name = SCMalloc(PATH_MAX);
-                if (profiling_packets_file_name == NULL) {
+                if (unlikely(profiling_packets_file_name == NULL)) {
                     SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
                     exit(EXIT_FAILURE);
                 }
@@ -173,7 +173,7 @@ SCProfilingInit(void)
                     log_dir = DEFAULT_LOG_DIR;
 
                 profiling_csv_file_name = SCMalloc(PATH_MAX);
-                if (profiling_csv_file_name == NULL) {
+                if (unlikely(profiling_csv_file_name == NULL)) {
                     SCLogError(SC_ERR_MEM_ALLOC, "out of memory");
                     exit(EXIT_FAILURE);
                 }
@@ -220,7 +220,7 @@ SCProfilingInit(void)
                     log_dir = DEFAULT_LOG_DIR;
 
                 profiling_locks_file_name = SCMalloc(PATH_MAX);
-                if (profiling_locks_file_name == NULL) {
+                if (unlikely(profiling_locks_file_name == NULL)) {
                     SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
                     exit(EXIT_FAILURE);
                 }
index 2d12d1759b11fcc42367a09bf935f32c7fa8d0e5..e57f8aaf1bfabc4e786a35185682dc0d2e83307f 100644 (file)
@@ -128,7 +128,7 @@ void SCRadixChopIPAddressAgainstNetmask(uint8_t *stream, uint8_t netmask,
 static SCRadixUserData *SCRadixAllocSCRadixUserData(uint8_t netmask, void *user)
 {
     SCRadixUserData *user_data = SCMalloc(sizeof(SCRadixUserData));
-    if (user_data == NULL) {
+    if (unlikely(user_data == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         return NULL;
     }
@@ -3183,7 +3183,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch15(void)
 
     for (; i <= 32; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3242,7 +3242,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch16(void)
 
     for (; i <= 32; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3301,7 +3301,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch17(void)
 
     for (; i <= 32; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3360,7 +3360,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch18(void)
 
     for (; i <= 32; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3416,7 +3416,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch19(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -3456,7 +3456,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch19(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -3520,7 +3520,7 @@ int SCRadixTestIPV4NetBlocksAndBestSearch19(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -3656,7 +3656,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch20(void)
 
     for (; i <= 128; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3715,7 +3715,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch21(void)
 
     for (; i <= 128; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3774,7 +3774,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch22(void)
 
     for (; i <= 128; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3833,7 +3833,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch23(void)
 
     for (; i <= 128; i++) {
         user = SCMalloc(sizeof(uint32_t));
-        if (user == NULL) {
+        if (unlikely(user == NULL)) {
             result = 0;
             goto end;
         }
@@ -3889,7 +3889,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch24(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -3929,7 +3929,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch24(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -3995,7 +3995,7 @@ int SCRadixTestIPV6NetBlocksAndBestSearch24(void)
     }
 
     user = SCMalloc(sizeof(uint32_t));
-    if (user == NULL) {
+    if (unlikely(user == NULL)) {
         result = 0;
         goto end;
     }
@@ -4203,7 +4203,7 @@ this_end:
 static int SCRadixTestUserdataMacro01(void) {
     int result = 0;
     SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
-    if (node == NULL) {
+    if (unlikely(node == NULL)) {
         goto end;
     }
     memset(node, 0x00, sizeof(*node));
@@ -4228,7 +4228,7 @@ static int SCRadixTestUserdataMacro02(void) {
     SCRadixPrefix prefix;
     int result = 0;
     SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
-    if (node == NULL) {
+    if (unlikely(node == NULL)) {
         goto end;
     }
     memset(node, 0x00, sizeof(*node));
@@ -4257,7 +4257,7 @@ static int SCRadixTestUserdataMacro03(void) {
     int result = 0;
     void *somep = &result;
     SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
-    if (node == NULL) {
+    if (unlikely(node == NULL)) {
         goto end;
     }
     memset(node, 0x00, sizeof(*node));
index 271493a73c22a060af9c1fcd992acee36bb2c161..82ed32096550e3e5cd145ac4a18858b00c9967cc 100644 (file)
@@ -486,7 +486,7 @@ int RingBufferSrSwPut(RingBuffer16 *rb, void *ptr) {
 
 RingBuffer8 *RingBuffer8Init(void) {
     RingBuffer8 *rb = SCMalloc(sizeof(RingBuffer8));
-    if (rb == NULL) {
+    if (unlikely(rb == NULL)) {
         return NULL;
     }
 
@@ -619,7 +619,7 @@ retry:
 
 RingBuffer16 *RingBufferInit(void) {
     RingBuffer16 *rb = SCMalloc(sizeof(RingBuffer16));
-    if (rb == NULL) {
+    if (unlikely(rb == NULL)) {
         return NULL;
     }
 
index 008b597b4c1840f5135c3d9eb62a877fee81b4c2..ce1e13cb3be3597a4cb4545bac37242955261bc7 100644 (file)
@@ -74,7 +74,7 @@ ROHashTable *ROHashInit(uint8_t hash_bits, uint16_t item_size) {
     uint32_t size = hashsize(hash_bits) * sizeof(ROHashTableOffsets);
 
     ROHashTable *table = SCMalloc(sizeof(ROHashTable) + size);
-    if (table == NULL) {
+    if (unlikely(table == NULL)) {
         SCLogError(SC_ERR_HASH_TABLE_INIT, "failed to alloc memory");
         return NULL;
     }
index 68ff4cb81d2c95dd15137355a748b44f4c2da9e7..1fa9d1df3d38413ba8da71d31985c2a3ff5ce5cb 100644 (file)
@@ -132,7 +132,7 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx,
 
             snprintf(tname, sizeof(tname),"%s-%s", thread_name, live_dev);
             tnamec = SCStrdup(tname);
-            if (tnamec == NULL) {
+            if (unlikely(tnamec == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
                 exit(EXIT_FAILURE);
             }
@@ -311,7 +311,7 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx,
 
         char *thread_name = SCStrdup(tname);
 
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
             exit(EXIT_FAILURE);
         }
@@ -336,7 +336,7 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx,
         TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
@@ -444,7 +444,7 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
         for (thread = 0; thread < threads_count; thread++) {
             snprintf(tname, sizeof(tname), "%s%"PRIu16, thread_name, thread+1);
             char *thread_name = SCStrdup(tname);
-            if (thread_name == NULL) {
+            if (unlikely(thread_name == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
                 exit(EXIT_FAILURE);
             }
@@ -507,7 +507,7 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
                 snprintf(tname, sizeof(tname), "%s%s%"PRIu16, thread_name,
                          live_dev, thread+1);
                 char *thread_name = SCStrdup(tname);
-                if (thread_name == NULL) {
+                if (unlikely(thread_name == NULL)) {
                     SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
                     exit(EXIT_FAILURE);
                 }
@@ -550,7 +550,7 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
         SCLogDebug("tname %s, qname %s", tname, qname);
 
         char *thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
             exit(EXIT_FAILURE);
         }
@@ -581,7 +581,7 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
         TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
@@ -637,7 +637,7 @@ static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx,
                      thread_name, live_dev, thread+1);
         }
         n_thread_name = SCStrdup(tname);
-        if (n_thread_name == NULL) {
+        if (unlikely(n_thread_name == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
             exit(EXIT_FAILURE);
         }
@@ -715,7 +715,7 @@ int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx,
         if (live_dev != NULL) {
             aconf = ConfigParser(live_dev);
             live_dev_c = SCStrdup(live_dev);
-            if (live_dev_c == NULL) {
+            if (unlikely(live_dev_c == NULL)) {
                 SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate interface name");
                 exit(EXIT_FAILURE);
             }
@@ -896,7 +896,7 @@ int RunModeSetIPSAuto(DetectEngineCtx *de_ctx,
         TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             printf("Error allocating memory\n");
             exit(EXIT_FAILURE);
         }
@@ -1058,7 +1058,7 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
         SCLogDebug("tname %s, qname %s", tname, qname);
 
         char *thread_name = SCStrdup(tname);
-        if (thread_name == NULL) {
+        if (unlikely(thread_name == NULL)) {
             SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
             exit(EXIT_FAILURE);
         }
@@ -1091,7 +1091,7 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
         SetupOutputs(tv_detect_ncpu);
 
         char *thread_group_name = SCStrdup("Detect");
-        if (thread_group_name == NULL) {
+        if (unlikely(thread_group_name == NULL)) {
             SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
index b4aa11d2cd16834561ff96f9c3d2648576c1aa04..ca7c82d65a41d03e01fa8fa87ada8d4bb883b604 100644 (file)
@@ -64,7 +64,7 @@ void BoyerMooreCtxToNocase(BmCtx *bm_ctx, uint8_t *needle, uint16_t needle_len)
  */
 BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint16_t needle_len) {
     BmCtx *new = SCMalloc(sizeof(BmCtx));
-    if (new == NULL) {
+    if (unlikely(new == NULL)) {
         SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
         exit(EXIT_FAILURE);
     }
@@ -162,7 +162,7 @@ int PreBmGs(const uint8_t *x, uint16_t m, uint16_t *bmGs) {
     uint16_t *suff;
 
     suff = SCMalloc(sizeof(uint16_t) * (m + 1));
-    if (suff == NULL)
+    if (unlikely(suff == NULL))
         return -1;
 
     BoyerMooreSuffixes(x, m, suff);
@@ -237,7 +237,7 @@ void PreBmGsNocase(const uint8_t *x, uint16_t m, uint16_t *bmGs) {
     uint16_t* suff;
 
     suff = SCMalloc(sizeof(uint16_t) * (m + 1));
-    if (suff == NULL)
+    if (unlikely(suff == NULL))
         return;
 
     BoyerMooreSuffixesNocase(x, m, suff);
index d83fc37780ac80f257285369c23d5de977a176ae..9f115da05af5e07a8fbf6bdabb1e893fe2156a19 100644 (file)
@@ -102,7 +102,7 @@ uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uin
 uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     PreBmGs(needle, needlelen, bmGs);
@@ -126,7 +126,7 @@ uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint
 uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     PreBmGsNocase(needle, needlelen, bmGs);
@@ -234,7 +234,7 @@ uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) {
 
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     uint8_t *ret = NULL;
@@ -259,7 +259,7 @@ uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
 
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     uint8_t *ret = NULL;
@@ -366,7 +366,7 @@ uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
 
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     uint8_t *ret = NULL;
@@ -408,7 +408,7 @@ uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
 
     uint16_t bmBc[ALPHABET_SIZE];
     uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
-    if (bmGs == NULL)
+    if (unlikely(bmGs == NULL))
         return NULL;
 
     uint8_t *ret = NULL;
index 3b942fa8d9e6baa96bb643f17517fb8a4188e174..c6fe1ed5e0254ca70320e1640a3e3421df654f64 100644 (file)
@@ -584,7 +584,7 @@ int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx)
             }
 
             de = SCMalloc(sizeof(DetectThresholdData));
-            if (de == NULL)
+            if (unlikely(de == NULL))
                 goto error;
 
             memset(de,0,sizeof(DetectThresholdData));
@@ -665,7 +665,7 @@ int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx)
                 }
 
                 de = SCMalloc(sizeof(DetectThresholdData));
-                if (de == NULL)
+                if (unlikely(de == NULL))
                     goto error;
 
                 memset(de,0,sizeof(DetectThresholdData));
@@ -753,7 +753,7 @@ int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx)
             }
 
             de = SCMalloc(sizeof(DetectThresholdData));
-            if (de == NULL)
+            if (unlikely(de == NULL))
                 goto error;
 
             memset(de,0,sizeof(DetectThresholdData));
index b64f2924a7355ebf3588835c41a6645ba341ac1e..03bd7aad20b73a66faf2a0437f3e8eb075d65a9f 100644 (file)
@@ -79,7 +79,7 @@ Packet *UTHBuildPacketIPV6Real(uint8_t *payload, uint16_t payload_len,
     uint32_t in[4];
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
@@ -166,7 +166,7 @@ Packet *UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len,
     struct in_addr in;
 
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = ((uint8_t *)p) + sizeof(*p);
@@ -282,7 +282,7 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt
     }
     Packet **p = NULL;
     p = SCMalloc(sizeof(Packet *) * numpkts);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
@@ -315,7 +315,7 @@ Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize) {
     DecodeThreadVars dtv;
     ThreadVars th_v;
     Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (p == NULL)
+    if (unlikely(p == NULL))
         return NULL;
     memset(p, 0, SIZE_OF_PACKET);
     p->pkt = (uint8_t *)(p + 1);
@@ -430,8 +430,9 @@ Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp) {
     struct in_addr in;
 
     Flow *f = SCMalloc(sizeof(Flow));
-    if (f == NULL) {
-        printf("FlowAlloc failed\n");;
+    if (unlikely(f == NULL)) {
+        printf("FlowAlloc failed\n");
+        ;
         return NULL;
     }
     memset(f, 0x00, sizeof(Flow));
index d44cff4af7c709ccb5a2f157282712383cb52ea6..4381bcfd53937a87ad304e1b7c0b52787e4e99e0 100644 (file)
@@ -46,7 +46,7 @@ static UtTest *ut_list;
 
 static UtTest *UtAllocTest(void) {
     UtTest *ut = SCMalloc(sizeof(UtTest));
-    if (ut == NULL)
+    if (unlikely(ut == NULL))
         return NULL;
 
     memset(ut, 0, sizeof(UtTest));
index cbad0a1c396f08383abd0772b8d522f6e12491d5..d14938237e42d8fd56d9dd924a09b528939c785d 100644 (file)
@@ -134,7 +134,7 @@ uint16_t VariableNameGetIdx(DetectEngineCtx *de_ctx, char *name, uint8_t type) {
     uint16_t idx = 0;
 
     VariableName *fn = SCMalloc(sizeof(VariableName));
-    if (fn == NULL)
+    if (unlikely(fn == NULL))
         goto error;
 
     memset(fn, 0, sizeof(VariableName));
@@ -171,7 +171,7 @@ error:
 char *VariableIdxGetName(DetectEngineCtx *de_ctx, uint16_t idx, uint8_t type)
 {
     VariableName *fn = SCMalloc(sizeof(VariableName));
-    if (fn == NULL)
+    if (unlikely(fn == NULL))
         goto error;
 
     char *name = NULL;
@@ -183,7 +183,7 @@ char *VariableIdxGetName(DetectEngineCtx *de_ctx, uint16_t idx, uint8_t type)
     VariableName *lookup_fn = (VariableName *)HashListTableLookup(de_ctx->variable_idxs, (void *)fn, 0);
     if (lookup_fn != NULL) {
         name = SCStrdup(lookup_fn->name);
-        if (name == NULL)
+        if (unlikely(name == NULL))
             goto error;
 
         VariableNameFree(fn);
index 83f86aa8b5b48f2b5e5281002d41c40838d5d94f..8014c8fb13e85cc5af38f76b95f4b4d9a13d1801 100644 (file)
@@ -33,7 +33,7 @@ void setenv(const char *name, const char *value, int overwrite)
 {
        if (overwrite || NULL == getenv(name)) {
                char *str = SCMalloc(strlen(name) + strlen(value) + 2);
-               if (str == NULL)
+               if (unlikely(str == NULL))
                        return;
                snprintf(str, strlen(name) + strlen(value) + 1, "%s=%s", name, value);
                putenv(str);
@@ -44,7 +44,7 @@ void setenv(const char *name, const char *value, int overwrite)
 void unsetenv(const char *name)
 {
        char *str = SCMalloc(strlen(name) + 2);
-       if (str == NULL)
+       if (unlikely(str == NULL))
                return;
        snprintf(str, strlen(name) + 1, "%s=", name);
        putenv(str);