Re: [patch 069/104] lib/string_helpers.c:string_get_size(): remove redundant prefixes

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

 



On Fri, 2015-02-13 at 17:02 -0800, Andrew Morton wrote:
> On Fri, 13 Feb 2015 16:05:54 -0800 James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> > @@ -42,31 +44,60 @@ void string_get_size(u64 size, const enum string_size_units units,
> >  		[STRING_UNITS_2] = 1024,
> >  	};
> >  	int i, j;
> > -	u32 remainder = 0, sf_cap;
> > +	u32 remainder = 0, sf_cap, exp;
> >  	char tmp[8];
> > +	const char *unit;
> >  
> >  	tmp[0] = '\0';
> >  	i = 0;
> > +	if (!size)
> > +	  goto out;
> 
> whitespace wart.

Yes, I'll run it through checkpatch before submitting.

> > +	if (blk_size >= divisor[units]) {
> > +		while (blk_size >= divisor[units]) {
> > +			remainder = do_div(blk_size, divisor[units]);
> > +			i++;
> > +		}
> > +	}
> 
> The `if' doesn't do anything.

Right ... I just copied from the original, but it's true we can unwrap
this.

> > +	exp = divisor[units];
> > +	do_div(exp, blk_size);
> > +	if (size >= exp) {
> > +		remainder = do_div(size, divisor[units]);
> > +		remainder *= blk_size;
> > +		i++;
> > +	} else {
> > +		remainder *= size;
> > +	}
> > +	size *= blk_size;
> > +	size += (remainder/divisor[units]);
> > +	remainder %= divisor[units];
> > +
> >  	if (size >= divisor[units]) {
> >  		while (size >= divisor[units]) {
> >  			remainder = do_div(size, divisor[units]);
> >  			i++;
> >  		}
> > +	}
> 
> Here too.

Certainly,

James



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux