Don't print message after SCMalloc failure.

This patch generated via coccinelle is getting rid of logging
message after a SCMalloc failure. They were useless as SCMalloc
already displays a message.
remotes/origin/master-1.1.x
Eric Leblond 15 years ago committed by Victor Julien
parent 67b95c8c4d
commit 49adc264bc

@ -1242,7 +1242,6 @@ void AppLayerParsersInitPostProcess(void)
if (parser_local_id < al_proto_table[u16].map_size) {
al_proto_table[u16].map[parser_local_id] = SCMalloc(sizeof(AppLayerLocalMap));
if (al_proto_table[u16].map[parser_local_id] == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in AppLayerParsersInitPostProcess. Exiting...");
exit(EXIT_FAILURE);
}

@ -157,7 +157,6 @@ static int SSHParseServerVersion(Flow *f, void *ssh_state, AppLayerParserState *
uint64_t proto_ver_len = (uint64_t)(proto_end - line_ptr);
state->server_proto_version = SCMalloc(proto_ver_len + 1);
if (state->server_proto_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
SCReturnInt(-1);
}
memcpy(state->server_proto_version, line_ptr, proto_ver_len);
@ -184,7 +183,6 @@ static int SSHParseServerVersion(Flow *f, void *ssh_state, AppLayerParserState *
uint64_t sw_ver_len = (uint64_t)(sw_end - line_ptr);
state->server_software_version = SCMalloc(sw_ver_len + 1);
if (state->server_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
SCReturnInt(-1);
}
memcpy(state->server_software_version, line_ptr, sw_ver_len);
@ -490,7 +488,6 @@ static int SSHParseClientVersion(Flow *f, void *ssh_state, AppLayerParserState *
uint64_t proto_ver_len = (uint64_t)(proto_end - line_ptr);
state->client_proto_version = SCMalloc(proto_ver_len + 1);
if (state->client_proto_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
SCReturnInt(-1);
}
memcpy(state->client_proto_version, line_ptr, proto_ver_len);
@ -517,7 +514,6 @@ static int SSHParseClientVersion(Flow *f, void *ssh_state, AppLayerParserState *
uint64_t sw_ver_len = (uint64_t)(sw_end - line_ptr);
state->client_software_version = SCMalloc(sw_ver_len + 1);
if (state->client_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
SCReturnInt(-1);
}
memcpy(state->client_software_version, line_ptr, sw_ver_len);

@ -69,7 +69,6 @@ Packet *PacketGetFromQueueOrAlloc(void) {
/* non fatal, we're just not processing a packet then */
p = SCMalloc(SIZE_OF_PACKET);
if (p == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s", strerror(errno));
return NULL;
}
@ -268,7 +267,6 @@ inline int PacketCopyDataOffset(Packet *p, int offset, uint8_t *data, int datale
* reveal the packet size*/
p->ext_pkt = SCMalloc(MAX_PAYLOAD_SIZE);
if (p->ext_pkt == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s", strerror(errno));
SET_PKT_LEN(p, 0);
return -1;
}

@ -260,7 +260,6 @@ DetectAsn1Data *DetectAsn1Parse(char *asn1str) {
fd = SCMalloc(sizeof(DetectAsn1Data));
if (fd == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating DetectAsn1Data");
exit(EXIT_FAILURE);
}
memset(fd, 0x00, sizeof(DetectAsn1Data));

@ -89,7 +89,6 @@ DetectContentData *DetectContentParse (char *contentstr)
cd = SCMalloc(sizeof(DetectContentData));
if (cd == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory. Exiting...");
exit(EXIT_FAILURE);
}
@ -229,7 +228,6 @@ DetectContentData *DetectContentParse (char *contentstr)
cd->content = SCMalloc(len);
if (cd->content == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "error allocating memory. exiting...");
exit(EXIT_FAILURE);
}

@ -261,7 +261,6 @@ SigNumArray *SigNumArrayNew(DetectEngineCtx *de_ctx,
new->array = SCMalloc(io_ctx->max_idx / 8 + 1);
if (new->array == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayNew. Exiting...");
exit(EXIT_FAILURE);
}
@ -294,7 +293,6 @@ SigNumArray *SigNumArrayCopy(SigNumArray *orig) {
new->array = SCMalloc(orig->size);
if (new->array == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayCopy. Exiting...");
exit(EXIT_FAILURE);
}
@ -840,7 +838,6 @@ void DetectEngineIPOnlyThreadInit(DetectEngineCtx *de_ctx,
io_tctx->sig_match_size = de_ctx->io_ctx.max_idx / 8 + 1;
io_tctx->sig_match_array = SCMalloc(io_tctx->sig_match_size);
if (io_tctx->sig_match_array == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in DetectEngineIPOnlyThreadInit. Exiting...");
exit(EXIT_FAILURE);
}

@ -1761,7 +1761,6 @@ uint32_t DetectPatternGetId(MpmPatternIdStore *ht, void *ctx, uint8_t sm_type)
e = SCMalloc(sizeof(MpmPatternIdTableElmt));
if (e == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
@ -1771,7 +1770,6 @@ uint32_t DetectPatternGetId(MpmPatternIdStore *ht, void *ctx, uint8_t sm_type)
DetectContentData *ud = ctx;
e->pattern = SCMalloc(ud->content_len);
if (e->pattern == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memcpy(e->pattern, ud->content, ud->content_len);
@ -1782,7 +1780,6 @@ uint32_t DetectPatternGetId(MpmPatternIdStore *ht, void *ctx, uint8_t sm_type)
DetectContentData *cd = ctx;
e->pattern = SCMalloc(cd->content_len);
if (e->pattern == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memcpy(e->pattern, cd->content, cd->content_len);

@ -105,7 +105,6 @@ uint32_t TagHashFunc(HashListTable *ht, void *data, uint16_t datalen)
void TagInitCtx(void) {
tag_ctx = SCMalloc(sizeof(DetectTagHostCtx));
if (tag_ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for the tagging context");
exit(EXIT_FAILURE);
}
memset(tag_ctx, 0, sizeof(DetectTagHostCtx));

@ -421,16 +421,12 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) {
det_ctx->de_state_sig_array_len = de_ctx->sig_array_len;
det_ctx->de_state_sig_array = SCMalloc(det_ctx->de_state_sig_array_len * sizeof(uint8_t));
if (det_ctx->de_state_sig_array == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "malloc of %"PRIuMAX" failed: %s",
(uintmax_t)(det_ctx->de_state_sig_array_len * sizeof(uint8_t)), strerror(errno));
return TM_ECODE_FAILED;
}
det_ctx->match_array_len = de_ctx->sig_array_len;
det_ctx->match_array = SCMalloc(det_ctx->match_array_len * sizeof(Signature *));
if (det_ctx->match_array == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "malloc of %"PRIuMAX" failed: %s",
(uintmax_t)(det_ctx->match_array_len * sizeof(Signature *)), strerror(errno));
return TM_ECODE_FAILED;
}
}

@ -129,7 +129,6 @@ static DetectReference *DetectReferenceParse(char *rawstr, DetectEngineCtx *de_c
ref = SCMalloc(sizeof(DetectReference));
if (ref == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "malloc failed: %s", strerror(errno));
goto error;
}
memset(ref, 0, sizeof(DetectReference));

@ -177,7 +177,6 @@ int DetectTagMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Si
DetectTagDataEntry *tde = NULL;
tde = SCMalloc(sizeof(DetectTagDataEntry));
if (tde == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Allocation failed for tag entry. The rule will alert, but no session/host will be taged");
return 1;
}
memset(tde, 0, sizeof(DetectTagDataEntry));

@ -286,7 +286,6 @@ static inline void EngineAnalysisWriteFastPattern(Signature *s, SigMatch *mpm_sm
patlen = fp_cd->fp_chop_len;
pat = SCMalloc(fp_cd->fp_chop_len + 1);
if (pat == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memcpy(pat, fp_cd->content + fp_cd->fp_chop_offset, fp_cd->fp_chop_len);

@ -307,7 +307,6 @@ 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) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCCudaHlRegisterModule. Exiting...");
exit(EXIT_FAILURE);
}
memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
@ -461,7 +460,6 @@ 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) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCCudaHlRegisterModule. Exiting...");
exit(EXIT_FAILURE);
}
memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
@ -828,7 +826,6 @@ int SCCudaHlRegisterModule(const char *name)
/* the module is not already registered. Register the module */
new_data = SCMalloc(sizeof(SCCudaHlModuleData));
if (new_data == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCCudaHlRegisterModule. Exiting...");
exit(EXIT_FAILURE);
}
memset(new_data, 0, sizeof(SCCudaHlModuleData));

@ -346,7 +346,6 @@ Asn1Ctx *SCAsn1CtxNew(void) {
ac->asn1_stack = SCMalloc(sizeof(Asn1Node *) * asn1_max_frames_config);
if (ac->asn1_stack == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
return NULL;
}
memset(ac->asn1_stack, 0, sizeof(Asn1Node *) * asn1_max_frames_config);

@ -1013,7 +1013,6 @@ void SCACGfbsInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
mpm_thread_ctx->ctx = SCMalloc(sizeof(SCACGfbsThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACGfbsThreadCtx));
@ -1037,7 +1036,6 @@ void SCACGfbsInitCtx(MpmCtx *mpm_ctx, int module_handle)
mpm_ctx->ctx = SCMalloc(sizeof(SCACGfbsCtx));
if (mpm_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(mpm_ctx->ctx, 0, sizeof(SCACGfbsCtx));
@ -1049,7 +1047,6 @@ void SCACGfbsInitCtx(MpmCtx *mpm_ctx, int module_handle)
SCACGfbsCtx *ctx = (SCACGfbsCtx *)mpm_ctx->ctx;
ctx->init_hash = SCMalloc(sizeof(SCACGfbsPattern *) * INIT_HASH_SIZE);
if (ctx->init_hash == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(ctx->init_hash, 0, sizeof(SCACGfbsPattern *) * INIT_HASH_SIZE);

@ -1051,7 +1051,6 @@ void SCACInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t m
mpm_thread_ctx->ctx = SCMalloc(sizeof(SCACThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACThreadCtx));
@ -1075,7 +1074,6 @@ void SCACInitCtx(MpmCtx *mpm_ctx, int module_handle)
mpm_ctx->ctx = SCMalloc(sizeof(SCACCtx));
if (mpm_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(mpm_ctx->ctx, 0, sizeof(SCACCtx));
@ -1087,7 +1085,6 @@ void SCACInitCtx(MpmCtx *mpm_ctx, int module_handle)
SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx;
ctx->init_hash = SCMalloc(sizeof(SCACPattern *) * INIT_HASH_SIZE);
if (ctx->init_hash == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(ctx->init_hash, 0, sizeof(SCACPattern *) * INIT_HASH_SIZE);

@ -768,8 +768,6 @@ void B2gInitCtx (MpmCtx *mpm_ctx, int module_handle) {
mpm_ctx->ctx = SCMalloc(sizeof(B2gCtx));
if (mpm_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gCtx)));
exit(EXIT_FAILURE);
}
@ -782,8 +780,6 @@ void B2gInitCtx (MpmCtx *mpm_ctx, int module_handle) {
B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx;
ctx->init_hash = SCMalloc(sizeof(B2gPattern *) * INIT_HASH_SIZE);
if (ctx->init_hash == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gPattern *) * INIT_HASH_SIZE));
exit(EXIT_FAILURE);
}
@ -881,8 +877,6 @@ void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t ma
if (sizeof(B2gThreadCtx) > 0) { /* size can be null when optimized */
mpm_thread_ctx->ctx = SCMalloc(sizeof(B2gThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gThreadCtx)));
exit(EXIT_FAILURE);
}

@ -911,8 +911,6 @@ void B2gcInitCtx (MpmCtx *mpm_ctx, int module_handle) {
mpm_ctx->ctx = SCMalloc(sizeof(B2gcCtx));
if (mpm_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gcCtx)));
exit(EXIT_FAILURE);
}
@ -1009,8 +1007,6 @@ void B2gcThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t m
if (sizeof(B2gcThreadCtx) > 0) { /* size can be null when optimized */
mpm_thread_ctx->ctx = SCMalloc(sizeof(B2gcThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gcThreadCtx)));
exit(EXIT_FAILURE);
}

@ -817,8 +817,6 @@ void B2gmInitCtx (MpmCtx *mpm_ctx, int module_handle) {
mpm_ctx->ctx = SCMalloc(sizeof(B2gmCtx));
if (mpm_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gmCtx)));
exit(EXIT_FAILURE);
}
@ -831,8 +829,6 @@ void B2gmInitCtx (MpmCtx *mpm_ctx, int module_handle) {
B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx;
ctx->init_hash = SCMalloc(sizeof(B2gmPattern *) * INIT_HASH_SIZE);
if (ctx->init_hash == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gmPattern *) * INIT_HASH_SIZE));
exit(EXIT_FAILURE);
}
@ -915,8 +911,6 @@ void B2gmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t m
if (sizeof(B2gmThreadCtx) > 0) { /* size can be null when optimized */
mpm_thread_ctx->ctx = SCMalloc(sizeof(B2gmThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
"to allocate %"PRIdMAX" bytes", strerror(errno), (intmax_t)(sizeof(B2gmThreadCtx)));
exit(EXIT_FAILURE);
}

@ -76,7 +76,6 @@ BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint32_t needle_len) {
new->bmGs = SCMalloc(sizeof(int32_t) * (needle_len + 1));
if (new->bmGs == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
exit(EXIT_FAILURE);
}

Loading…
Cancel
Save