test/member: fix incorrect expression
PATCH 1/1 test/member: fix incorrect expression
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 <[email protected]>
--- app/test/test_member.c | 16 ++++++++-------- app/test/test_member_perf.c | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-)
app/test/test_member.c +8 -8
@@ -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; }
app/test/test_member_perf.c +2 -1
@@ -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--;
Signature · 1 line
2.25.1
PATCH v2 1/1 test/member: fix incorrect expression
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 <[email protected]>
---
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(-)
app/test/test_member.c +8 -8
@@ -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; }
app/test/test_member_perf.c +2 -1
@@ -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--;
Signature · 1 line
2.25.1
Thomas Monjalon
Applied25/10/2022 11:00, Leyi Rong:
Quoted 7 lines
Fix incorrect expression by cast division operand to type double to match
ceil()andfabs()definitions.Coverity issue: 381398, 381401, 381402
Fixes db354bd2e1f8 ("member: add NitroSketch mode")Signed-off-by Leyi Rong <[email protected]>
Applied, thanks.