Blame SOURCES/0019-Cast-variables-to-target-type-before-use.patch

72abff
From abc147f28e5310df4a4c2327f59c7eb65b611254 Mon Sep 17 00:00:00 2001
72abff
From: Sebastien GODARD <sysstat@users.noreply.github.com>
72abff
Date: Fri, 2 Jun 2017 09:38:40 +0200
72abff
Subject: [PATCH] Cast variables to target type before use
72abff
72abff
This patch casts some variables to target type before they are used.
72abff
Without this patch, problems may happen (like issue #150) notably on 32
72abff
bit architectures where sizeof(long) is different from sizeof(long
72abff
long).
72abff
72abff
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
72abff
(cherry picked from commit 7a8306ad184cc2c2e9339c428a98773a7f818e3b)
72abff
---
72abff
 rd_stats.c | 14 +++++++-------
72abff
 1 file changed, 7 insertions(+), 7 deletions(-)
72abff
72abff
diff --git a/rd_stats.c b/rd_stats.c
72abff
index 6aa8698..01276b6 100644
72abff
--- a/rd_stats.c
72abff
+++ b/rd_stats.c
72abff
@@ -532,7 +532,7 @@ void read_diskstats_io(struct stats_io *st_io)
72abff
 				 * OK: It's a (real) device and not a partition.
72abff
 				 * Note: Structure should have been initialized first!
72abff
 				 */
72abff
-				st_io->dk_drive      += rd_ios + wr_ios;
72abff
+				st_io->dk_drive      += (unsigned long long) rd_ios + (unsigned long long) wr_ios;
72abff
 				st_io->dk_drive_rio  += rd_ios;
72abff
 				st_io->dk_drive_rblk += rd_sec;
72abff
 				st_io->dk_drive_wio  += wr_ios;
72abff
@@ -586,7 +586,7 @@ void read_diskstats_disk(struct stats_disk *st_disk, int nbr, int read_part)
72abff
 				st_disk_i = st_disk + dsk++;
72abff
 				st_disk_i->major     = major;
72abff
 				st_disk_i->minor     = minor;
72abff
-				st_disk_i->nr_ios    = rd_ios + wr_ios;
72abff
+				st_disk_i->nr_ios    = (unsigned long long) rd_ios + (unsigned long long) wr_ios;
72abff
 				st_disk_i->rd_sect   = rd_sec;
72abff
 				st_disk_i->wr_sect   = wr_sec;
72abff
 				st_disk_i->rd_ticks  = rd_ticks;
72abff
@@ -1950,11 +1950,11 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
72abff
 				continue;
72abff
 			
72abff
 			st_filesystem_i = st_filesystem + fs++;
72abff
-			st_filesystem_i->f_blocks = buf.f_blocks * buf.f_frsize;
72abff
-			st_filesystem_i->f_bfree  = buf.f_bfree * buf.f_frsize;
72abff
-			st_filesystem_i->f_bavail = buf.f_bavail * buf.f_frsize;
72abff
-			st_filesystem_i->f_files  = buf.f_files;
72abff
-			st_filesystem_i->f_ffree  = buf.f_ffree;
72abff
+			st_filesystem_i->f_blocks = (unsigned long long) buf.f_blocks * (unsigned long long) buf.f_frsize;
72abff
+			st_filesystem_i->f_bfree  = (unsigned long long) buf.f_bfree * (unsigned long long) buf.f_frsize;
72abff
+			st_filesystem_i->f_bavail = (unsigned long long) buf.f_bavail * (unsigned long long) buf.f_frsize;
72abff
+			st_filesystem_i->f_files  = (unsigned long long) buf.f_files;
72abff
+			st_filesystem_i->f_ffree  = (unsigned long long) buf.f_ffree;
72abff
 			strncpy(st_filesystem_i->fs_name, fs_name, MAX_FS_LEN);
72abff
 			st_filesystem_i->fs_name[MAX_FS_LEN - 1] = '\0';
72abff
 			strncpy(st_filesystem_i->mountp, mountp, MAX_FS_LEN);
72abff
-- 
72abff
2.14.3
72abff