From patchwork Fri Dec 18 17:00:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 58728 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp1149255lbb; Fri, 18 Dec 2015 09:01:13 -0800 (PST) X-Received: by 10.140.19.229 with SMTP id 92mr6456580qgh.100.1450458073020; Fri, 18 Dec 2015 09:01:13 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c18si16673416qkb.8.2015.12.18.09.01.11; Fri, 18 Dec 2015 09:01:12 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 604C86169C; Fri, 18 Dec 2015 17:01:11 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=U2cIlLyl; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 87A1961694; Fri, 18 Dec 2015 17:01:07 +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 5003D61688; Fri, 18 Dec 2015 17:01:05 +0000 (UTC) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by lists.linaro.org (Postfix) with ESMTPS id 8142F61688 for ; Fri, 18 Dec 2015 17:01:03 +0000 (UTC) Received: by mail-wm0-f52.google.com with SMTP id l126so73693256wml.1 for ; Fri, 18 Dec 2015 09:01:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=MiklbMmFNw8jleNoCQhTp0yVJZHy34zjP0LdloI6XCg=; b=U2cIlLylh6Y76DMSF55CmJkz/mhSCPApFEHx2Qo9VFdmK3EHUsMkj/paFRDRZ7xYrE AaMrB27m/ZtdQTJ3dgGOuFZWcaWdujy9dS/+O/2Nprt12o3HveHfqdfFeg4scBWRrvt3 nkHrOvfMEZOglmWYDXw9epw9YvkRamWd1W0tw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=MiklbMmFNw8jleNoCQhTp0yVJZHy34zjP0LdloI6XCg=; b=LFatcISEfkWuLTq7bCHOf/cNnF1/0X9ytl1KTxfnYnL49X6eddvWeAdL3dqsZSF3I3 mJy/cEyoP/3glTbWNXYrvx5hFz385iASGQgf8WV62ELZyr4YO4ulBS+v3celbOs/9Qrz EbhdXlZYLbW5VCspCuB3Jo5n5Sm09nwZsAQ1ZT4z2SueNDJNcDbPSh9a0OI5wX1BRqPT ok6zkUd0rrHOLq7s0Y1AV2QK3a7aLMAPnlW/ItQhTphqP2s4AhIrWuNQRbprYvPP3ASl rMKO3CrqvLCIj4kpGqQbOrnkWkclNjJO98M83vdlcfZIYgdlo2DCxlpDWDT44J5QvWea 78jA== X-Gm-Message-State: ALoCoQk/G+3P/QQ0tf6KnkxI8QyAfXB1cX7r28FBM7sydq68Dkh1MNyC2r7VMEpD/n6CvVdilA3FwYj/92n8XJbH6D9eCtOnlQ== X-Received: by 10.28.194.7 with SMTP id s7mr4381099wmf.29.1450458062698; Fri, 18 Dec 2015 09:01:02 -0800 (PST) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id jo6sm15537482wjb.48.2015.12.18.09.01.01 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Dec 2015 09:01:01 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 18 Dec 2015 17:00:40 +0000 Message-Id: <1450458040-16391-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] validation: pktio: refactor error handling during sequence check X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" The callers of this function expect TEST_SEQ_INVALID or the sequence number. Although it is defined as (uint32_t)~0, which normally yields to -1, it's cleaner to use the same macro. Similar to that, it's unlikely that seq reaches UINT32_MAX, the function should check for it. Signed-off-by: Zoltan Kiss Reviewed-by: Stuart Haslam diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 4de3ff8..ff6ece9 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -142,7 +142,7 @@ static uint32_t pktio_pkt_seq(odp_packet_t pkt) pkt_tail_t tail; if (pkt == ODP_PACKET_INVALID) - return -1; + return TEST_SEQ_INVALID; off = odp_packet_l4_offset(pkt); if (off == ODP_PACKET_OFFSET_INVALID) @@ -160,8 +160,10 @@ static uint32_t pktio_pkt_seq(odp_packet_t pkt) if (odp_packet_copydata_out(pkt, off, sizeof(tail), &tail) != 0) return TEST_SEQ_INVALID; - if (tail.magic == TEST_SEQ_MAGIC) + if (tail.magic == TEST_SEQ_MAGIC) { seq = head.seq; + CU_ASSERT(seq != TEST_SEQ_INVALID); + } } return seq;