Commit 80210bcd719c615d3ae9cd851e9e961bac722538

Authored by ths
1 parent 3d97b40b

Fix compiler warnings, by Stefan Weil.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3507 c046a42c-6fe2-441c-8c8c-71466251a162
linux-user/mmap.c
@@ -37,7 +37,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) @@ -37,7 +37,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)
37 37
38 #ifdef DEBUG_MMAP 38 #ifdef DEBUG_MMAP
39 printf("mprotect: start=0x" TARGET_FMT_lx 39 printf("mprotect: start=0x" TARGET_FMT_lx
40 - "len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len, 40 + "len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
41 prot & PROT_READ ? 'r' : '-', 41 prot & PROT_READ ? 'r' : '-',
42 prot & PROT_WRITE ? 'w' : '-', 42 prot & PROT_WRITE ? 'w' : '-',
43 prot & PROT_EXEC ? 'x' : '-'); 43 prot & PROT_EXEC ? 'x' : '-');
@@ -100,7 +100,7 @@ static int mmap_frag(abi_ulong real_start, @@ -100,7 +100,7 @@ static int mmap_frag(abi_ulong real_start,
100 abi_ulong start, abi_ulong end, 100 abi_ulong start, abi_ulong end,
101 int prot, int flags, int fd, abi_ulong offset) 101 int prot, int flags, int fd, abi_ulong offset)
102 { 102 {
103 - abi_ulong real_end, ret, addr; 103 + abi_ulong real_end, addr;
104 void *host_start; 104 void *host_start;
105 int prot1, prot_new; 105 int prot1, prot_new;
106 106
@@ -116,10 +116,10 @@ static int mmap_frag(abi_ulong real_start, @@ -116,10 +116,10 @@ static int mmap_frag(abi_ulong real_start,
116 116
117 if (prot1 == 0) { 117 if (prot1 == 0) {
118 /* no page was there, so we allocate one */ 118 /* no page was there, so we allocate one */
119 - ret = (long)mmap(host_start, qemu_host_page_size, prot,  
120 - flags | MAP_ANONYMOUS, -1, 0);  
121 - if (ret == -1)  
122 - return ret; 119 + void *p = mmap(host_start, qemu_host_page_size, prot,
  120 + flags | MAP_ANONYMOUS, -1, 0);
  121 + if (p == MAP_FAILED)
  122 + return -1;
123 prot1 = prot; 123 prot1 = prot;
124 } 124 }
125 prot1 &= PAGE_BITS; 125 prot1 &= PAGE_BITS;
@@ -168,7 +168,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, @@ -168,7 +168,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
168 #ifdef DEBUG_MMAP 168 #ifdef DEBUG_MMAP
169 { 169 {
170 printf("mmap: start=0x" TARGET_FMT_lx 170 printf("mmap: start=0x" TARGET_FMT_lx
171 - " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=", 171 + " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
172 start, len, 172 start, len,
173 prot & PROT_READ ? 'r' : '-', 173 prot & PROT_READ ? 'r' : '-',
174 prot & PROT_WRITE ? 'w' : '-', 174 prot & PROT_WRITE ? 'w' : '-',
@@ -230,16 +230,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, @@ -230,16 +230,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
230 */ 230 */
231 abi_ulong host_end; 231 abi_ulong host_end;
232 unsigned long host_aligned_start; 232 unsigned long host_aligned_start;
  233 + void *p;
233 234
234 host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size 235 host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
235 - qemu_real_host_page_size); 236 - qemu_real_host_page_size);
236 - host_start = (unsigned long) mmap(real_start ?  
237 - g2h(real_start) : NULL,  
238 - host_len, prot, flags,  
239 - fd, host_offset);  
240 - if (host_start == -1) 237 + p = mmap(real_start ? g2h(real_start) : NULL,
  238 + host_len, prot, flags, fd, host_offset);
  239 + if (p == MAP_FAILED)
241 return -1; 240 return -1;
242 241
  242 + host_start = (unsigned long)p;
243 host_end = host_start + host_len; 243 host_end = host_start + host_len;
244 244
245 /* Find start and end, aligned to the targets pagesize with-in the 245 /* Find start and end, aligned to the targets pagesize with-in the
@@ -260,11 +260,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, @@ -260,11 +260,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
260 goto the_end1; 260 goto the_end1;
261 } else { 261 } else {
262 /* if not fixed, no need to do anything */ 262 /* if not fixed, no need to do anything */
263 - host_start = (long)mmap(real_start ? g2h(real_start) : NULL, 263 + void *p = mmap(real_start ? g2h(real_start) : NULL,
264 host_len, prot, flags, fd, host_offset); 264 host_len, prot, flags, fd, host_offset);
265 - if (host_start == -1) 265 + if (p == MAP_FAILED)
266 return -1; 266 return -1;
267 /* update start so that it points to the file position at 'offset' */ 267 /* update start so that it points to the file position at 'offset' */
  268 + host_start = (unsigned long)p;
268 if (!(flags & MAP_ANONYMOUS)) 269 if (!(flags & MAP_ANONYMOUS))
269 host_start += offset - host_offset; 270 host_start += offset - host_offset;
270 start = h2g(host_start); 271 start = h2g(host_start);
@@ -333,14 +334,15 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, @@ -333,14 +334,15 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
333 334
334 /* map the middle (easier) */ 335 /* map the middle (easier) */
335 if (real_start < real_end) { 336 if (real_start < real_end) {
  337 + void *p;
336 unsigned long offset1; 338 unsigned long offset1;
337 - if (flags & MAP_ANONYMOUS)  
338 - offset1 = 0;  
339 - else  
340 - offset1 = offset + real_start - start;  
341 - ret = (long)mmap(g2h(real_start), real_end - real_start,  
342 - prot, flags, fd, offset1);  
343 - if (ret == -1) 339 + if (flags & MAP_ANONYMOUS)
  340 + offset1 = 0;
  341 + else
  342 + offset1 = offset + real_start - start;
  343 + p = mmap(g2h(real_start), real_end - real_start,
  344 + prot, flags, fd, offset1);
  345 + if (p == MAP_FAILED)
344 return -1; 346 return -1;
345 } 347 }
346 the_end1: 348 the_end1:
target-i386/helper2.c
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 //#define DEBUG_MMU 32 //#define DEBUG_MMU
33 33
34 #ifdef USE_CODE_COPY 34 #ifdef USE_CODE_COPY
  35 +#include <unistd.h>
35 #include <asm/ldt.h> 36 #include <asm/ldt.h>
36 #include <linux/unistd.h> 37 #include <linux/unistd.h>
37 #include <linux/version.h> 38 #include <linux/version.h>