[PATCH][wireguard-android] fix formatBytes to be able to display gibibytes
Jason A. Donenfeld
Jason at zx2c4.com
Wed Feb 26 00:14:08 CET 2020
Thanks. Can you resend this with your Signed-off-by line?
On Wed, Feb 26, 2020, 07:12 François Guerraz <kubrick at fgv6.net> wrote:
> The default type for literal numerals is int, not long it, therefore
> 1024*1024*1024*1024
> overflows and
> bytes < 1024*1024*1024*1024
> is always false.
> Therefore, GiBi is never displayed and switches to TiBi immediately.
> ---
> diff --git
> a/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
>
> b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
> index 57e0d8e..bc0726a 100644
> ---
> a/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
> +++
> b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
> @@ -115,7 +115,7 @@ public class TunnelDetailFragment extends BaseFragment
> {
> return
> getContext().getString(R.string.transfer_kibibytes, bytes/1024.0);
> else if (bytes < 1024*1024*1024)
> return
> getContext().getString(R.string.transfer_mibibytes,
> bytes/(1024.0*1024.0));
> - else if (bytes < 1024*1024*1024*1024)
> + else if (bytes < 1024*1024*1024*1024L)
> return
> getContext().getString(R.string.transfer_gibibytes,
> bytes/(1024.0*1024.0*1024.0));
> return getContext().getString(R.string.transfer_tibibytes,
> bytes/(1024.0*1024.0*1024.0)/1024.0);
> }
> _______________________________________________
> WireGuard mailing list
> WireGuard at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/wireguard/attachments/20200226/503a1f0c/attachment.html>
More information about the WireGuard
mailing list