Skip to contentSkip to conversation

linux-user: fix compile failure if !CONFIG_USE_GUEST_BASE

PATCH Applied Peter Maydell 2 participants 3 messages Feb 10, 2011 – Mar 3, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: fix compile failure if !CONFIG_USE_GUEST_BASE

If CONFIG_USE_GUEST_BASE is not defined, gcc complains:
linux-user/mmap.c:235: error: comparison of unsigned expression >= 0 is always true

because RESERVED_VA is #defined to 0. Since mmap_find_vma_reserved() will never be called anyway if RESERVED_VA is always 0, fix this by simply #ifdef'ing away the function and its callsite.

---
I'm not a great fan of introducing #ifdefs, but I couldn't come up with a cleaner way of shutting gcc up...

 linux-user/mmap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
linux-user/mmap.c +4 -0
index abf21f6..0cf22f8 100644
@@ -216,6 +216,7 @@ static abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
 
 unsigned long last_brk;
 
+#ifdef CONFIG_USE_GUEST_BASE
 /* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk
    of guest address space.  */
 static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
@@ -249,6 +250,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
     mmap_next_start = addr;
     return last_addr;
 }
+#endif
 
 /*
  * Find and reserve a free memory area of size 'size'. The search
@@ -271,9 +273,11 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
 
     size = HOST_PAGE_ALIGN(size);
 
+#ifdef CONFIG_USE_GUEST_BASE
     if (RESERVED_VA) {
         return mmap_find_vma_reserved(start, size);
     }
+#endif
 
     addr = start;
     wrapped = repeat = 0;
Signature · 1 line
1.7.1
#1 lore raw

Ping?

Quoted 52 lines · Peter Maydell

If CONFIG_USE_GUEST_BASE is not defined, gcc complains:
 linux-user/mmap.c:235: error: comparison of unsigned expression >= 0 is always true

because RESERVED_VA is #defined to 0. Since mmap_find_vma_reserved() will never be called anyway if RESERVED_VA is always 0, fix this by simply #ifdef'ing away the function and its callsite.

---
I'm not a great fan of introducing #ifdefs, but I couldn't come up with a cleaner way of shutting gcc up...

 linux-user/mmap.c |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
linux-user/mmap.c +1 -0
index abf21f6..0cf22f8 100644
@@ -216,6 +216,7 @@ static abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
 
  unsigned long last_brk;
 
+#ifdef CONFIG_USE_GUEST_BASE
  /* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk

   of guest address space.  */
 static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)

linux-user/mmap.c +3 -1
@@ -249,6 +250,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
     mmap_next_start = addr;
     return last_addr;
  }
+#endif
 
  /*
  * Find and reserve a free memory area of size 'size'. The search
@@ -271,9 +273,11 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
 
     size = HOST_PAGE_ALIGN(size);
 
+#ifdef CONFIG_USE_GUEST_BASE
     if (RESERVED_VA) {
         return mmap_find_vma_reserved(start, size);
     }
+#endif
 
     addr = start;
     wrapped = repeat = 0;
--

1.7.1

#2 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell

If CONFIG_USE_GUEST_BASE is not defined, gcc complains:
linux-user/mmap.c:235: error: comparison of unsigned expression >= 0 is always true

because RESERVED_VA is #defined to 0. Since mmap_find_vma_reserved() will never be called anyway if RESERVED_VA is always 0, fix this by simply #ifdef'ing away the function and its callsite.

Quoted 7 lines

---
I'm not a great fan of introducing #ifdefs, but I couldn't come up with a cleaner way of shutting gcc up...

 linux-user/mmap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Thanks, applied.

Quoted 37 lines
linux-user/mmap.c +4 -0
index abf21f6..0cf22f8 100644
@@ -216,6 +216,7 @@ static abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
 
 unsigned long last_brk;
 
+#ifdef CONFIG_USE_GUEST_BASE
 /* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk
    of guest address space.  */
 static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
@@ -249,6 +250,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
     mmap_next_start = addr;
     return last_addr;
 }
+#endif
 
 /*
  * Find and reserve a free memory area of size 'size'. The search
@@ -271,9 +273,11 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
 
     size = HOST_PAGE_ALIGN(size);
 
+#ifdef CONFIG_USE_GUEST_BASE
     if (RESERVED_VA) {
         return mmap_find_vma_reserved(start, size);
     }
+#endif
 
     addr = start;
     wrapped = repeat = 0;
Signature · 1 line
1.7.1
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net