Development discussion of WireGuard
 help / color / mirror / Atom feed
From: "François Guerraz" <kubrick@fgv6.net>
To: wireguard@lists.zx2c4.com
Subject: [PATCH][wireguard-android] fix formatBytes to be able to display gibibytes
Date: Tue, 25 Feb 2020 17:41:00 -0500	[thread overview]
Message-ID: <CA+zF5m=eFUxsg+7nQCjYEmM-6rGdsOnov3a5VkC+me6iM7Y+yQ@mail.gmail.com> (raw)

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

             reply	other threads:[~2020-02-25 23:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 22:41 François Guerraz [this message]
2020-02-25 23:14 ` Jason A. Donenfeld

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='CA+zF5m=eFUxsg+7nQCjYEmM-6rGdsOnov3a5VkC+me6iM7Y+yQ@mail.gmail.com' \
    --to=kubrick@fgv6.net \
    --cc=wireguard@lists.zx2c4.com \
    /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;
as well as URLs for NNTP newsgroup(s).