Review Request: fix 4 TB wrap-around of filelight reported sizes on platforms with 64-bit long int
Anssi Hannula
anssi at mageia.org
Sat Oct 15 16:19:26 UTC 2011
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102870/
-----------------------------------------------------------
Review request for KDE Utils.
Description
-------
Filelight internally uses a FileSize type in fileTree.h to represent
file sizes. It is defined as unsigned long and contains kilobytes,
therefore it will wrap around at 4 TB when long int is 32-bit, while
64-bit is safe.
However, File::humanReadableSize() takes the size as uint instead of
FileSize, causing it wrap-around even if long int would be big enough.
This causes e.g. directories that take up 6 TB to have a caption
saying 2 TB usage (the graph is generated correctly, though).
Change it to use FileSize to avoid wrap-around on 64-bit systems where
long int is 64-bit, and to make it consistent with other code.
32-bit systems continue to be affected.
This could be trivially fixed on 32-bit systems as well after this patch by making FileSize always a 64-bit integer (and maybe dropping the divide-by-1024 trick), but since 32-bit int seems to be used due to performance reasons and I couldn't test it on a real 32-bit system, I'll leave that to someone else who can test it or knows for sure that the performance impact would be less than the impact of the wrap-around bug.
Diffs
-----
src/part/fileTree.h fe0a9ec
src/part/fileTree.cpp 6da7a8f
Diff: http://git.reviewboard.kde.org/r/102870/diff/diff
Testing
-------
Built filelight in kdeutils-4.6.5 with this change and wrap-around was fixed. Code in git master seems to have no actual code changes since then.
Thanks,
Anssi Hannula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-utils-devel/attachments/20111015/c3a6f488/attachment.html>
More information about the Kde-utils-devel
mailing list