Subject: Re: hpckbd vs. -Wcast-qual
To: None <tech-kern@NetBSD.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-kern
Date: 07/12/2006 06:12:59
On Wed, Jul 12, 2006 at 01:27:57 +0200, Peter Postma wrote:

> On Mon, Jun 26, 2006 at 11:53:59PM +0400, Valeriy E. Ushakov wrote:
> 
> > I think that pckbd_keydesctab[] was constified incorrectly.  Preceding
> > commetns says:
> > 
> > /* KBD_NULLMAP generates a entry for machine native variant.
> >    the entry will be modified by machine dependent keyboard driver. */
> >    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > 
> > So the right fix is to unconst the array.
> 
> Ok, I did this and added an extra comment, see attachment.
> Would this be ok to commit?
> 
> -- 
> Peter Postma

> Index: hpc/hpckbd.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/hpc/hpckbd.c,v
> retrieving revision 1.17
> diff -u -r1.17 hpckbd.c
> --- hpc/hpckbd.c	29 Mar 2006 06:37:35 -0000	1.17
> +++ hpc/hpckbd.c	11 Jul 2006 23:23:14 -0000
> @@ -267,15 +267,7 @@
>  	int i;
>  	struct wscons_keydesc *desc;
>  
> -	/* fix keydesc table */
> -	/* 
> -	 * XXX The way this is done is really wrong.  The __UNCONST()
> -	 * is a hint as to what is wrong.  This actually ends up modifying
> -	 * initialized data which is marked "const".
> -	 * The reason we get away with it here is apparently that text
> -	 * and read-only data gets mapped read/write on the platforms
> -	 * using this code.
> -	 */
> +	/* fix keydesc table, the UNCONST is "OK". */
>  	desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
>  	for (i = 0; desc[i].name != 0; i++) {
>  		if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {

If you drop const from teh array, you don't need __UNCONST (and the
comment) here.

Otherwise looks ok.

SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen