Subject: Re: hpckbd vs. -Wcast-qual
To: None <tech-kern@NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: tech-kern
Date: 07/12/2006 10:59:45
On Wed, Jul 12, 2006 at 06:12:59AM +0400, Valeriy E. Ushakov wrote:
> On Wed, Jul 12, 2006 at 01:27:57 +0200, Peter Postma wrote:
>
> > 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.
>
But the "keydesc" member in struct wskbd_mapdata is marked as const,
so the compiler will warn if this __UNCONST is removed. I'm not sure
if it's a good idea to remove that const from the member.
--
Peter Postma