From patchwork Thu Dec 22 13:49:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 88867 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp2815059qgi; Thu, 22 Dec 2016 05:50:19 -0800 (PST) X-Received: by 10.55.137.4 with SMTP id l4mr9616560qkd.310.1482414619170; Thu, 22 Dec 2016 05:50:19 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t14si8319783qkt.296.2016.12.22.05.50.18; Thu, 22 Dec 2016 05:50:19 -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 218C760CDE; Thu, 22 Dec 2016 13:50:18 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_FRT_BELOW2, 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 3BFC360C3E; Thu, 22 Dec 2016 13:50:13 +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 526EA60C50; Thu, 22 Dec 2016 13:50:11 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id 4E4DE60C20 for ; Thu, 22 Dec 2016 13:50:07 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id t196so119352879lff.3 for ; Thu, 22 Dec 2016 05:50:07 -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=zsxQ1w7OoxdSvqILQW1TvdAO7Zzi/zik7991BkkYu/Y=; b=bNIQPLPjC62KwNw5tCG/RPyv+jiGExXkuazbJXgYqdEpQsFxBUU2u3yGJZvP6/J/Ei pjNxx2CXZZRjXBs/lu/yxkfnSSr4by4J4xIA2vgmVVr0GngL34tiR5HobU8IKgp4PAa2 HS/zmEcpwUPve4xREFGF4Y+11bsfXKsxuUislWRYje/jjq/fT/xMqIU+lj4sQrSu6i1L IETmo/W7YhkLE3qg3cVVZb0SEhFXOTZ0tXrrjB8vkB6w7j9oiolEhQSWAJ+NrH20WEX6 I+NfL9a33c5DZafOO7OUhRqPyFhfcALR9Fay+zfcMndC0RKLaWbR1pkOmWfqosqdogPH jwtQ== X-Gm-Message-State: AIkVDXKulY5F+lfgyZCvaT4N8m07GtMtezu57Yf5VYW/LiomJHSotzZOhTLkuuz18DuyuEXDyoA= X-Received: by 10.25.196.88 with SMTP id u85mr3950570lff.69.1482414605883; Thu, 22 Dec 2016 05:50:05 -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 d16sm7116458lfj.14.2016.12.22.05.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Dec 2016 05:50:05 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 22 Dec 2016 16:49:51 +0300 Message-Id: <1482414591-10661-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 Subject: [lng-odp] [PATCHv2] 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 fails on .len line. 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 --- v2: - add comment (Mike) - in description .len line reorder does not fix compilation (Bill) platform/linux-generic/odp_packet.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.1.250.gff4ea60 Reviewed-by: Mike Holmes diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 0d3fd05..599d839 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -309,6 +309,10 @@ static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, int i; for (i = 0; i < num; i++) { + /* check bellow also fixes gcc bug, refer to corresponding + * git commit */ + 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;