eve: no need to check fields

Cppcheck 2.10:

src/output-json-dns.c:460:23: warning: Identical inner 'if' condition is always true (outer condition is 'field' and inner condition is 'field!=NULL'). [identicalInnerCondition]
            if (field != NULL)
                      ^
src/output-json-dns.c:458:9: note: outer condition: field
        TAILQ_FOREACH(field, &custom->head, next)
        ^
src/output-json-dns.c:460:23: note: identical inner condition: field!=NULL
            if (field != NULL)
                      ^

src/output-json-email-common.c:408:27: warning: Identical inner 'if' condition is always true (outer condition is 'field' and inner condition is 'field!=NULL'). [identicalInnerCondition]
                if (field != NULL) {
                          ^
src/output-json-email-common.c:407:13: note: outer condition: field
            TAILQ_FOREACH(field, &custom->head, next) {
            ^
src/output-json-email-common.c:408:27: note: identical inner condition: field!=NULL
                if (field != NULL) {
                          ^
src/output-json-email-common.c:430:27: warning: Identical inner 'if' condition is always true (outer condition is 'field' and inner condition is 'field!=NULL'). [identicalInnerCondition]
                if (field != NULL) {
                          ^
src/output-json-email-common.c:429:13: note: outer condition: field
            TAILQ_FOREACH(field, &md5_conf->head, next) {
            ^
src/output-json-email-common.c:430:27: note: identical inner condition: field!=NULL
                if (field != NULL) {
                          ^
src/output-json-http.c:574:27: warning: Identical inner 'if' condition is always true (outer condition is 'field' and inner condition is 'field!=NULL'). [identicalInnerCondition]
                if (field != NULL)
                          ^
src/output-json-http.c:572:13: note: outer condition: field
            TAILQ_FOREACH(field, &custom->head, next)
            ^
src/output-json-http.c:574:27: note: identical inner condition: field!=NULL
                if (field != NULL)
                          ^
pull/8753/head
Victor Julien 3 years ago
parent 29ac7b366b
commit b700222240

@ -455,19 +455,12 @@ static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, ConfNode *conf,
if ((custom = ConfNodeLookupChild(conf, answer_types_key)) != NULL) {
dnslog_ctx->flags &= ~LOG_ALL_RRTYPES;
ConfNode *field;
TAILQ_FOREACH(field, &custom->head, next)
{
if (field != NULL)
{
DnsRRTypes f;
for (f = DNS_RRTYPE_A; f < DNS_RRTYPE_MAX; f++)
{
if (strcasecmp(dns_rrtype_fields[f].config_rrtype,
field->val) == 0)
{
dnslog_ctx->flags |= dns_rrtype_fields[f].flags;
break;
}
TAILQ_FOREACH (field, &custom->head, next) {
DnsRRTypes f;
for (f = DNS_RRTYPE_A; f < DNS_RRTYPE_MAX; f++) {
if (strcasecmp(dns_rrtype_fields[f].config_rrtype, field->val) == 0) {
dnslog_ctx->flags |= dns_rrtype_fields[f].flags;
break;
}
}
}

@ -404,20 +404,15 @@ void OutputEmailInitConf(ConfNode *conf, OutputJsonEmailCtx *email_ctx)
ConfNode *custom;
if ((custom = ConfNodeLookupChild(conf, "custom")) != NULL) {
ConfNode *field;
TAILQ_FOREACH(field, &custom->head, next) {
if (field != NULL) {
int f = 0;
while(email_fields[f].config_field) {
if ((strcmp(email_fields[f].config_field,
field->val) == 0) ||
(strcasecmp(email_fields[f].email_field,
field->val) == 0))
{
email_ctx->fields |= (1ULL<<f);
break;
}
f++;
TAILQ_FOREACH (field, &custom->head, next) {
int f = 0;
while (email_fields[f].config_field) {
if ((strcmp(email_fields[f].config_field, field->val) == 0) ||
(strcasecmp(email_fields[f].email_field, field->val) == 0)) {
email_ctx->fields |= (1ULL << f);
break;
}
f++;
}
}
}
@ -426,16 +421,14 @@ void OutputEmailInitConf(ConfNode *conf, OutputJsonEmailCtx *email_ctx)
ConfNode *md5_conf;
if ((md5_conf = ConfNodeLookupChild(conf, "md5")) != NULL) {
ConfNode *field;
TAILQ_FOREACH(field, &md5_conf->head, next) {
if (field != NULL) {
if (strcmp("body", field->val) == 0) {
SCLogInfo("Going to log the md5 sum of email body");
email_ctx->flags |= LOG_EMAIL_BODY_MD5;
}
if (strcmp("subject", field->val) == 0) {
SCLogInfo("Going to log the md5 sum of email subject");
email_ctx->flags |= LOG_EMAIL_SUBJECT_MD5;
}
TAILQ_FOREACH (field, &md5_conf->head, next) {
if (strcmp("body", field->val) == 0) {
SCLogInfo("Going to log the md5 sum of email body");
email_ctx->flags |= LOG_EMAIL_BODY_MD5;
}
if (strcmp("subject", field->val) == 0) {
SCLogInfo("Going to log the md5 sum of email subject");
email_ctx->flags |= LOG_EMAIL_SUBJECT_MD5;
}
}
}

@ -569,21 +569,13 @@ static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_c
ConfNode *custom;
if ((custom = ConfNodeLookupChild(conf, "custom")) != NULL) {
ConfNode *field;
TAILQ_FOREACH(field, &custom->head, next)
{
if (field != NULL)
{
HttpField f;
for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
{
if ((strcmp(http_fields[f].config_field,
field->val) == 0) ||
(strcasecmp(http_fields[f].htp_field,
field->val) == 0))
{
http_ctx->fields |= (1ULL<<f);
break;
}
TAILQ_FOREACH (field, &custom->head, next) {
HttpField f;
for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++) {
if ((strcmp(http_fields[f].config_field, field->val) == 0) ||
(strcasecmp(http_fields[f].htp_field, field->val) == 0)) {
http_ctx->fields |= (1ULL << f);
break;
}
}
}

Loading…
Cancel
Save