Revision 80210bcd linux-user/mmap.c

b/linux-user/mmap.c
37 37

  
38 38
#ifdef DEBUG_MMAP
39 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 41
           prot & PROT_READ ? 'r' : '-',
42 42
           prot & PROT_WRITE ? 'w' : '-',
43 43
           prot & PROT_EXEC ? 'x' : '-');
......
100 100
                     abi_ulong start, abi_ulong end,
101 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 104
    void *host_start;
105 105
    int prot1, prot_new;
106 106

  
......
116 116

  
117 117
    if (prot1 == 0) {
118 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 123
        prot1 = prot;
124 124
    }
125 125
    prot1 &= PAGE_BITS;
......
168 168
#ifdef DEBUG_MMAP
169 169
    {
170 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 172
               start, len,
173 173
               prot & PROT_READ ? 'r' : '-',
174 174
               prot & PROT_WRITE ? 'w' : '-',
......
230 230
             */
231 231
            abi_ulong host_end;
232 232
            unsigned long host_aligned_start;
233
            void *p;
233 234

  
234 235
            host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
235 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 240
                return -1;
242 241

  
242
            host_start = (unsigned long)p;
243 243
            host_end = host_start + host_len;
244 244

  
245 245
            /* Find start and end, aligned to the targets pagesize with-in the
......
260 260
            goto the_end1;
261 261
        } else {
262 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 264
                                    host_len, prot, flags, fd, host_offset);
265
            if (host_start == -1)
265
            if (p == MAP_FAILED)
266 266
                return -1;
267 267
            /* update start so that it points to the file position at 'offset' */
268
            host_start = (unsigned long)p;
268 269
            if (!(flags & MAP_ANONYMOUS))
269 270
                host_start += offset - host_offset;
270 271
            start = h2g(host_start);
......
333 334

  
334 335
    /* map the middle (easier) */
335 336
    if (real_start < real_end) {
337
        void *p;
336 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 346
            return -1;
345 347
    }
346 348
 the_end1:

Also available in: Unified diff