From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0144.outbound.protection.outlook.com [157.56.110.144]) by dpdk.org (Postfix) with ESMTP id 054BE58EF for ; Wed, 14 Oct 2015 19:54:20 +0200 (CEST) Received: from CY1PR0101MB0987.prod.exchangelabs.com (10.160.224.149) by CY1PR0101MB0986.prod.exchangelabs.com (10.160.224.148) with Microsoft SMTP Server (TLS) id 15.1.293.16; Wed, 14 Oct 2015 17:54:15 +0000 Received: from CY1PR0101MB0987.prod.exchangelabs.com ([10.160.224.149]) by CY1PR0101MB0987.prod.exchangelabs.com ([10.160.224.149]) with mapi id 15.01.0293.007; Wed, 14 Oct 2015 17:54:15 +0000 From: Don Provan To: Tiwei Bie , Bruce Richardson Thread-Topic: [dpdk-dev] [PATCH] eal/bsd: reinitialize optind and optreset to 1 Thread-Index: AQHRBZaShIsSHmJxtkyKmQCqCgDwCZ5pnoZQgAE9PcCAAGFE6Q== Date: Wed, 14 Oct 2015 17:54:14 +0000 Message-ID: References: <1444726446-8106-1-git-send-email-btw@mail.ustc.edu.cn> <1444726446-8106-2-git-send-email-btw@mail.ustc.edu.cn> <20151014022843.GA26774@dell> <20151014093128.GC32308@bricha3-MOBL3> <20151014101933.GB68200@dell>,<20151014112813.GA1514@dell> In-Reply-To: <20151014112813.GA1514@dell> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dprovan@bivio.net; x-originating-ip: [132.245.22.245] x-microsoft-exchange-diagnostics: 1; CY1PR0101MB0986; 5:ovvelqZ9Ynp5xH905Zc21trrKJnBBsXwc0ooZF9vx51yA1uKDcI5nYPkcU0lYSz1fxFyUusaELburShX1krzfUmv9QabLzGTrsa93CEwzoyojbIUHn9X1JF2SghzZnNGRfUOl5vepBmJLsxTSjPGWg==; 24:hJXx5MDFK5WdMzpS/bH5DcaZUzfEPgTYaU55iY6Q9lIVDaEy1IjgRtikUmPgOXJ1t7Mff0rJbuNyYdDUFjgdSZw/GwW6tOjytlhP37VOi+g=; 20:r4FtAw6+wArj3kz4I682xm+4Wi7i+rCZYgj2N0nEFnORqXyLrYjhCcBjavyGU0hISANIhRwvB5pucQzlPFa/5w== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0101MB0986; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(262628399951293); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(2401047)(520078)(8121501046)(5005006)(3002001); SRVR:CY1PR0101MB0986; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0101MB0986; x-forefront-prvs: 0729050452 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(24454002)(199003)(46102003)(5007970100001)(5003600100002)(5004730100002)(93886004)(50986999)(189998001)(81156007)(105586002)(5008740100001)(10400500002)(74316001)(106116001)(5001770100001)(5001960100002)(97736004)(40100003)(86362001)(106356001)(19580405001)(33656002)(77096005)(2950100001)(122556002)(102836002)(11100500001)(19580395003)(76176999)(66066001)(2171001)(87936001)(101416001)(92566002)(2900100001)(5002640100001)(54356999)(64706001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0101MB0986; H:CY1PR0101MB0987.prod.exchangelabs.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:3; A:3; LANG:en; received-spf: None (protection.outlook.com: bivio.net does not designate permitted sender hosts) spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bivio.net X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2015 17:54:14.8585 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8731bc55-0e76-4eb7-ae4b-401e56037945 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0101MB0986 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] eal/bsd: reinitialize optind and optreset to 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Oct 2015 17:54:20 -0000 > > On Wed, Oct 14, 2015 at 10:28:44AM +0800, Tiwei Bie wrote: > > > It is designed to have DPDK's parameters specified in the front of th= e > > > cmd line and terminated by '--'. In other words, it is designed assuming the DPDK library can dictate the application's command line. This is an incorrect assumption that should be eliminated. I don't think I'm the only one that has figured out that layering a service on top of DPDK requires creating a fake argc/argv array. The original plan of having rte_eal_init() parse the actual application command line organized as dictated by DPDK is not reasonable. > > > And 1 or 0 are not some > > > arbitrary values. They are used to put the index back to the beginnin= g > > > of the new argv[] array. They're arbitrary values from the point of view of the calling application. If the caller is using getopt() for its own purposes, it has every reason to expect optind to have the same value after the call to rte_eal_init() that it had before, not some other value that the DPDK library happened to think was useful. > > > We shouldn't mix up DPDK's parameters and application's parameters. > > > And we should group them using '--'. Exactly! Yet we do confuse the two by using getopt() without considering that the application's parameters might not be in the argc/argv list that's passed to rte_eal_init(). > I'm considering updating optind to make it point to the option after > '--' before eal_parse_args() returns, and eal_parse_args() will return > 0 to avoid breaking the current applications which use the return value > of rte_eal_init() to update argc/argv. > > Any comments? Thanks! :-) Don't do it. Last time I looked, optind wasn't even mentioned in the documentation. Even if I thought it was reasonable to change it, I would still argue against using it as an undocumented return value, particularly when the documented return value works fine. -don provan dprovan@bivio.net