On Tue, 2015-10-27 at 09:36 +0100, Vitaly Kuznetsov wrote: > Andy Shevchenko <andriy.shevche...@linux.intel.com> writes: > > > On Mon, 2015-10-26 at 14:55 +0100, Vitaly Kuznetsov wrote: > > > string_get_size() loses precision when there is a remainder for > > > blk_size / divisor[units] and size is big enough. E.g > > > string_get_size(8192, 4096, STRING_UNITS_10, ...) returns "32.7 > > > MB" > > > while it is supposed to return "33.5 MB". For some artificial > > > inputs > > > the result can be ridiculously wrong, e.g. > > > string_get_size(3000, 1900, STRING_UNITS_10, ...) returns "3.00 > > > MB" > > > when "5.70 MB" is expected.
[] > > > - int i, j; > > > - u32 remainder = 0, sf_cap, exp; > > > + int order = 0, j; > > > + u64 remainder = 0; > > > + u32 sf_cap; > > > char tmp[8]; > > > const char *unit; > > > > > > tmp[0] = '\0'; > > > - i = 0; > > > > Maybe leave i naming as is. Your order is not strictly speaking an > > order, rather 3x order. I will make patch neater. > > > > While reading the original function I found meaningless 'i' and 'j' > here > a bit consufing but yes, strictly speaking 'i' is a power of > divisor[units], not 'order' and I don't have a good name for it > (div_power?). I'll revert back to 'i' in v2. I agree that names suck, however it might be better to have separate patch to fix naming. Rasmus? -- Andy Shevchenko <andriy.shevche...@linux.intel.com> Intel Finland Oy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/