From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 83D76A00E6 for ; Tue, 11 Jun 2019 23:44:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9C7F71D07E; Tue, 11 Jun 2019 23:44:56 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by dpdk.org (Postfix) with ESMTP id 2E8401D07C for ; Tue, 11 Jun 2019 23:44:55 +0200 (CEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5BLgaXL025756 for ; Tue, 11 Jun 2019 17:44:54 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2t2h887rkh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 11 Jun 2019 17:44:53 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Jun 2019 22:44:53 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 11 Jun 2019 22:44:51 +0100 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5BLiohQ23003430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jun 2019 21:44:50 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 579737805C; Tue, 11 Jun 2019 21:44:50 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AA0F7805F; Tue, 11 Jun 2019 21:44:49 +0000 (GMT) Received: from localhost.localdomain (unknown [9.41.99.70]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 11 Jun 2019 21:44:49 +0000 (GMT) From: Thinh Tran To: dev@dpdk.org Cc: Thinh Tran Date: Tue, 11 Jun 2019 16:44:12 -0500 X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19061121-0016-0000-0000-000009C17D02 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011248; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01216607; UDB=6.00639692; IPR=6.00997707; MB=3.00027270; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-11 21:44:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061121-0017-0000-0000-0000439DB7E1 Message-Id: <20190611214412.18388-1-thinhtr@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-11_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=825 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906110140 Subject: [dpdk-dev] [PATCH] raw/skeleton: fix test raw_attr set get failure 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Using memory on the stack instead of on the heap by calling malloc also avoid memory leak in case of test case failures Fixes: 88d0e47880ec ("raw/skeleton: fix memory leak on test failure") Signed-off-by: Thinh Tran --- drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c index 359c9e296..3250c2296 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c @@ -274,17 +274,14 @@ static int test_rawdev_attr_set_get(void) { int ret; - int *dummy_value; + int *dummy_value, set_value; uint64_t ret_value; /* Set an attribute and fetch it */ ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test1", 100); RTE_TEST_ASSERT(!ret, "Unable to set an attribute (Test1)"); - dummy_value = malloc(sizeof(int)); - if (!dummy_value) - RTE_TEST_ASSERT(1, "Unable to allocate memory (dummy_value)"); - + dummy_value = &set_value; *dummy_value = 200; ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test2", (uintptr_t)dummy_value); @@ -294,11 +291,9 @@ test_rawdev_attr_set_get(void) "Attribute (Test1) not set correctly (%" PRIu64 ")", ret_value); - free(dummy_value); - ret_value = 0; ret = rte_rawdev_get_attr(TEST_DEV_ID, "Test2", &ret_value); - RTE_TEST_ASSERT_EQUAL(*((int *)(uintptr_t)ret_value), 200, + RTE_TEST_ASSERT_EQUAL(*((int *)(uintptr_t)ret_value), set_value, "Attribute (Test2) not set correctly (%" PRIu64 ")", ret_value); -- 2.21.0.windows.1