72332c
From 37c5b64e0e6966afe66d62ad9c700d27f3065e4e Mon Sep 17 00:00:00 2001
72332c
From: Dmitry Safonov <dima@arista.com>
72332c
Date: Thu, 10 May 2018 19:14:43 +0100
72332c
Subject: [PATCH 3/8] aio: Allow expressions in NR_IOEVENTS_IN_PAGES macro
72332c
72332c
The macro is used only in aio_estimate_nr_reqs():
72332c
unsigned int k_max_reqs = NR_IOEVENTS_IN_NPAGES(size/PAGE_SIZE);
72332c
72332c
Which compiler may evaluate as (((PAGE_SIZE*size)/PAGE_SIZE) - ...)
72332c
It works as long as PAGE_SIZE is long.
72332c
The patches set converts PAGE_SIZE to use sysconf() returning
72332c
(unsigned), non-long type and making the aio macro overflowing.
72332c
72332c
I do not see any value making PAGE_SIZE (unsigned long) typed.
72332c
72332c
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
72332c
Signed-off-by: Dmitry Safonov <dima@arista.com>
72332c
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
72332c
---
72332c
 criu/aio.c | 2 +-
72332c
 1 file changed, 1 insertion(+), 1 deletion(-)
72332c
72332c
diff --git a/criu/aio.c b/criu/aio.c
72332c
index 27c251df5..45651f2d3 100644
72332c
--- a/criu/aio.c
72332c
+++ b/criu/aio.c
72332c
@@ -13,7 +13,7 @@
72332c
 #include "images/mm.pb-c.h"
72332c
 #include <compel/compel.h>
72332c
 
72332c
-#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * npages - sizeof(struct aio_ring)) / sizeof(struct io_event))
72332c
+#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * (npages) - sizeof(struct aio_ring)) / sizeof(struct io_event))
72332c
 
72332c
 int dump_aio_ring(MmEntry *mme, struct vma_area *vma)
72332c
 {
72332c
-- 
72332c
2.17.0
72332c