From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 6563F4C99; Fri, 26 Oct 2018 23:43:23 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6678CA78; Fri, 26 Oct 2018 14:43:22 -0700 (PDT) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.14.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AF363F6A8; Fri, 26 Oct 2018 14:43:22 -0700 (PDT) From: Dharmik Thakkar To: dev@dpdk.org, Bruce Richardson , Pablo de Lara Cc: Dharmik Thakkar , stable@dpdk.org Date: Fri, 26 Oct 2018 16:43:03 -0500 Message-Id: <1540590183-87753-1-git-send-email-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537298539-31403-1-git-send-email-dharmik.thakkar@arm.com> References: <1537298539-31403-1-git-send-email-dharmik.thakkar@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3] test/hash: solve unit test hash compilation error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2018 21:43:23 -0000 Enable print_key_info() function compilation always. Compilation error message: 'test_hash.c: In function ‘print_key_info’: test_hash.c:90:15: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual] uint8_t *p = (uint8_t *)key; ^ cc1: all warnings being treated as errors' Fixes: af75078fece36 ("first public release") Cc: stable@dpdk.org Suggested-by: Honnappa Nagarahalli Signed-off-by: Dharmik Thakkar Reviewed-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu --- v3: * Add compilation error message --- v2: * Fix checkpatch coding style issue * Add "Fixes:" tag --- test/test/test_hash.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/test/test/test_hash.c b/test/test/test_hash.c index b3db9fd10547..db6442a2b101 100644 --- a/test/test/test_hash.c +++ b/test/test/test_hash.c @@ -80,29 +80,23 @@ static uint32_t pseudo_hash(__attribute__((unused)) const void *keys, return 3; } +#define UNIT_TEST_HASH_VERBOSE 0 /* * Print out result of unit test hash operation. */ -#if defined(UNIT_TEST_HASH_VERBOSE) static void print_key_info(const char *msg, const struct flow_key *key, int32_t pos) { - uint8_t *p = (uint8_t *)key; - unsigned i; - - printf("%s key:0x", msg); - for (i = 0; i < sizeof(struct flow_key); i++) { - printf("%02X", p[i]); + if (UNIT_TEST_HASH_VERBOSE) { + const uint8_t *p = (const uint8_t *)key; + unsigned int i; + + printf("%s key:0x", msg); + for (i = 0; i < sizeof(struct flow_key); i++) + printf("%02X", p[i]); + printf(" @ pos %d\n", pos); } - printf(" @ pos %d\n", pos); -} -#else -static void print_key_info(__attribute__((unused)) const char *msg, - __attribute__((unused)) const struct flow_key *key, - __attribute__((unused)) int32_t pos) -{ } -#endif /* Keys used by unit test functions */ static struct flow_key keys[5] = { { -- 2.7.4