>               case 'e':
>                       mult *= 1024;
> +                     /* Fallthrough */

These comments still annoy me :).  And really, that code kind of annoys
me too.  That's a lot of duplicated code for a mapping of characters to
powers of 1024.

How about.. 

u64 pow_u64(u64 x, unsigned y)
{
        u64 ret = 1;

        while (y--)
                ret *= x;

        return ret;
}

u64 get_mult(char unit)
{
        static char *units = "bkmgtpe";
        char *found = index(units, unit);

        if (found)
                return pow_u64(1024, found - units);
        return 0;
}

Seems like a lot less noise for the same functionality.

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

Reply via email to