Message ID | 1340743869-12293-3-git-send-email-ehabkost@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, Jun 26, 2012 at 8:51 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > While we are at it, rename it to "length", as "memory" doesn't mean > anything. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > exec.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/exec.c b/exec.c > index 8244d54..5f3b265 100644 > --- a/exec.c > +++ b/exec.c > @@ -2354,7 +2354,7 @@ static long gethugepagesize(const char *path) > } > > static void *file_ram_alloc(RAMBlock *block, > - ram_addr_t memory, > + size_t length, > const char *path) > { > char *filename; > @@ -2370,7 +2370,7 @@ static void *file_ram_alloc(RAMBlock *block, > return NULL; > } > > - if (memory < hpagesize) { > + if (length < hpagesize) { > return NULL; > } > > @@ -2392,7 +2392,7 @@ static void *file_ram_alloc(RAMBlock *block, > unlink(filename); > free(filename); > > - memory = (memory+hpagesize-1) & ~(hpagesize-1); > + length = (length+hpagesize-1) & ~(hpagesize-1); Please add spaces around operators like '+' and '-'. > > /* > * ftruncate is not supported by hugetlbfs in older > @@ -2400,7 +2400,7 @@ static void *file_ram_alloc(RAMBlock *block, > * If anything goes wrong with it under other filesystems, > * mmap will fail. > */ > - if (ftruncate(fd, memory)) > + if (ftruncate(fd, length)) Missing braces. The above problems could be detected with scripts/checkpatch.pl. > perror("ftruncate"); > > #ifdef MAP_POPULATE > @@ -2409,9 +2409,9 @@ static void *file_ram_alloc(RAMBlock *block, > * to sidestep this quirk. > */ > flags = mem_prealloc ? MAP_POPULATE | MAP_SHARED : MAP_PRIVATE; > - area = mmap(0, memory, PROT_READ | PROT_WRITE, flags, fd, 0); > + area = mmap(0, length, PROT_READ | PROT_WRITE, flags, fd, 0); > #else > - area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); > + area = mmap(0, length, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); > #endif > if (area == MAP_FAILED) { > perror("file_ram_alloc: can't mmap RAM pages"); > -- > 1.7.10.4 > >
diff --git a/exec.c b/exec.c index 8244d54..5f3b265 100644 --- a/exec.c +++ b/exec.c @@ -2354,7 +2354,7 @@ static long gethugepagesize(const char *path) } static void *file_ram_alloc(RAMBlock *block, - ram_addr_t memory, + size_t length, const char *path) { char *filename; @@ -2370,7 +2370,7 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } - if (memory < hpagesize) { + if (length < hpagesize) { return NULL; } @@ -2392,7 +2392,7 @@ static void *file_ram_alloc(RAMBlock *block, unlink(filename); free(filename); - memory = (memory+hpagesize-1) & ~(hpagesize-1); + length = (length+hpagesize-1) & ~(hpagesize-1); /* * ftruncate is not supported by hugetlbfs in older @@ -2400,7 +2400,7 @@ static void *file_ram_alloc(RAMBlock *block, * If anything goes wrong with it under other filesystems, * mmap will fail. */ - if (ftruncate(fd, memory)) + if (ftruncate(fd, length)) perror("ftruncate"); #ifdef MAP_POPULATE @@ -2409,9 +2409,9 @@ static void *file_ram_alloc(RAMBlock *block, * to sidestep this quirk. */ flags = mem_prealloc ? MAP_POPULATE | MAP_SHARED : MAP_PRIVATE; - area = mmap(0, memory, PROT_READ | PROT_WRITE, flags, fd, 0); + area = mmap(0, length, PROT_READ | PROT_WRITE, flags, fd, 0); #else - area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + area = mmap(0, length, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); #endif if (area == MAP_FAILED) { perror("file_ram_alloc: can't mmap RAM pages");
While we are at it, rename it to "length", as "memory" doesn't mean anything. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)