From patchwork Mon Jun 29 12:48:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 50410 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 104FE218E4 for ; Mon, 29 Jun 2015 12:51:08 +0000 (UTC) Received: by widjy10 with SMTP id jy10sf23071901wid.3 for ; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=VKAHd+EZdubrC41pzT4gaSwQ28vxdAj6ZLVsnSpd1xQ=; b=kDp24dECOAEi9juZ61vFmZ7wONF8u7NZlXaW1+73lxQQpFsDgM2pNPYBq8nDVZQ14B DfZ0xVAql1hcXu9XTZC8DHfPM6i8e7hMml5c3AhXHZxQsOpr+SWwBQnHacVgoFHCQvV9 wpe1loyDf9oUelLoHKpYi7Ct426YIN006xB0+tL6J5PSrkEIkdrA31HACXjgkwxIcSbJ JwMEpqwV6r8AaD4AIvI3V5hf+7Op6yq+CuqhZKOqnNldVN/m8iYinjSR8KcXcwCL/JVU rl411vpmyuiF9Pk1OWwIYtXdc5SljgBbs55Y63mVuYEgM89z+mwvxDIyLGrc/kqgu56R +wzw== X-Gm-Message-State: ALoCoQlOLlJ9s/JwfH+CTxKHHw/xrgokDx/R8R2L0zuHrjpy3HXjgGlycMhVzuhS6ndMtMcqQFY/ X-Received: by 10.152.27.130 with SMTP id t2mr10822596lag.2.1435582267277; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.2 with SMTP id t2ls765251laz.8.gmail; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) X-Received: by 10.112.190.10 with SMTP id gm10mr13622519lbc.2.1435582267128; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id o2si31274917lah.162.2015.06.29.05.51.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 05:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagc2 with SMTP id c2so8469874lag.3 for ; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr13978148laj.88.1435582267012; Mon, 29 Jun 2015 05:51:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1684377lbb; Mon, 29 Jun 2015 05:51:06 -0700 (PDT) X-Received: by 10.140.86.239 with SMTP id p102mr18953530qgd.49.1435582265572; Mon, 29 Jun 2015 05:51:05 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k77si41556643qhc.70.2015.06.29.05.51.04; Mon, 29 Jun 2015 05:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 80D2061DE3; Mon, 29 Jun 2015 12:51:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B762C61DCF; Mon, 29 Jun 2015 12:48:51 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 01FE761DDF; Mon, 29 Jun 2015 12:48:42 +0000 (UTC) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 0C48261C89 for ; Mon, 29 Jun 2015 12:48:38 +0000 (UTC) Received: by lagc2 with SMTP id c2so8386337lag.3 for ; Mon, 29 Jun 2015 05:48:37 -0700 (PDT) X-Received: by 10.152.115.199 with SMTP id jq7mr13842943lab.113.1435582116745; Mon, 29 Jun 2015 05:48:36 -0700 (PDT) Received: from erachmi-VirtualBox.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by mx.google.com with ESMTPSA id w7sm10798397lag.42.2015.06.29.05.48.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jun 2015 05:48:35 -0700 (PDT) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Mon, 29 Jun 2015 14:48:19 +0200 Message-Id: <1435582101-18831-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435582101-18831-1-git-send-email-christophe.milard@linaro.org> References: <1435582101-18831-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCHv2 3/5] validation: cosmetic changes in odp_packet.c X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christophe.milard@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 To please check-patch as much as possible before the file gets moved (and rechecked by check-odp) Note: braces are required in if/then/else with CU_ASSERT macro. Signed-off-by: Christophe Milard --- test/validation/odp_packet.c | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/validation/odp_packet.c b/test/validation/odp_packet.c index e9a022c..eb8e615 100644 --- a/test/validation/odp_packet.c +++ b/test/validation/odp_packet.c @@ -59,7 +59,7 @@ static int packet_suite_init(void) udat = odp_packet_user_area(test_packet); udat_size = odp_packet_user_area_size(test_packet); - if (udat == NULL || udat_size != sizeof(struct udata_struct)) + if (!udat || udat_size != sizeof(struct udata_struct)) return -1; odp_pool_print(packet_pool); memcpy(udat, &test_packet_udata, sizeof(struct udata_struct)); @@ -145,8 +145,9 @@ static void packet_test_event_conversion(void) static void packet_test_basic_metadata(void) { odp_packet_t pkt = test_packet; - CU_ASSERT(odp_packet_head(pkt) != NULL); - CU_ASSERT(odp_packet_data(pkt) != NULL); + + CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt)); + CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt)); CU_ASSERT(odp_packet_pool(pkt) != ODP_POOL_INVALID); /* Packet was allocated by application so shouldn't have valid pktio. */ @@ -191,7 +192,7 @@ static void packet_test_context(void) odp_packet_user_ptr_set(pkt, prev_ptr); udat = odp_packet_user_area(pkt); - CU_ASSERT(udat != NULL); + CU_ASSERT_PTR_NOT_NULL(udat); CU_ASSERT(odp_packet_user_area_size(pkt) == sizeof(struct udata_struct)); CU_ASSERT(memcmp(udat, &test_packet_udata, sizeof(struct udata_struct)) @@ -225,7 +226,7 @@ static void packet_test_layer_offsets(void) CU_ASSERT(seg_len != 0); l4_addr = odp_packet_l4_ptr(pkt, &seg_len); CU_ASSERT(seg_len != 0); - CU_ASSERT(l2_addr != NULL); + CU_ASSERT_PTR_NOT_NULL(l2_addr); CU_ASSERT(l2_addr == l3_addr); CU_ASSERT(l2_addr == l4_addr); @@ -239,11 +240,11 @@ static void packet_test_layer_offsets(void) /* Addresses should not be the same */ l2_addr = odp_packet_l2_ptr(pkt, NULL); - CU_ASSERT(l2_addr != NULL); + CU_ASSERT_PTR_NOT_NULL(l2_addr); l3_addr = odp_packet_l3_ptr(pkt, NULL); - CU_ASSERT(l3_addr != NULL); + CU_ASSERT_PTR_NOT_NULL(l3_addr); l4_addr = odp_packet_l4_ptr(pkt, NULL); - CU_ASSERT(l4_addr != NULL); + CU_ASSERT_PTR_NOT_NULL(l4_addr); CU_ASSERT(l2_addr != l3_addr); CU_ASSERT(l2_addr != l4_addr); @@ -265,7 +266,7 @@ static void _verify_headroom_shift(odp_packet_t packet, else data = odp_packet_pull_head(packet, -shift); - CU_ASSERT(data != NULL); + CU_ASSERT_PTR_NOT_NULL(data); CU_ASSERT(odp_packet_headroom(packet) == room - shift); CU_ASSERT(odp_packet_seg_len(packet) == seg_data_len + shift); CU_ASSERT(odp_packet_len(packet) == pkt_data_len + shift); @@ -317,6 +318,7 @@ static void _verify_tailroom_shift(odp_packet_t pkt, if (shift >= 0) { uint32_t l2_off, l3_off, l4_off; + l2_off = odp_packet_l2_offset(pkt); l3_off = odp_packet_l3_offset(pkt); l4_off = odp_packet_l4_offset(pkt); @@ -330,7 +332,7 @@ static void _verify_tailroom_shift(odp_packet_t pkt, tail = odp_packet_pull_tail(pkt, -shift); } - CU_ASSERT(tail != NULL); + CU_ASSERT_PTR_NOT_NULL(tail); CU_ASSERT(odp_packet_seg_data_len(pkt, seg) == seg_data_len + shift); CU_ASSERT(odp_packet_len(pkt) == pkt_data_len + shift); CU_ASSERT(odp_packet_tailroom(pkt) == room - shift); @@ -390,7 +392,6 @@ static void packet_test_segments(void) CU_ASSERT(num_segs == 1); } - seg = odp_packet_first_seg(pkt); buf_len = 0; data_len = 0; @@ -407,8 +408,8 @@ static void packet_test_segments(void) CU_ASSERT(seg_buf_len > 0); CU_ASSERT(seg_data_len > 0); CU_ASSERT(seg_buf_len >= seg_data_len); - CU_ASSERT(seg_data != NULL); - CU_ASSERT(seg_buf_addr != NULL); + CU_ASSERT_PTR_NOT_NULL(seg_data); + CU_ASSERT_PTR_NOT_NULL(seg_buf_addr); CU_ASSERT(seg_data >= seg_buf_addr); CU_ASSERT(odp_packet_seg_to_u64(seg) != odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID)); @@ -525,7 +526,7 @@ static void packet_test_add_rem_data(void) /* Verify that user metadata has been preserved */ new_udat = odp_packet_user_area(new_pkt); - CU_ASSERT(new_udat != NULL); + CU_ASSERT_PTR_NOT_NULL(new_udat); CU_ASSERT(odp_packet_user_area_size(new_pkt) == sizeof(struct udata_struct)); CU_ASSERT(memcmp(new_udat, &test_packet_udata, @@ -544,7 +545,7 @@ static void packet_test_add_rem_data(void) /* Verify that user metadata has been preserved */ new_udat = odp_packet_user_area(new_pkt); - CU_ASSERT(new_udat != NULL); + CU_ASSERT_PTR_NOT_NULL(new_udat); CU_ASSERT(odp_packet_user_area_size(new_pkt) == sizeof(struct udata_struct)); CU_ASSERT(memcmp(new_udat, &test_packet_udata, @@ -556,7 +557,6 @@ free_packet: odp_packet_free(pkt); } - #define COMPARE_INFLAG(p1, p2, flag) \ CU_ASSERT(odp_packet_has_##flag(p1) == odp_packet_has_##flag(p2)) @@ -594,8 +594,8 @@ static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2) void *pkt1map = odp_packet_offset(pkt1, offset, &seglen1, NULL); void *pkt2map = odp_packet_offset(pkt2, offset, &seglen2, NULL); - CU_ASSERT_FATAL(pkt1map != NULL); - CU_ASSERT_FATAL(pkt2map != NULL); + CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map); + CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map); cmplen = seglen1 < seglen2 ? seglen1 : seglen2; CU_ASSERT(!memcmp(pkt1map, pkt2map, cmplen)); @@ -634,7 +634,7 @@ static void packet_test_copydata(void) CU_ASSERT_FATAL(pkt_len > 0); data_buf = malloc(pkt_len); - CU_ASSERT_FATAL(data_buf != NULL); + CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf); for (i = 0; i < pkt_len; i++) data_buf[i] = (uint8_t)i; @@ -667,7 +667,7 @@ static void packet_test_offset(void) CU_ASSERT(seg_len > 1); CU_ASSERT(seg_len == odp_packet_seg_len(pkt)); CU_ASSERT(seg_len == odp_packet_seg_data_len(pkt, seg)); - CU_ASSERT(ptr != NULL); + CU_ASSERT_PTR_NOT_NULL(ptr); CU_ASSERT(ptr == odp_packet_data(pkt)); CU_ASSERT(ptr == odp_packet_seg_data(pkt, seg)); @@ -677,7 +677,7 @@ static void packet_test_offset(void) offset = 1; ptr = odp_packet_offset(pkt, offset, &seg_len, NULL); - CU_ASSERT(ptr != NULL); + CU_ASSERT_PTR_NOT_NULL(ptr); CU_ASSERT(ptr == start_ptr + offset); CU_ASSERT(seg_len == full_seg_len - offset); @@ -685,19 +685,19 @@ static void packet_test_offset(void) offset = full_seg_len - 1; ptr = odp_packet_offset(pkt, offset, &seg_len, NULL); - CU_ASSERT(ptr != NULL); + CU_ASSERT_PTR_NOT_NULL(ptr); CU_ASSERT(ptr == start_ptr + offset); CU_ASSERT(seg_len == full_seg_len - offset); /* Query the last byte in a packet */ offset = odp_packet_len(pkt) - 1; ptr = odp_packet_offset(pkt, offset, &seg_len, NULL); - CU_ASSERT(ptr != NULL); + CU_ASSERT_PTR_NOT_NULL(ptr); CU_ASSERT(seg_len == 1); /* Pass NULL to [out] arguments */ ptr = odp_packet_offset(pkt, 0, NULL, NULL); - CU_ASSERT(ptr != NULL); + CU_ASSERT_PTR_NOT_NULL(ptr); } static CU_TestInfo packet_suite[] = {