From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753728AbbLJVf0 (ORCPT ); Thu, 10 Dec 2015 16:35:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50219 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753353AbbLJVfZ (ORCPT ); Thu, 10 Dec 2015 16:35:25 -0500 Date: Thu, 10 Dec 2015 15:35:24 -0600 From: Josh Poimboeuf To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Borislav Petkov Subject: Re: [PATCH v2 14/14] perf tools: Move subcommand framework and related utils to libapi Message-ID: <20151210213524.GC4934@treble.redhat.com> References: <20151208194026.GL11564@kernel.org> <20151208214825.GI14846@treble.redhat.com> <20151208222732.GA15864@kernel.org> <20151208230725.GJ14846@treble.redhat.com> <20151209080343.GA14846@gmail.com> <20151209123315.GA15897@treble.redhat.com> <20151209155808.GO11564@kernel.org> <20151209185915.GA14778@treble.hsd1.ky.comcast.net> <20151210014039.GA13790@sejong> <20151210145445.GC29872@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151210145445.GC29872@treble.redhat.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2015 at 08:54:45AM -0600, Josh Poimboeuf wrote: > On Thu, Dec 10, 2015 at 10:40:39AM +0900, Namhyung Kim wrote: > > > - usage.c: used in several places for die() and error(), but these are > > > trivial functions which can be duplicated. > > > > Not sure it's ok to call die() or similar in a library. The error > > should be reported to the caller rather than exiting inside unless > > explicitly requested like in usage_with_options() IMHO. > > Thanks, good point. I'll try to remove all exits from the library > (except for the explicit requests). As it turns out, some special options like '--list-opts' and '--list-cmds' are implemented within parse_options_subcommand(), which then does an exit(). If those exit()'s were replaced with negative return codes, we'd have to provide a way for callers to distinguish between a normal early exit and a real error (in which the usage printout might be appropriate). That would be a disruptive change and require the 40+ callers of the parse_options*() functions to have more complexity (because they'd need to check for more return conditions). So I'm thinking I'll leave the code as it is for now and just document the fact that these functions can exit(). -- Josh