lkml.org 
[lkml]   [2015]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 14/14] perf tools: Move subcommand framework and related utils to libapi
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


\
 
 \ /
  Last update: 2015-12-10 23:01    [W:0.150 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site