From: Sascha Hauer <s.hauer@pengutronix.de>
To: Franck Jullien <franck.jullien@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] cosmetic: improve drivers list display
Date: Fri, 12 Oct 2012 10:12:29 +0200 [thread overview]
Message-ID: <20121012081229.GM27665@pengutronix.de> (raw)
In-Reply-To: <1349989025-13612-1-git-send-email-franck.jullien@gmail.com>
On Thu, Oct 11, 2012 at 10:57:05PM +0200, Franck Jullien wrote:
> When the drivers list is printed with devinfo one can have some
> unaligned strings because of the arbitrary %10s alignment in the printf.
>
> This adds a first step finding the longest driver name, then the printf
> alignment is matched to this value.
Maybe instead just print the driver list left aligned? When I
implemented this I thought that it looked nice when printing them
right aligned, but in the end it doesn't matter and shouldn't cause
additional code.
Sascha
>
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
> drivers/base/driver.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> index 5b7286a..9dd479e 100644
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -397,6 +397,7 @@ static int do_devinfo(int argc, char *argv[])
> struct param_d *param;
> int i;
> struct resource *res;
> + int max_length = 0;
>
> if (argc == 1) {
> printf("devices:\n");
> @@ -408,7 +409,12 @@ static int do_devinfo(int argc, char *argv[])
>
> printf("\ndrivers:\n");
> for_each_driver(drv)
> - printf("%10s\n",drv->name);
> + if (strlen(drv->name) > max_length)
> + max_length = strlen(drv->name);
> +
> + for_each_driver(drv)
> + printf("%*s\n", max_length, drv->name);
> +
> } else {
> dev = get_device_by_name(argv[1]);
>
> --
> 1.7.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-10-12 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 20:57 Franck Jullien
2012-10-12 8:12 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121012081229.GM27665@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=franck.jullien@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox