[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120213201243.GM15955@infradead.org>
Date: Mon, 13 Feb 2012 18:12:43 -0200
From: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung.kim@....com>,
Namhyung Kim <namhyung@...il.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 01/11] perf tools: Introduce struct perf_maps_opts
Em Mon, Feb 13, 2012 at 12:19:37PM -0700, David Ahern escreveu:
>
>
> On 02/13/2012 12:05 PM, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Feb 13, 2012 at 11:50:29AM -0700, David Ahern escreveu:
> >> Today's perf if you give it an invalid pid, scandir fails and the
> >> command spits out the usage statement. Which is completely confusing --
> >> ie., not clear that the command failed b/c the pid does not exist.
> > Humm, ok, but then I think we should have an enum + a strerror(3)
> > equivalent, i.e.:
> > enum perf_target_error perf_evlist__create_maps(...);
> > int perf_target__strerror(struct perf_target *target, int errnum,
> > char *buf, size_t buflen);
> ok, so you are proposing an internal generation of enum error codes and
> correlating them to strings rather than adding a buffer into
> perf_target. If that's the case perhaps we need a libperf-wide design:
> enum perf_error perf__strerror(enum perf_error)
>
> which effectively taps an array similar to _sys_errlist_internal based
> on enum index.
I think a per class mechanism is better. I.e. some errors are too
specific.
I couldn't find any standard way to know the max errno value used :-\ If
we had that we could reuse strerror_r and use a different range for per
class specific errnos, i.e.:
int perf_target__strerror(struct perf_target *target, int errnum,
char *buf, size_t buflen)
{
if (errnum < MAX_ERRNO)
return strerror_r(errnum, buf, buflen);
errnum -= MAX_ERRNO;
if (errnum >= PERF_TARGET__MAX_ERRNO)
return -1;
snprintf(buf, buflen, "%s", perf_target__error_str[errnum]);
return 0;
}
> > Please see 'man strerror_r", and make it work like the POSIX compliant
> > variant.
>
> No globals are in use, so I would expect the _r to be redundant. I have
> glibc source; scanning __strerror_r implementation ....
>
> >
> > Ok, so it may be better to first process Kim's patches and then you
> > rework yours?
>
> The current patch is ready to go; I just don't like the error handling
> and lack of a useful message. That said, it is no worse than what
> happens today.
Yeah, we can go with what you have and then add the
perf_target__strerror on top, I'll read it now.
- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists