From patchwork Mon Jul 6 11:57:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 50734 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C734218EA for ; Mon, 6 Jul 2015 11:57:27 +0000 (UTC) Received: by wgfk9 with SMTP id k9sf49329792wgf.1 for ; Mon, 06 Jul 2015 04:57:26 -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: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=sGeiZQ5ig6rBhE0Vvz6qigsihsWGQQBd4vXwjbsWBd0=; b=L48Wa1niO5mRvRBvxOTG4RQL9Zih4/5NDadaW9Ra2AdEOUsZCEhOWil32Y3CCMd7Hk gPPLno1RgdE38Br3BDqr6EjikS7Ozs+WgDhnAj/ZcJYGcOEHHbJRB5itV4v6Mp42c5Ix Ty6WEmZKVcQpUD0ePbbwmG+NHDAMRSFonTqEKHiCe6Y0VoAo7OMSxryzbIWYN5fkxL/N qTEeUHJxHRxuOpYnWx+86pAJoBLLXv7F1qlu6mv5Bd6ItV2BsANb34Qx9nVT9ClvcMjH SVyVSN1AXAFzK8+55fxym3PwvsIrn1UcCoIP1Xr5cKOn6lackRMDLeVd8GwUjXG7jyb2 ZQMw== X-Gm-Message-State: ALoCoQmg8/Oowx1WVUF3AfIWLoO3E4ULGCW0i4GGjo2thUAVNScCFldJ8cbVER1Fd0vkWFS3QQue X-Received: by 10.112.9.100 with SMTP id y4mr30553260lba.20.1436183846822; Mon, 06 Jul 2015 04:57:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.7 with SMTP id f7ls625075lah.48.gmail; Mon, 06 Jul 2015 04:57:26 -0700 (PDT) X-Received: by 10.152.204.7 with SMTP id ku7mr9829757lac.38.1436183846649; Mon, 06 Jul 2015 04:57:26 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id do5si7708805lac.80.2015.07.06.04.57.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 04:57:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lagc2 with SMTP id c2so151571245lag.3 for ; Mon, 06 Jul 2015 04:57:26 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr47584909lbc.41.1436183846381; Mon, 06 Jul 2015 04:57:26 -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 hn6csp1675275lbb; Mon, 6 Jul 2015 04:57:25 -0700 (PDT) X-Received: by 10.140.86.239 with SMTP id p102mr71880047qgd.49.1436183845110; Mon, 06 Jul 2015 04:57:25 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d13si456014qka.37.2015.07.06.04.57.23; Mon, 06 Jul 2015 04:57:25 -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 95BCE61B52; Mon, 6 Jul 2015 11:57:23 +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 CB12561B41; Mon, 6 Jul 2015 11:57:19 +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 F34E661B45; Mon, 6 Jul 2015 11:57:17 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 3936961B3F for ; Mon, 6 Jul 2015 11:57:17 +0000 (UTC) Received: by wiga1 with SMTP id a1so226595543wig.0 for ; Mon, 06 Jul 2015 04:57:16 -0700 (PDT) X-Received: by 10.194.192.33 with SMTP id hd1mr97015545wjc.96.1436183836413; Mon, 06 Jul 2015 04:57:16 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by mx.google.com with ESMTPSA id wx9sm27745640wjb.6.2015.07.06.04.57.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jul 2015 04:57:15 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 6 Jul 2015 14:57:08 +0300 Message-Id: <1436183828-7364-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH] linux-generic: check for event type while converting packet to event 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: maxim.uvarov@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.41 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 All examples of odp code do not check odp_schedule() output, I.e.: ev = odp_schedule() pkt = odp_packet_from_event(ev) Because of ev can be not only packet (timer, crypto operation), add check that only packet event can be converted to packet. Signed-off-by: Maxim Uvarov --- After Zoltan's changes to API-NEXT I think it's reasonable to add check to odp_packet_from_event() to make linux-generic catch other non packets events. Thanks, Maxim. platform/linux-generic/odp_crypto.c | 2 +- platform/linux-generic/odp_packet.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index d49e256..22071d8 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -40,7 +40,7 @@ static odp_crypto_global_t *global; static odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) { - return &(odp_packet_hdr(odp_packet_from_event(ev))->op_result); + return &(odp_packet_hdr((odp_packet_t)ev)->op_result); } static diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 668ddda..586ad09 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -77,6 +77,9 @@ odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt) odp_packet_t odp_packet_from_event(odp_event_t ev) { + if (odp_unlikely(odp_event_type(ev) != ODP_EVENT_PACKET)) + ODP_ABORT("Dispatching not packet event %d\n", + odp_event_type(ev)); return (odp_packet_t)ev; }