From patchwork Wed Dec 3 15:05:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41854 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C08B125E66 for ; Wed, 3 Dec 2014 15:06:54 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf9615572wgh.0 for ; Wed, 03 Dec 2014 07:06:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references: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=Dm+ByjxHjBxZZOpRkgBJdVfmDSnugck7tOP6WjR3zdo=; b=Eg0+Rhy0BY5g7e1s4zLbuwmhMVauax2FsLcCY/cbipS8wX+AKnWh0awTAi8zz0B1vo dBR1l6Mvwgobwlv66NyryjlLe8+8S+vquAyAd+5kREWlhBXzlC6GeFckVKpoUWFDgph+ O18mVcoM5zW/GMJS/QKWoQ0mVDsBPoRIUREo3G5cBA8HVo7RkUuV5CB3YM+Kic1ZurnC r6sayTG6et3pZ1azFZ8MSGFWaZREqGxxCw+rYZJ7fUaKJdFNWdaEmtOGmuOFC2x5ffZk ng8QACa7mROTzwHlGr46OpujErkxjx0ukxVIzOxFpkOgYBkKKYrS31ySTjQvcO1StygP hdIg== X-Gm-Message-State: ALoCoQl2ML7V5aEa+/cUAt8Q3aJkOKuhrSdGzDDiasy83RE0dr5hpgbLQe8r7aqovfcE5dWub59A X-Received: by 10.194.178.163 with SMTP id cz3mr1185769wjc.1.1417619214089; Wed, 03 Dec 2014 07:06:54 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.98 with SMTP id lf2ls161409lac.16.gmail; Wed, 03 Dec 2014 07:06:53 -0800 (PST) X-Received: by 10.112.45.228 with SMTP id q4mr4727179lbm.35.1417619213733; Wed, 03 Dec 2014 07:06:53 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id k10si14833615lam.2.2014.12.03.07.06.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 07:06:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so12197842lbi.24 for ; Wed, 03 Dec 2014 07:06:53 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr4652023lbc.66.1417619213656; Wed, 03 Dec 2014 07:06:53 -0800 (PST) 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.184.201 with SMTP id ew9csp680328lbc; Wed, 3 Dec 2014 07:06:52 -0800 (PST) X-Received: by 10.236.43.176 with SMTP id l36mr6273789yhb.9.1417619212148; Wed, 03 Dec 2014 07:06:52 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id g2si8263519qas.95.2014.12.03.07.06.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 07:06:52 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XwBVu-0005K9-Cl; Wed, 03 Dec 2014 15:06:46 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XwBVV-0005Hn-SW for lng-odp@lists.linaro.org; Wed, 03 Dec 2014 15:06:22 +0000 Received: by mail-lb0-f179.google.com with SMTP id z11so12303563lbi.10 for ; Wed, 03 Dec 2014 07:06:16 -0800 (PST) X-Received: by 10.152.8.194 with SMTP id t2mr4642901laa.21.1417619176391; Wed, 03 Dec 2014 07:06:16 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id r4sm6449679lar.3.2014.12.03.07.06.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 07:06:15 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 3 Dec 2014 18:05:56 +0300 Message-Id: <1417619157-13690-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417619157-13690-1-git-send-email-maxim.uvarov@linaro.org> References: <1417619157-13690-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 5/6] linux-generic: correct socket get for mtu functions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org 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.217.179 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 Socket can be 0 and it's accounted in previews patch. Correct that function too. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet_io.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 900b47c..1a7405e 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -569,12 +569,13 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) return -1; } - if (entry->s.pkt_sock_mmap.sockfd) + if (entry->s.pkt_sock_mmap.sockfd > -1) sockfd = entry->s.pkt_sock_mmap.sockfd; else sockfd = entry->s.pkt_sock.sockfd; - strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ); + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; ifr.ifr_mtu = mtu; ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr); @@ -599,12 +600,13 @@ int odp_pktio_mtu(odp_pktio_t id) return -1; } - if (entry->s.pkt_sock_mmap.sockfd) + if (entry->s.pkt_sock_mmap.sockfd > -1) sockfd = entry->s.pkt_sock_mmap.sockfd; else sockfd = entry->s.pkt_sock.sockfd; - strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ); + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; ret = ioctl(sockfd, SIOCGIFMTU, &ifr); if (ret < 0) {