From 81b1be51d2e23bd54e6f79b35cb0f1caee6e96e5 Mon Sep 17 00:00:00 2001 From: lecaros Date: Wed, 4 Oct 2023 20:07:23 -0300 Subject: [PATCH 1/3] out_chronicle: remove redundant initializations. These initializations are redundant. The variables are already initialized with these values and there's no code that could change them until this point. Signed-off-by: lecaros --- plugins/out_chronicle/chronicle.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/out_chronicle/chronicle.c b/plugins/out_chronicle/chronicle.c index 479dd803566..db40d151751 100644 --- a/plugins/out_chronicle/chronicle.c +++ b/plugins/out_chronicle/chronicle.c @@ -550,10 +550,6 @@ static flb_sds_t flb_pack_msgpack_extract_log_key(void *out_context, uint64_t by map_size = map.via.map.size; - /* Reset variables for found log_key and correct type */ - found = FLB_FALSE; - check = FLB_FALSE; - /* Extract log_key from record and append to output buffer */ for (i = 0; i < map_size; i++) { key = map.via.map.ptr[i].key; From 131e7aa858ce229f8045e2c547076c6cb3023539 Mon Sep 17 00:00:00 2001 From: lecaros Date: Wed, 4 Oct 2023 20:09:52 -0300 Subject: [PATCH 2/3] out_chronicle: remove unnecessary if. To this point, found will always be FLB_FALSE (hence the expression will always be true). It's only changed in one line, and that block ends with a break, hence never reaching the removed if statement. Signed-off-by: lecaros --- plugins/out_chronicle/chronicle.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/out_chronicle/chronicle.c b/plugins/out_chronicle/chronicle.c index db40d151751..9c5fd870534 100644 --- a/plugins/out_chronicle/chronicle.c +++ b/plugins/out_chronicle/chronicle.c @@ -603,9 +603,7 @@ static flb_sds_t flb_pack_msgpack_extract_log_key(void *out_context, uint64_t by } /* If log_key was not found in the current record, mark log key as missing */ - if (found == FLB_FALSE) { - log_key_missing++; - } + log_key_missing++; } if (log_key_missing > 0) { From 953f14918cc068dbeef34bf4719fde4c730809ea Mon Sep 17 00:00:00 2001 From: lecaros Date: Wed, 4 Oct 2023 20:11:32 -0300 Subject: [PATCH 3/3] out_chronicle: remove unnecessary variable. If the record is found, a break is issued. If it's not, then it must always log_key_missing++. Signed-off-by: lecaros --- plugins/out_chronicle/chronicle.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/out_chronicle/chronicle.c b/plugins/out_chronicle/chronicle.c index 9c5fd870534..b01fef22569 100644 --- a/plugins/out_chronicle/chronicle.c +++ b/plugins/out_chronicle/chronicle.c @@ -518,7 +518,6 @@ static flb_sds_t flb_pack_msgpack_extract_log_key(void *out_context, uint64_t by int i; int map_size; int check = FLB_FALSE; - int found = FLB_FALSE; int log_key_missing = 0; int ret; struct flb_chronicle *ctx = out_context; @@ -568,7 +567,6 @@ static flb_sds_t flb_pack_msgpack_extract_log_key(void *out_context, uint64_t by if (check == FLB_TRUE) { if (strncmp(ctx->log_key, key_str, key_str_size) == 0) { - found = FLB_TRUE; /* * Copy contents of value into buffer. Necessary to copy