This is a quick fix to avoid potential overflow in zram01 test.

Signed-off-by: Caspar Zhang <cas...@casparzhang.com>
---
 testcases/kernel/mem/zram/zram01.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/mem/zram/zram01.c b/testcases/kernel/mem/zram/zram01.c
index 38adf63..70ae9b1 100644
--- a/testcases/kernel/mem/zram/zram01.c
+++ b/testcases/kernel/mem/zram/zram01.c
@@ -39,7 +39,7 @@ int TST_TOTAL = 1;
 int modprobe = 0;
 
 #define PATH_ZRAM	"/sys/block/zram0"
-#define SIZE		(512 * 1024 * 1024)
+#define SIZE		(512 * 1024 * 1024L)
 #define DEVICE		"/dev/zram0"
 
 static void set_disksize(void);
@@ -83,12 +83,12 @@ static void set_disksize(void)
 	int fd;
 	char size[BUFSIZ];
 
-	tst_resm(TINFO, "create a zram device with %d bytes in size.", SIZE);
+	tst_resm(TINFO, "create a zram device with %ld bytes in size.", SIZE);
 	fd = open(PATH_ZRAM "/disksize", O_WRONLY);
 	if (fd == -1)
 		tst_brkm(TBROK|TERRNO, cleanup, "open %s",
 				PATH_ZRAM "/disksize");
-	sprintf(size, "%d", SIZE);
+	sprintf(size, "%ld", SIZE);
 	if (write(fd, size, strlen(size)) != strlen(size))
 		tst_brkm(TBROK|TERRNO, cleanup, "write %s to %s", size,
 				PATH_ZRAM "/disksize");
@@ -120,7 +120,8 @@ static void write_device(void)
 
 static void verify_device(void)
 {
-	int fd, i, fail;
+	int fd;
+	long i, fail;
 	char *s;
 
 	tst_resm(TINFO, "verify contents from device.");
@@ -139,10 +140,10 @@ static void verify_device(void)
 		i++;
 	}
 	if (i != SIZE-1)
-		tst_resm(TFAIL, "expect size: %d, actual size: %d.",
+		tst_resm(TFAIL, "expect size: %ld, actual size: %ld.",
 				SIZE-1, i);
 	if (fail)
-		tst_resm(TFAIL, "%d failed bytes found.", fail);
+		tst_resm(TFAIL, "%ld failed bytes found.", fail);
 	if (munmap(s, SIZE) == -1)
 		tst_brkm(TBROK|TERRNO, cleanup, "2nd munmap");
 
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to