Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH][wireguard-android] fix formatBytes to be able to display gibibytes
@ 2020-02-25 22:41 François Guerraz
  2020-02-25 23:14 ` Jason A. Donenfeld
  0 siblings, 1 reply; 2+ messages in thread
From: François Guerraz @ 2020-02-25 22:41 UTC (permalink / raw)
  To: wireguard

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@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-25 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 22:41 [PATCH][wireguard-android] fix formatBytes to be able to display gibibytes François Guerraz
2020-02-25 23:14 ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).