From: Leyi Rong <leyi.rong@intel.com>
To: yipeng1.wang@intel.com
Cc: dev@dpdk.org, Leyi Rong <leyi.rong@intel.com>
Subject: [PATCH v2] test/member: fix incorrect expression
Date: Tue, 25 Oct 2022 17:00:21 +0800 [thread overview]
Message-ID: <20221025090021.1549968-1-leyi.rong@intel.com> (raw)
In-Reply-To: <20221012074850.3579230-1-leyi.rong@intel.com>
Fix incorrect expression by cast division operand to type double
to match ceil() and fabs() definitions.
Coverity issue: 381398, 381401, 381402
Fixes: db354bd2e1f8 ("member: add NitroSketch mode")
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
---
v2:
- resubmit as v1 performance CI fail maybe false-positive.
---
app/test/test_member.c | 16 ++++++++--------
app/test/test_member_perf.c | 3 ++-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/app/test/test_member.c b/app/test/test_member.c
index 8266e6437b..c1b6a7d8b9 100644
--- a/app/test/test_member.c
+++ b/app/test/test_member.c
@@ -712,19 +712,19 @@ print_out_sketch_results(uint64_t *count_result, member_set_t *heavy_set,
printf("key %2u, count %8"PRIu64", real count %8u, "
"heavy_set %u, deviation rate [%.04f]\n",
i, count_result[i],
- (unsigned int)ceil(SKETCH_LARGEST_KEY_SIZE / (i + 1)) *
+ (unsigned int)ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1)) *
HH_PKT_SIZE,
heavy_set[i],
- fabs((float)count_result[i] - (float)NUM_OF_KEY(i) * HH_PKT_SIZE) /
- ((float)NUM_OF_KEY(i) * HH_PKT_SIZE));
+ fabs((double)count_result[i] - (double)NUM_OF_KEY(i) * HH_PKT_SIZE) /
+ ((double)NUM_OF_KEY(i) * HH_PKT_SIZE));
else
printf("key %2u, count %8"PRIu64", real count %8u, "
"heavy_set %u, deviation rate [%.04f]\n",
i, count_result[i],
- (unsigned int)ceil(SKETCH_LARGEST_KEY_SIZE / (i + 1)),
+ (unsigned int)ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1)),
heavy_set[i],
- fabs((float)count_result[i] - (float)NUM_OF_KEY(i)) /
- (float)NUM_OF_KEY(i));
+ fabs((double)count_result[i] - (double)NUM_OF_KEY(i)) /
+ (double)NUM_OF_KEY(i));
}
}
@@ -879,7 +879,7 @@ test_member_sketch(void)
int count_byte = 0;
for (i = 0; i < SKETCH_TOTAL_KEY; i++)
- total_pkt += ceil(SKETCH_LARGEST_KEY_SIZE / (i + 1));
+ total_pkt += ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1));
printf("\nTotal key count [%u] in Sketch Autotest\n", total_pkt);
@@ -892,7 +892,7 @@ test_member_sketch(void)
index = 0;
for (i = 0; i < SKETCH_TOTAL_KEY; i++) {
- for (j = 0; j < ceil(SKETCH_LARGEST_KEY_SIZE / (i + 1)); j++)
+ for (j = 0; j < ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1)); j++)
keys[index++] = i;
}
diff --git a/app/test/test_member_perf.c b/app/test/test_member_perf.c
index b7eb3e4c66..7b6adf913e 100644
--- a/app/test/test_member_perf.c
+++ b/app/test/test_member_perf.c
@@ -196,7 +196,8 @@ setup_keys_and_data(struct member_perf_params *params, unsigned int cycle,
for (i = 0; i < KEYS_TO_ADD; i++) {
if (count_down == 0) {
distinct_key++;
- count_down = ceil(SKETCH_LARGEST_KEY_SIZE / (distinct_key + 1));
+ count_down = ceil((double)SKETCH_LARGEST_KEY_SIZE /
+ (distinct_key + 1));
}
memcpy(hh_keys[i], keys[distinct_key], params->key_size);
count_down--;
--
2.25.1
next prev parent reply other threads:[~2022-10-25 9:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 7:48 [PATCH] " Leyi Rong
2022-10-25 9:00 ` Leyi Rong [this message]
2022-10-26 15:14 ` [PATCH v2] " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221025090021.1549968-1-leyi.rong@intel.com \
--to=leyi.rong@intel.com \
--cc=dev@dpdk.org \
--cc=yipeng1.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).