pagemap: Use ssize_t type in read_local_page

Submitted by Cyrill Gorcunov on Aug. 10, 2018, 2:58 p.m.

Details

Message ID 20180810145811.21031-1-gorcunov@gmail.com
State Accepted
Series "pagemap: Use ssize_t type in read_local_page"
Headers show

Commit Message

Cyrill Gorcunov Aug. 10, 2018, 2:58 p.m.
Integer is too small for big memory slabs.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/pagemap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/pagemap.c b/criu/pagemap.c
index 227db6bffe3a..06c470a7fed1 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -244,7 +244,7 @@  static int read_local_page(struct page_read *pr, unsigned long vaddr,
 			   unsigned long len, void *buf)
 {
 	int fd = img_raw_fd(pr->pi);
-	int ret;
+	ssize_t ret;
 
 	/*
 	 * Flush any pending async requests if any not to break the
@@ -256,7 +256,7 @@  static int read_local_page(struct page_read *pr, unsigned long vaddr,
 	pr_debug("\tpr%lu-%u Read page from self %lx/%"PRIx64"\n", pr->img_id, pr->id, pr->cvaddr, pr->pi_off);
 	ret = pread(fd, buf, len, pr->pi_off);
 	if (ret != len) {
-		pr_perror("Can't read mapping page %d", ret);
+		pr_perror("Can't read mapping page %zd", ret);
 		return -1;
 	}
 

Comments

Mike Rapoport Aug. 13, 2018, 2:10 p.m.
On Fri, Aug 10, 2018 at 05:58:11PM +0300, Cyrill Gorcunov wrote:
> Integer is too small for big memory slabs.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  criu/pagemap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 227db6bffe3a..06c470a7fed1 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -244,7 +244,7 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  			   unsigned long len, void *buf)
>  {
>  	int fd = img_raw_fd(pr->pi);
> -	int ret;
> +	ssize_t ret;

I think process_async_reads() should also use ssize_t to be on the safe
size :)
 
>  	/*
>  	 * Flush any pending async requests if any not to break the
> @@ -256,7 +256,7 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  	pr_debug("\tpr%lu-%u Read page from self %lx/%"PRIx64"\n", pr->img_id, pr->id, pr->cvaddr, pr->pi_off);
>  	ret = pread(fd, buf, len, pr->pi_off);
>  	if (ret != len) {
> -		pr_perror("Can't read mapping page %d", ret);
> +		pr_perror("Can't read mapping page %zd", ret);
>  		return -1;
>  	}
> 
> -- 
> 2.14.4
Cyrill Gorcunov Aug. 13, 2018, 2:22 p.m.
On Mon, Aug 13, 2018 at 05:10:39PM +0300, Mike Rapoport wrote:
> On Fri, Aug 10, 2018 at 05:58:11PM +0300, Cyrill Gorcunov wrote:
> > Integer is too small for big memory slabs.
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> > ---
> >  criu/pagemap.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/criu/pagemap.c b/criu/pagemap.c
> > index 227db6bffe3a..06c470a7fed1 100644
> > --- a/criu/pagemap.c
> > +++ b/criu/pagemap.c
> > @@ -244,7 +244,7 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
> >  			   unsigned long len, void *buf)
> >  {
> >  	int fd = img_raw_fd(pr->pi);
> > -	int ret;
> > +	ssize_t ret;
> 
> I think process_async_reads() should also use ssize_t to be on the safe
> size :)

Definitely, I could miss some of code snippets. This patch was sitting in vz7
stable branch for hell knows how long ;)
Andrey Vagin Aug. 16, 2018, 10:39 p.m.
Applied, thanks!

On Fri, Aug 10, 2018 at 05:58:11PM +0300, Cyrill Gorcunov wrote:
> Integer is too small for big memory slabs.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  criu/pagemap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 227db6bffe3a..06c470a7fed1 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -244,7 +244,7 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  			   unsigned long len, void *buf)
>  {
>  	int fd = img_raw_fd(pr->pi);
> -	int ret;
> +	ssize_t ret;
>  
>  	/*
>  	 * Flush any pending async requests if any not to break the
> @@ -256,7 +256,7 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  	pr_debug("\tpr%lu-%u Read page from self %lx/%"PRIx64"\n", pr->img_id, pr->id, pr->cvaddr, pr->pi_off);
>  	ret = pread(fd, buf, len, pr->pi_off);
>  	if (ret != len) {
> -		pr_perror("Can't read mapping page %d", ret);
> +		pr_perror("Can't read mapping page %zd", ret);
>  		return -1;
>  	}
>  
> -- 
> 2.14.4
>