Re: [Bcache v13 09/16] Bcache: generic utility code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-05-22 at 23:12 -0400, Kent Overstreet wrote:
> On Tue, May 22, 2012 at 02:17:06PM -0700, Tejun Heo wrote:
[]
> > > +ssize_t hprint(char *buf, int64_t v)
> > > +{
> > > +	static const char units[] = "?kMGTPEZY";
> > > +	char dec[3] = "";
> > > +	int u, t = 0;
> > > +
> > > +	for (u = 0; v >= 1024 || v <= -1024; u++) {
> > > +		t = v & ~(~0 << 10);
> > > +		v >>= 10;
> > > +	}
> > > +
> > > +	if (!u)
> > > +		return sprintf(buf, "%llu", v);
> > > +
> > > +	if (v < 100 && v > -100)
> > > +		sprintf(dec, ".%i", t / 100);
> > > +
> > > +	return sprintf(buf, "%lli%s%c", v, dec, units[u]);
> > > +}
> > > +EXPORT_SYMBOL_GPL(hprint);
> > 
> > Not your fault but maybe we want integer vsnprintf modifier for this.
> 
> Yes.

or maybe yet another lib/vsprintf pointer extension
like %pD with some descriptors after the %pD for
type, width and precision.


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux