Re: [GIT PULL] iscsi-target merge for v3.1-rc1

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

 



On Mon, Jul 25, 2011 at 11:51 PM, Nicholas A. Bellinger
<nab@xxxxxxxxxxxxxxx> wrote:
>
> How about the following to add a new DIV_ROUND_UP_ULL macro

Hmm.

>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> +#define DIV_ROUND_UP_ULL(n,d) (                                \
> +{                                                      \
> +       unsigned long long _tmp = n, _off;              \
> +       int _res;                                       \
> +       /* Round up using asm/div64.h:do_div */         \
> +       _off = do_div(_tmp, d);                         \
> +       if (_off != 0)                                  \
> +               _tmp++;                                 \
> +       _res = _tmp;                                    \
> +}                                                      \
> +)

That looks buggy. Why the "_res = _tmp" there? All that does is to
truncate the result to "int", which looks bogus.

And it just looks unnecessarily complicated. Just a simple

#define DIV_ROUND_UP_ULL(ll,d) \
  ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })

looks like it would work and be simpler. Avoid the conditional, do the
same "add 'd-1' thing as the regular ROUND_UP().

Untested. And not much thinking involved.

                     Linus
--
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