Skip to contentSkip to conversation

exec.c:283: warning: cast from pointer to integer of different size

Qemu-devel Jan Kiszka 2 participants 2 messages Jun 23, 2008

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi Paul,

trying to get rid of some of the various compiler warnings, specifically on 64-bit hosts, I came across this:

Quoted 13 lines
#if defined(CONFIG_USER_ONLY)
        unsigned long addr;
        size_t len = sizeof(PageDesc) * L2_SIZE;
        /* Don't use qemu_malloc because it may recurse.  */
        p = mmap(0, len, PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        *lp = p;
        addr = h2g(p);
        if (addr == (target_ulong)addr) {
            page_set_flags(addr & TARGET_PAGE_MASK,
                           TARGET_PAGE_ALIGN(addr + len),
                           PAGE_RESERVED); 
        }
Quoted 1 line

#else

Something is fishy here. h2g already returns target_ulong (and generates compiler warnings at this chance), but the succeeding line seems to assume that addr can still be larger than that. Now I wonder what this code is actually supposed to do.

Jan

#1 lore raw
Quoted 20 lines · Jan Kiszka

Hi Paul,

trying to get rid of some of the various compiler warnings, specifically on 64-bit hosts, I came across this:

Quoted 13 lines
#if defined(CONFIG_USER_ONLY)
        unsigned long addr;
        size_t len = sizeof(PageDesc) * L2_SIZE;
        /* Don't use qemu_malloc because it may recurse.  */
        p = mmap(0, len, PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        *lp = p;
        addr = h2g(p);
        if (addr == (target_ulong)addr) {
            page_set_flags(addr & TARGET_PAGE_MASK,
                           TARGET_PAGE_ALIGN(addr + len),
                           PAGE_RESERVED);
        }
Quoted 1 line

#else

Quoted 4 lines

Something is fishy here. h2g already returns target_ulong (and generates compiler warnings at this chance), but the succeeding line seems to assume that addr can still be larger than that. Now I wonder what this code is actually supposed to do.

I already reported this two weeks ago and got no feedback.

http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00324.html

Laurent