[Xfce4-commits] [panel-plugins/xfce4-netload-plugin] 02/02: Fix unit_names index

noreply at xfce.org noreply at xfce.org
Sat Nov 15 23:00:20 CET 2014


This is an automated email from the git hooks/post-receive script.

mmassonnet pushed a commit to branch master
in repository panel-plugins/xfce4-netload-plugin.

commit 4a5dea3435cc6b1e2322240124f18948240cf4b2
Author: Mike Massonnet <m8t at gandi.net>
Date:   Sat Nov 15 23:00:15 2014 +0100

    Fix unit_names index
---
 panel-plugin/utils.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/utils.c b/panel-plugin/utils.c
index c49744a..c2824ba 100644
--- a/panel-plugin/utils.c
+++ b/panel-plugin/utils.c
@@ -76,7 +76,7 @@ char* format_byte_humanreadable(char* string, int stringsize, double number, int
     char buffer[BUFSIZ], formatstring[BUFSIZ];
     char* bufptr = buffer;
     char* unit_names[] = { N_("B"), N_("KiB"), N_("MiB"), N_("GiB") };
-    unsigned int uidx = 1;
+    unsigned int uidx = 0;
     double number_displayed = number / 1024.0;
     unsigned int i;
     int numberOfIntegerChars, count;
@@ -97,7 +97,7 @@ char* format_byte_humanreadable(char* string, int stringsize, double number, int
     }
 
     /* calculate number and appropriate unit size for display */
-    while(number_displayed >= 1024.0 && uidx < sizeof(unit_names))
+    while(number_displayed >= 1024.0 && uidx < (sizeof(unit_names) / sizeof(char*) - 1))
     {
         number_displayed /= 1024.0;
         uidx++;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list