[PATCH 5/5] os: compress two conditions
Jasper St. Pierre
jstpierre at mecheye.net
Wed Oct 30 03:10:34 CET 2013
"almost identical"? Mind expanding on this?
On Tue, Oct 29, 2013 at 7:25 PM, Peter Hutterer <peter.hutterer at who-t.net>wrote:
> The recent change to use elfutils made these conditions almost identical.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> os/backtrace.c | 29 +++++++++++------------------
> 1 file changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/os/backtrace.c b/os/backtrace.c
> index acf110a..c3a31bc 100644
> --- a/os/backtrace.c
> +++ b/os/backtrace.c
> @@ -134,32 +134,25 @@ xorg_backtrace(void)
> size = backtrace(array, BT_SIZE);
> for (i = 0; i < size; i++) {
> int rc = dladdr(array[i], &info);
> + const char *name;
> + unsigned int addr;
>
> if (rc == 0) {
> ErrorFSigSafe("%u: ?? [%p]\n", i, array[i]);
> continue;
> }
> mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname :
> "(vdso)";
> - if (info.dli_saddr)
> - ErrorFSigSafe(
> - "%u: %s (%s+0x%x) [%p]\n",
> - i,
> - mod,
> - info.dli_sname,
> - (unsigned int)((char *) array[i] -
> - (char *) info.dli_saddr),
> - array[i]);
> +
> + if (info.dli_saddr) {
> + name = info.dli_sname;
> + addr = (unsigned int)((char *) array[i] - (char *)
> info.dli_saddr);
> + }
> else {
> - const char *name = symbol_name(array[i], info.dli_fbase);
> - ErrorFSigSafe(
> - "%u: %s (%s+0x%x) [%p]\n",
> - i,
> - mod,
> - name,
> - (unsigned int)((char *) array[i] -
> - (char *) info.dli_fbase),
> - array[i]);
> + name = symbol_name(array[i], info.dli_fbase);
> + addr = (unsigned int)((char *) array[i] - (char *)
> info.dli_fbase);
> }
> +
> + ErrorFSigSafe("%u: %s (%s+0x%x) [%p]\n", i, mod, name, addr,
> array[i]);
> }
> ErrorFSigSafe("\n");
> }
> --
> 1.8.3.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
--
Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20131029/e9d46d0c/attachment.html>
More information about the xorg-devel
mailing list