[tracker] libtracker-common: Use guint64 for free space calculations



commit d366405906740ee832f418a5d5bf37f63627bbfe
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 21 13:08:21 2016 +0100

    libtracker-common: Use guint64 for free space calculations
    
    We need the whole range after the multiplication with st.f_bsize, gsize
    may overflow here. Also, make the cast to double explicit rather than
    implicit in get_remaining_space_percentage()

 src/libtracker-common/tracker-file-utils.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index 0cf6cd1..2c92179 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -290,7 +290,7 @@ guint64
 tracker_file_system_get_remaining_space (const gchar *path)
 {
        struct __statvfs st;
-       gsize available;
+       guint64 available;
 
        if (statvfs_helper (path, &st)) {
                available = (geteuid () == 0) ? st.f_bfree : st.f_bavail;
@@ -304,11 +304,11 @@ gdouble
 tracker_file_system_get_remaining_space_percentage (const gchar *path)
 {
        struct __statvfs st;
-       gsize available;
+       guint64 available;
 
        if (statvfs_helper (path, &st)) {
                available = (geteuid () == 0) ? st.f_bfree : st.f_bavail;
-               return (available * 100.0 / st.f_blocks);
+               return (((gdouble) available * 100) / st.f_blocks);
        } else {
                return 0.0;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]