From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by dpdk.org (Postfix) with ESMTP id C15A136E for ; Fri, 10 Mar 2017 15:41:06 +0100 (CET) Received: by mail-wr0-f171.google.com with SMTP id l37so66244726wrc.1 for ; Fri, 10 Mar 2017 06:41:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=a9GJm3Ndu0Of47Gw5ktEMfbCofH3F7sZLnAepKl/1pw=; b=tzVW0lNwez6rcZNUHiB2X96FTCt9HRmsSr6e78z0z+zpw+/Vmp1F57jpfockkn60E4 8zb70Dy/wzLH7USYPy+M604ogJUZVUR1HkQNZ5j20Ag4cpRKgQyCDR9wzNX4GlxkzXAX XhI/3ZYLjoZzcR9ZSWeQg62icQU4jHdu69TRpt1Zk7GOAFQFLXSLM0IacTD7tSu/l4f0 WhZjdytMydhsNNW/82r0IydWmwckIrseVBbRrrp+ztyv45S/M8wpAXzDhygKaEW8M7KU fhz3BYxXqulHsT/jAIVl1GkPX9TQGghpoWun0LE3sZN2MoN+znkjs9mTFgZC6O2q+FVP 85jw== 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:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=a9GJm3Ndu0Of47Gw5ktEMfbCofH3F7sZLnAepKl/1pw=; b=pAPaOAyl0PLkhmNwgor2DxYr+cJqywKMEFf3AVFnMrXtRN6Soqmu5lELeQuHnhcFYa kjLa9+09LkEsOlCnn3jKpKY4kvCMK6KmbZtl8YMlLVpD0TE76jH3/6emJFgvxj8nLYTH YQan+1wfswxJ+TYUwJrFCyYDd1fD1uQa54vNmTUqwsbJYngQhTP8eG+5zL7NbAFjiZNb pzVoszejq3d00tUz3XyHCvMXY/xBHrBc6HVZX9i45yWHMYnw+QWFUrT2O8xWjrb9jwMa MUxbOqfxSEturykK6cMYjZFjvFqVSEzrSTXWf7VHeHDdeBqqf0f8s22cIScNdrRx3UP1 Bwlg== X-Gm-Message-State: AMke39nkG3BkRMQcsE2Z1qC1Xin6441w0pePiApy/66o8C+PQH2ECQE4NoOrJ1WsiUUOe1lK X-Received: by 10.223.153.168 with SMTP id y37mr15609119wrb.193.1489156866472; Fri, 10 Mar 2017 06:41:06 -0800 (PST) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id j74sm13208146wrj.21.2017.03.10.06.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 06:41:05 -0800 (PST) From: Thomas Monjalon To: "Wiles, Keith" Cc: dev@dpdk.org Date: Fri, 10 Mar 2017 15:41:05 +0100 Message-ID: <5516131.2JN5YXhbWQ@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: References: <20170214220941.1178-1-keith.wiles@intel.com> <74455339.85cqDTeWke@xps13> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Subject: Re: [dpdk-dev] [PATCH] examples: optind should be reset to one not zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Mar 2017 14:41:06 -0000 2017-03-09 21:11, Wiles, Keith: >=20 > > On Mar 9, 2017, at 2:41 PM, Thomas Monjalon wrote: > >=20 > > 2017-02-14 16:09, Keith Wiles: > >> Signed-off-by: Keith Wiles > >=20 > > Please, could explain and describe what was the consequence of this= > > wrong reset value? > > You can just reply and I will integrate it in the commit when apply= ing. >=20 > Here is the man page text: >=20 > "The variable optind is the index of the next element to be processed= in argv. The system initializes this value to 1. > The caller can reset it to 1 to restart scanning of the same argv, or= when scanning a new argument vector.=E2=80=9D >=20 > The problem I saw with my application was trying to parse the wrong o= ption, which can happen as DPDK parses the first part of the command li= ne and the application parses the second part. If you call getopt() mul= tiple times in the same execution, the behavior is not maintained when = using zero for optind. >=20 >=20 > =E2=80=94 Do not put the next part in the commit message unless you w= ant =E2=80=94=20 > As a side note it appears MacOS is much more picky about trying to us= e optind of zero and not one. I would get a segfault on DPDK running in= MacOS and I assumed Linux/FreeBSD could be fixing optind internally, b= ut it is best to set the correct value in all cases. >=20 > I hope that helps. Applied with this explanation integrated, thanks.