bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gnumach cleanup 11


From: Samuel Thibault
Subject: Re: Gnumach cleanup 11
Date: Tue, 22 Jul 2008 23:49:25 +0100
User-agent: Mutt/1.5.12-2006-07-14

Barry deFreese, le Tue 22 Jul 2008 13:33:07 -0400, a écrit :
> I'm a little curious if using (void *)port cast is correct in the calls 
> to tty_portdeath()?

Rather cast into the target type instaed, ipc_port_t.

> I also could use some guidance on these warnings (they all come from 
> basically the same call):
> 
> ../kern/startup.c:297: warning: passing argument 1 of 'kvtophys' makes 
> integer from pointer without a cast

See inside the PMAP_ACTIVATE_USER macro.

> --- i386/i386at/kd.c  20 Jul 2008 17:05:38 -0000      1.5.2.15
> +++ i386/i386at/kd.c  22 Jul 2008 17:12:40 -0000
> @@ -590,7 +590,7 @@ kdportdeath(dev, port)
>       dev_t   dev;
>       mach_port_t     port;
>  {
> -     return (tty_portdeath(&kd_tty, port));
> +     return (tty_portdeath(&kd_tty, (void *)port));
>  }

ditto, same for others.

> --- i386/i386at/kd_mouse.c    20 Jul 2008 17:05:38 -0000      1.3.2.9
> +++ i386/i386at/kd_mouse.c    22 Jul 2008 17:12:40 -0000
> @@ -603,7 +603,7 @@ mouse_handle_byte(ch)
>               mousebuf[mousebufindex++] = ch;
>           if (mouse_char_wanted) {
>               mouse_char_wanted = FALSE;
> -             wakeup(&mousebuf);
> +             wakeup((unsigned int)&mousebuf);
>           }
>           return;
>       }

Same principle here, cast into the target type expected by the function,
vm_offset_t.

> --- i386/intel/pmap.c 18 Nov 2007 17:33:07 -0000      1.4.2.19
> +++ i386/intel/pmap.c 22 Jul 2008 17:12:41 -0000
> @@ -927,7 +927,7 @@ void pmap_destroy(p)
>               vm_object_unlock(pmap_object);
>           }
>       }
> -     kmem_free(kernel_map, p->dirbase, INTEL_PGBYTES);
> +     kmem_free(kernel_map, (vm_offset_t)p->dirbase, INTEL_PGBYTES);
>       zfree(pmap_zone, (vm_offset_t) p);
>  }
>  

That one is correct, for instance.

> --- ipc/ipc_kmsg.c    16 Jul 2008 00:51:03 -0000      1.2.2.11
> +++ ipc/ipc_kmsg.c    22 Jul 2008 17:12:41 -0000
> @@ -531,7 +531,7 @@ ipc_kmsg_get(msg, size, kmsgp)
>               ikm_init(kmsg, size);
>       }
>  
> -     if (copyinmsg((char *) msg, (char *) &kmsg->ikm_header, size)) {
> +     if (copyinmsg((vm_offset_t) msg, (vm_offset_t) &kmsg->ikm_header, 
> size)) {
>               ikm_free(kmsg);
>               return MACH_SEND_INVALID_DATA;
>       }

Mmm, it'd probably be better to fix the prototype into taking void *
(just like copyin/out), so that you won't need a cast at all., same thing
for copyoutmsg and in ipc/mach_msg.c

> --- kern/bootstrap.c  17 Jul 2008 01:02:01 -0000      1.12.2.11
> +++ kern/bootstrap.c  22 Jul 2008 17:12:42 -0000
> @@ -435,7 +435,7 @@ read_exec(void *handle, vm_offset_t file
>       if (file_size > 0)
>       {
>               err = copyout((char *)phystokv (mod->mod_start) + file_ofs,
> -                           mem_addr, file_size);
> +                           (char *)mem_addr, file_size);
>               assert(err == 0);
>       }
>  

Better cast into void * instead.  Casting into char* is actually old C
style.

Samuel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]