From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36AF0C4BA06 for ; Tue, 25 Feb 2020 23:15:35 +0000 (UTC) Received: from krantz.zx2c4.com (krantz.zx2c4.com [192.95.5.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD8532176D for ; Tue, 25 Feb 2020 23:15:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="uxP5/kCF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD8532176D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=wireguard-bounces@lists.zx2c4.com Received: from krantz.zx2c4.com (localhost [IPv6:::1]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 81bd9910; Tue, 25 Feb 2020 23:10:48 +0000 (UTC) Received: from krantz.zx2c4.com (localhost [127.0.0.1]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id dcc084c2 for ; Tue, 25 Feb 2020 23:10:47 +0000 (UTC) Received: from frisell.zx2c4.com (frisell.zx2c4.com [192.95.5.64]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 2ac55c11 for ; Tue, 25 Feb 2020 23:10:47 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 80b14202 for ; Tue, 25 Feb 2020 23:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=5RR2IXndJ6KBZCm20OIGp7q32XU=; b=uxP5/k CFNai7mXwmtkBUL77IpoQLCCdXzktF8CSu3u6lg3IkhjtrVCijZs0lmmeou0ixL/ hlpQq2K+c+iHZn3Qa0uoAFD0PvlJ3OoUNixUvuVRoQYsoP58rMpZF0pleuvKFO1T RzZjM03h1slaCIKjDXYqUBPMzA0RJHRmVntxziExdVC1ZuW5rl3aheUYPhagWr9m IHmEoeNhyRbMQWz8De3UVK8Jv7PRF/DVgJY4zfy60XcaajTcK799USl2k5b0KnzJ USODqEwsysJBEmPmVqf8uaDPE70lseB/KOQx2HBeAnOouc81BiQ5K9pvReWza0to n07uDzdVRkN/YSTw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 5700edb8 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Tue, 25 Feb 2020 23:10:46 +0000 (UTC) Received: by mail-oi1-f173.google.com with SMTP id q84so1103374oic.4 for ; Tue, 25 Feb 2020 15:14:20 -0800 (PST) X-Gm-Message-State: APjAAAVE5dfP0L70+ISE9KT8hvBFkj2iAzb9ERIEIm7wKVDKne+Ygz7/ iVrLhBcnLypQPxQw901VxacObF3ahl/QMvJwGjw= X-Google-Smtp-Source: APXvYqxdZcuGs8IsrKqCimyeqz4gOipPoxV69jawT9LbiY0i9iOOpchhUsStWeIEzDRhWO4/+C6ok0eeJLku1ylaS5w= X-Received: by 2002:a05:6808:a8a:: with SMTP id q10mr969064oij.66.1582672460035; Tue, 25 Feb 2020 15:14:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Jason A. Donenfeld" Date: Wed, 26 Feb 2020 07:14:08 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH][wireguard-android] fix formatBytes to be able to display gibibytes To: =?UTF-8?Q?Fran=C3=A7ois_Guerraz?= Cc: WireGuard mailing list X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============2977978326039334687==" Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" --===============2977978326039334687== Content-Type: multipart/alternative; boundary="000000000000c6bba7059f6ea54c" --000000000000c6bba7059f6ea54c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. Can you resend this with your Signed-off-by line? On Wed, Feb 26, 2020, 07:12 Fran=C3=A7ois Guerraz 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.j= ava > > b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.j= ava > index 57e0d8e..bc0726a 100644 > --- > a/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.j= ava > +++ > b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.j= ava > @@ -115,7 +115,7 @@ public class TunnelDetailFragment extends BaseFragmen= t > { > 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 > --000000000000c6bba7059f6ea54c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks. Can you resend this with your Signed-off-by line?=

= On Wed, Feb 26, 2020, 07:12 Fran=C3=A7ois Guerraz <kubrick@fgv6.net> wrote:
The default type for literal numerals is int, not long it, th= erefore
1024*1024*1024*1024
overflows and
=C2=A0 =C2=A0 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/TunnelDetailF= ragment.java
b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.jav= a
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 = {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return
getContext().getString(R.string.transfer_kibibytes, bytes/1024.0);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else if (bytes < 1024*1024*1024)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return
getContext().getString(R.string.transfer_mibibytes,
bytes/(1024.0*1024.0));
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 else if (bytes < 1024*1024*1024*1024)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else if (bytes < 1024*1024*1024*1024L)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return
getContext().getString(R.string.transfer_gibibytes,
bytes/(1024.0*1024.0*1024.0));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return getContext().getString(R.string.tr= ansfer_tibibytes,
bytes/(1024.0*1024.0*1024.0)/1024.0);
=C2=A0 =C2=A0 =C2=A0}
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinf= o/wireguard
--000000000000c6bba7059f6ea54c-- --===============2977978326039334687== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ WireGuard mailing list WireGuard@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/wireguard --===============2977978326039334687==--