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

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