From patchwork Mon Dec 1 16:15:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41795 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2173420672 for ; Mon, 1 Dec 2014 16:16:51 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf6982791wib.10 for ; Mon, 01 Dec 2014 08:16:50 -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=G9H1wgH6cZ3GMxoZvVJWHqK5XrjpCpmDD16Cku2Hcf0=; b=PXySZpDNyQRXEaV6B556kkLOdeLJB4KLPx0XFMNFiMNRuxPXwi2l1/kDICLJnXO+TJ cWsqrQowhimFeeYWfKCg0zGl3f2Qyl0sshg41hImq7C6F+wc+mcIT5Ug50aEZWBChgZA yN1Q0aY7kg8MKFDhPi5piggrPkzFkaji2Ct89HboApbsUqAUpeZ3NOK7gqZ3N5vwL2aX bAifYXHJAa+WhmfJss3cXwMy4D0VBnVc06dEs4EsU4Ss0xxNDZF8L2kvg/6T7TNKDjYk 5rjS5aFojZf/tdPfLHLXopFvJzhsdLYmfjNgp0ME0yN+PUBLG1emQe0ah3pAKZPU9j1q h27A== X-Gm-Message-State: ALoCoQnnYCDB4DYR0/ZobXdRdi7gy5tpnD9mmlms5e9vEv0Y/j8TyT6OLFJGy/9LxB+YXPoUhxhp X-Received: by 10.152.10.233 with SMTP id l9mr16055273lab.0.1417450610377; Mon, 01 Dec 2014 08:16:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.9 with SMTP id f9ls739051laa.66.gmail; Mon, 01 Dec 2014 08:16:50 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr56270907lbr.74.1417450610153; Mon, 01 Dec 2014 08:16:50 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id a3si18112693lbv.43.2014.12.01.08.16.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:16:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so4410967lab.27 for ; Mon, 01 Dec 2014 08:16:50 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr34252152lal.29.1417450610067; Mon, 01 Dec 2014 08:16:50 -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 ew9csp320030lbc; Mon, 1 Dec 2014 08:16:47 -0800 (PST) X-Received: by 10.236.14.234 with SMTP id d70mr13048946yhd.196.1417450606586; Mon, 01 Dec 2014 08:16:46 -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 d9si20981123qch.30.2014.12.01.08.16.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:16:46 -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 1XvTeW-0007Fv-Sb; Mon, 01 Dec 2014 16:16:44 +0000 Received: from mail-lb0-f180.google.com ([209.85.217.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvTdw-0007B0-5v for lng-odp@lists.linaro.org; Mon, 01 Dec 2014 16:16:08 +0000 Received: by mail-lb0-f180.google.com with SMTP id l4so8936923lbv.11 for ; Mon, 01 Dec 2014 08:16:02 -0800 (PST) X-Received: by 10.112.201.72 with SMTP id jy8mr57616517lbc.65.1417450562634; Mon, 01 Dec 2014 08:16:02 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id ar4sm4819466lbc.48.2014.12.01.08.16.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:16:01 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 1 Dec 2014 19:15:35 +0300 Message-Id: <1417450537-7640-10-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1417450537-7640-1-git-send-email-maxim.uvarov@linaro.org> References: <1417450537-7640-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 09/11] 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.215.54 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 8dc4fb1..6c8307e 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -561,12 +561,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); @@ -591,12 +592,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) {