Fix a compiler warning on Ubuntu 9.10 gcc 4.4.1 in the pattern matchers where the size of the thread ctx can be optimized to 0.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 8b8e2fef2d
commit deb511f51a

@ -130,6 +130,9 @@
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME #undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION

@ -1034,14 +1034,16 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) {
void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) {
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = malloc(sizeof(B2gThreadCtx)); if (sizeof(B2gThreadCtx) > 0) { /* size can be null when optimized */
if (mpm_thread_ctx->ctx == NULL) mpm_thread_ctx->ctx = malloc(sizeof(B2gThreadCtx));
return; if (mpm_thread_ctx->ctx == NULL)
return;
memset(mpm_thread_ctx->ctx, 0, sizeof(B2gThreadCtx)); memset(mpm_thread_ctx->ctx, 0, sizeof(B2gThreadCtx));
mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(B2gThreadCtx); mpm_thread_ctx->memory_size += sizeof(B2gThreadCtx);
}
/* alloc an array with the size of _all_ keys in all instances. /* alloc an array with the size of _all_ keys in all instances.
* this is done so the detect engine won't have to care about * this is done so the detect engine won't have to care about
@ -1068,18 +1070,18 @@ void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) {
B2gPrintSearchStats(mpm_thread_ctx); B2gPrintSearchStats(mpm_thread_ctx);
if (ctx) { if (ctx != NULL) { /* can be NULL if B2gThreadCtx is optimized to 0 */
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
mpm_thread_ctx->memory_cnt--; mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(B2gThreadCtx); mpm_thread_ctx->memory_size -= sizeof(B2gThreadCtx);
free(mpm_thread_ctx->ctx); free(mpm_thread_ctx->ctx);
} }
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist);
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist);
} }

@ -1084,14 +1084,16 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) {
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = malloc(sizeof(B3gThreadCtx)); if (sizeof(B3gThreadCtx) > 0) { /* size can be 0 when optimized */
if (mpm_thread_ctx->ctx == NULL) mpm_thread_ctx->ctx = malloc(sizeof(B3gThreadCtx));
return; if (mpm_thread_ctx->ctx == NULL)
return;
memset(mpm_thread_ctx->ctx, 0, sizeof(B3gThreadCtx)); memset(mpm_thread_ctx->ctx, 0, sizeof(B3gThreadCtx));
mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(B3gThreadCtx); mpm_thread_ctx->memory_size += sizeof(B3gThreadCtx);
}
/* alloc an array with the size of _all_ keys in all instances. /* alloc an array with the size of _all_ keys in all instances.
* this is done so the detect engine won't have to care about * this is done so the detect engine won't have to care about
@ -1118,18 +1120,18 @@ void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) {
B3gPrintSearchStats(mpm_thread_ctx); B3gPrintSearchStats(mpm_thread_ctx);
if (ctx) { if (ctx != NULL) { /* can be NULL when optimized */
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
mpm_thread_ctx->memory_cnt--; mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(B3gThreadCtx); mpm_thread_ctx->memory_size -= sizeof(B3gThreadCtx);
free(mpm_thread_ctx->ctx); free(mpm_thread_ctx->ctx);
} }
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist);
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist);
} }

@ -2316,14 +2316,16 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) {
void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) {
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = malloc(sizeof(WmThreadCtx)); if (sizeof(WmThreadCtx) > 0) { /* size can be 0 when optimized */
if (mpm_thread_ctx->ctx == NULL) mpm_thread_ctx->ctx = malloc(sizeof(WmThreadCtx));
return; if (mpm_thread_ctx->ctx == NULL)
return;
memset(mpm_thread_ctx->ctx, 0, sizeof(WmThreadCtx)); memset(mpm_thread_ctx->ctx, 0, sizeof(WmThreadCtx));
mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(WmThreadCtx); mpm_thread_ctx->memory_size += sizeof(WmThreadCtx);
}
/* alloc an array with the size of _all_ keys in all instances. /* alloc an array with the size of _all_ keys in all instances.
* this is done so the detect engine won't have to care about * this is done so the detect engine won't have to care about
@ -2347,18 +2349,18 @@ void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t mat
void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) {
WmThreadCtx *ctx = (WmThreadCtx *)mpm_thread_ctx->ctx; WmThreadCtx *ctx = (WmThreadCtx *)mpm_thread_ctx->ctx;
if (ctx) { if (ctx != NULL) { /* size can be 0 when optimized */
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
mpm_thread_ctx->memory_cnt--; mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(WmThreadCtx); mpm_thread_ctx->memory_size -= sizeof(WmThreadCtx);
free(mpm_thread_ctx->ctx); free(mpm_thread_ctx->ctx);
} }
if (mpm_thread_ctx->match != NULL) {
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
free(mpm_thread_ctx->match);
}
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist);
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist); MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->qlist);
} }
@ -2410,20 +2412,24 @@ int WmTestInitCtx03 (void) {
} }
int WmTestThreadInitCtx01 (void) { int WmTestThreadInitCtx01 (void) {
int result = 0; if (sizeof(WmThreadCtx) > 0) {
MpmCtx mpm_ctx; int result = 0;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmCtx mpm_ctx;
MpmThreadCtx mpm_thread_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER); MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1); WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
if (mpm_thread_ctx.memory_cnt == 2) if (mpm_thread_ctx.memory_cnt == 2)
result = 1; result = 1;
WmThreadDestroyCtx(&mpm_ctx, &mpm_thread_ctx); WmThreadDestroyCtx(&mpm_ctx, &mpm_thread_ctx);
WmDestroyCtx(&mpm_ctx); WmDestroyCtx(&mpm_ctx);
return result; return result;
} else {
return 1;
}
} }
int WmTestThreadInitCtx02 (void) { int WmTestThreadInitCtx02 (void) {

Loading…
Cancel
Save