From patchwork Tue Oct 25 09:00:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leyi Rong X-Patchwork-Id: 119086 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E7686A0543; Tue, 25 Oct 2022 11:00:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BFDF40A89; Tue, 25 Oct 2022 11:00:29 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id BC7ED400D5 for ; Tue, 25 Oct 2022 11:00:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666688427; x=1698224427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T7W/1jZv+kYfkbLa7bhGKYLRrriQmQF3GdY+wPz/QcQ=; b=LkNkcMb8QryuZvFXZgknMrNR6Yppbicwp1VoTAONdrZ/qBJPw4DyUHWt amSStorLNZR43EV35ZiqDCJDyMmYaUAkTskucGqexqua3Fx8dKgUBo8UH 8XL35eh9VzWUfuzuhpFLNnlu7ORh5Mz5oKKtzDmoiUWS+kzCiIcI34U1n 9XF7i9knkoapTMSKh4t/7vHmBgw333dlqOE0lqtGePFZ2WLv1v/2kNMD2 LcnsSeid9YmDH8WD85AzcVMDrscDcvn9Rr9OJ+2cS63ZGz1UFYTfowN28 crPiVhiZbSF2GeLHFVLP34n5i+8elfzbm8tWKOCJeZK/fPU73RtFYi4E3 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="288023571" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="288023571" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2022 02:00:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="876734636" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="876734636" Received: from dpdk-lrong-icx-01.sh.intel.com ([10.67.119.18]) by fmsmga006.fm.intel.com with ESMTP; 25 Oct 2022 02:00:25 -0700 From: Leyi Rong To: yipeng1.wang@intel.com Cc: dev@dpdk.org, Leyi Rong Subject: [PATCH v2] test/member: fix incorrect expression Date: Tue, 25 Oct 2022 17:00:21 +0800 Message-Id: <20221025090021.1549968-1-leyi.rong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221012074850.3579230-1-leyi.rong@intel.com> References: <20221012074850.3579230-1-leyi.rong@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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--;