public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: torvalds@linux-foundation.org, linux@rasmusvillemoes.dk,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [patch 069/104] lib/string_helpers.c:string_get_size(): remove redundant prefixes
Date: Fri, 13 Feb 2015 17:02:46 -0800	[thread overview]
Message-ID: <20150213170246.9c52ad2a.akpm@linux-foundation.org> (raw)
In-Reply-To: <1423872354.10229.7.camel@HansenPartnership.com>

On Fri, 13 Feb 2015 16:05:54 -0800 James Bottomley <James.Bottomley@hansenpartnership.com> 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.

> +	if (blk_size >= divisor[units]) {
> +		while (blk_size >= divisor[units]) {
> +			remainder = do_div(blk_size, divisor[units]);
> +			i++;
> +		}
> +	}

The `if' doesn't do anything.

> +	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.



  reply	other threads:[~2015-02-14  1:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <54dd30d9.8sIvA5PVH18vSWTI%akpm@linux-foundation.org>
2015-02-12 23:25 ` [patch 069/104] lib/string_helpers.c:string_get_size(): remove redundant prefixes James Bottomley
2015-02-12 23:40   ` Andrew Morton
2015-02-12 23:45     ` James Bottomley
2015-02-12 23:55       ` Andrew Morton
2015-02-14  0:05         ` James Bottomley
2015-02-14  1:02           ` Andrew Morton [this message]
2015-02-14  4:03             ` James Bottomley

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=20150213170246.9c52ad2a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=torvalds@linux-foundation.org \
    /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