From patchwork Wed Dec 21 15:26:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 88753 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp2764533obb; Wed, 21 Dec 2016 07:26:30 -0800 (PST) X-Received: by 10.200.35.139 with SMTP id q11mr5467773qtq.274.1482333990820; Wed, 21 Dec 2016 07:26:30 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u40si15220724qtb.199.2016.12.21.07.26.30; Wed, 21 Dec 2016 07:26:30 -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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2B20A60DC9; Wed, 21 Dec 2016 15:26:30 +0000 (UTC) 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 7652960B25; Wed, 21 Dec 2016 15:26:26 +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 3C12B60C18; Wed, 21 Dec 2016 15:26:24 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 19C2560A3F for ; Wed, 21 Dec 2016 15:26:23 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id t196so100154508lff.3 for ; Wed, 21 Dec 2016 07:26:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Wp+PF3m492sqHiZwirCzl4dZJIAr+cO/FB48tfpPlTY=; b=tpOsCOWGx0P/u5UFE10P3ZqfC7kQ9QtnvmQiqb+u8nYOoO/+J70kQDw4nnfRgHQHgu Aw8P4/mYgRb/YOmLPib+37pG+PzodyZAeiyXoCTvuVtCKcJ0rOntrbdSSMUyQfYtWvYZ qFY6UaxzbHu+SM/bJX8mDYFdwvzjjedcamKEFgE+IJAEIuUONeYXvM7BUjWe/uXRvHl8 JxzMqbFx8UPG3323/IOvWGH3zhsyOdfcSyoQaq3FnRNn2Hj7zJZ4qnktD21aa95jM+BZ odArWlyMcR40a3AAIX9xrWcfJ+Pw+Lf7mpVyyd8pKyo+NX//Pp29i1bQG26NV+DpCeDg yG5A== X-Gm-Message-State: AIkVDXIMJaEQ7jNX3BdKgeTTzugd159gDL948Gdm8i28qnUK4qATd00l7c5z0yZs0mTUXYilEFA= X-Received: by 10.46.72.1 with SMTP id v1mr2498223lja.49.1482333981871; Wed, 21 Dec 2016 07:26:21 -0800 (PST) Received: from localhost.localdomain (ppp91-77-165-188.pppoe.mtu-net.ru. [91.77.165.188]) by smtp.gmail.com with ESMTPSA id s63sm5929081lja.19.2016.12.21.07.26.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Dec 2016 07:26:21 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 21 Dec 2016 18:26:03 +0300 Message-Id: <1482333963-20494-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 Subject: [lng-odp] [API-NEXT PATCH] linux-generic: packet: fix buggy compiler error 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" On debian jessie gcc unable to compile current code with error: odp_packet.c: In function 'odp_packet_trunc_head': odp_packet.c:314:46: error: array subscript is above array bounds [-Werror=array-bounds] to->buf_hdr.seg[i].len = from->buf_hdr.seg[num + i].len; The problem is that it breaks compilation only on .len line: for (i = 0; i < num; i++) { to->buf_hdr.seg[i].hdr = from->buf_hdr.seg[num + i].hdr; to->buf_hdr.seg[i].data = from->buf_hdr.seg[num + i].data; to->buf_hdr.seg[i].len = from->buf_hdr.seg[num + i].len; } If that line is commented out compilation passes. If lines are reordered than compilation also passes. Because there is no warning on .hdr and .data it looks like compiler error. Additional check for preconfigured value is workaround to that situation. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.1.250.gff4ea60 diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 0d3fd05..f3e0a12 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -309,6 +309,8 @@ static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, int i; for (i = 0; i < num; i++) { + if (odp_unlikely((num + i) >= CONFIG_PACKET_MAX_SEGS)) + ODP_ABORT("packet segmenation error\n"); to->buf_hdr.seg[i].hdr = from->buf_hdr.seg[num + i].hdr; to->buf_hdr.seg[i].data = from->buf_hdr.seg[num + i].data; to->buf_hdr.seg[i].len = from->buf_hdr.seg[num + i].len;