Use unlikely for error treatment.

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
pull/91/head
Eric Leblond 14 years ago
parent d292004880
commit e176be6fcc

@ -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));

@ -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;

@ -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;

@ -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");

@ -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));

@ -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));

@ -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));

@ -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));

@ -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);

@ -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));

@ -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));

@ -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));

@ -1292,7 +1292,7 @@ static void *SMBStateAlloc(void) {
SCEnter();
void *s = SCMalloc(sizeof(SMBState));
if (s == NULL) {
if (unlikely(s == NULL)) {
SCReturnPtr(NULL, "void");
}

@ -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));

@ -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));

@ -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));

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;
}

@ -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);
}

@ -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);

@ -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();

@ -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;

@ -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));

@ -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));

@ -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);
}

@ -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);
}

@ -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;

@ -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;
}
}

@ -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;

@ -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));

@ -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;

@ -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;

@ -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));

@ -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;

@ -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,

@ -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);
}

@ -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();

@ -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));

@ -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));

@ -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));

@ -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));

@ -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");
}

@ -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));

@ -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);
}

@ -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));

@ -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));

@ -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));

@ -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));

@ -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] == '<')

@ -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));

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -170,7 +170,7 @@ DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) {
}
iseq = SCMalloc(sizeof(DetectIcmpSeqData));
if (iseq == NULL)
if (unlikely(iseq == NULL))
goto error;
iseq->seq = 0;

@ -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;

@ -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;

@ -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;

@ -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);

@ -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;

@ -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;

@ -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;

@ -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));

@ -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;

@ -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);

@ -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;

@ -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;

@ -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));

@ -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;

@ -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));

@ -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;

@ -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';

@ -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;

@ -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();

@ -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';

@ -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));

@ -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);

@ -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;

@ -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;

@ -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;
}

@ -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));

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save