[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <979A8436335E3744ADCD3A9F2A2B68A52AC5EE34@SJEXCHMB10.corp.ad.broadcom.com>
Date: Fri, 24 May 2013 03:50:45 +0000
From: "Yuval Mintz" <yuvalmin@...adcom.com>
To: "Joe Perches" <joe@...ches.com>
cc: "bhutchings@...arflare.com" <bhutchings@...arflare.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"Eilon Greenstein" <eilong@...adcom.com>
Subject: RE: [PATCH] Ethtool: Beautify private flags print
> On Thu, 2013-05-23 at 20:55 +0300, Yuval Mintz wrote:
> > When printing the private flags of the device, align all strings
> > to have the same length.
> []
> > diff --git a/ethtool.c b/ethtool.c
> []
> > + for (i = 0; i < strings->len; i++) {
> > + int j;
> > +
> > + printf("%s", (const char *)strings->data +
> > + i * ETH_GSTRING_LEN);
> > +
> > + cur_len = strlen((const char*)strings->data +
> > + i * ETH_GSTRING_LEN);
> > + for (j = 0; j < max_len - cur_len; j++)
> > + printf(" ");
>
> I think this isn't necessary, but this is simpler
>
> "%-*s", max_len, strings->data + i * ETH_GSTRING_LEN
Nice - I was unfamiliar with this second-order format string modifier.
I'll modify the patch into using this format.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists