[comp.windows.x] warning in compiling sunKbd.c in SunOS 4.1 make world

pjs@aristotle.JPL.NASA.gov (Peter Scott) (10/08/90)

I just did a make world of the X11R4.18 tree under SunOS 4.1,
and checked for errors and warnings.  The only ones were:

"sunKbd.c", line 170: warning: constant 770 is out of range of unsigned
 char comparison
"sunKbd.c", line 170: warning: result of comparison is always true

The line in mit/server/ddx/sun/sunKbd.c is:

               if (key.kio_entry != HOLE)

and it comes from the include file /usr/include/sundev/kbd.h,
which is included by sun.h in mit/server/ddx/sun.

On a SunOS 4.0.3 system, this is defined as:

/usr/include/sundev/kbd.h:#define       HOLE            0xA2    /* This key
 does not exist on the keyboard.

On the SunOS 4.1 system, it is defined as:

/usr/include/sundev/kbd.h:#define       HOLE            0x302   /* This key
 does not exist on the keyboard.

I still have a lot more work to do to get the installation complete, but
this (obviously) bothers me.  I have no clue what to do about it.  Any
information on the topic would be helpful.

-- 
This is news.  This is your       |    Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?    |    (pjs@aristotle.jpl.nasa.gov)

stolcke@ICSI.Berkeley.EDU (Andreas Stolcke) (10/09/90)

In article <1990Oct7.183002.11878@elroy.jpl.nasa.gov>, pjs@aristotle.JPL.NASA.gov (Peter Scott) writes:
|> I just did a make world of the X11R4.18 tree under SunOS 4.1,
|> and checked for errors and warnings.  The only ones were:
|> 
|> "sunKbd.c", line 170: warning: constant 770 is out of range of unsigned
|>  char comparison
|> "sunKbd.c", line 170: warning: result of comparison is always true

These warnings are the result of a hack in sunKbd.c used to detect Type-4
keyboards under SunOS4.0.3.  4.1 no longer requires this and the corresponding
piece of code can be taken out.  This can be done in a backward-compatible
way by replacing the

#define TYPE4KEYBOARDOVERRIDE

line with

#ifndef KIOCGKEY
#define TYPE4KEYBOARDOVERRIDE
#endif


-- 
Andreas Stolcke
International Computer Science Institute	stolcke@icsi.Berkeley.EDU
1957 Center St., Suite 600, Berkeley, CA 94704	(415) 642-4274 ext. 126

guy@auspex.auspex.com (Guy Harris) (10/09/90)

>I still have a lot more work to do to get the installation complete, but
>this (obviously) bothers me.  I have no clue what to do about it.  Any
>information on the topic would be helpful.

The problem is that in SunOS 4.1, the keyboard driver was changed so
that translation table entries are 16 bits long, rather than 8 bits, so
that translation table entries can contain ISO Latin #1 characters plus
a whole bunch of special functions, rather than just ASCII characters
plus special functions, and the codes for the special functions were
changed.

New "ioctl"s were added to read 16-bit translation table entries; the
old "ioctl"s are still there, and attempt to map a new-style translation
table entry to an old-style one.

So one solution would be to replace HOLE in the line

                if (key.kio_entry != HOLE)

with 0xA2; since it's fetching the entry with the old-style "ioctl", it
should compare it with the old-style value for HOLE.  This should work,
although I've not tried compiling it; I *have* run a server built under
4.0.3 on a 4.1 machine, but that code doesn't come into play anyway,
because under 4.1 the KIOCGTYPE "ioctl" doesn't lie about Type 4s, it
says they're Type 4s.

Another solution is simply to un-define TYPE4KEYBOARDOVERRIDE when
building under 4.1, since, as I said, the 4.1 driver says Type 4s are
Type 4s and you don't have to kludge around to find out whether
something it says is a Type 3 is really a Type 4.  (We don't count Type
4s with the DIP switches set to tell it to say to the OS that it's a
Type 3; there's not much we can do about them.)

I'd be inclined to go with the second solution, as there's no guarantee
that, if you build your server under 4.1, it'll run on a 4.0[.x] machine
*anyway*.  Try something such as

  /*
   * The Sun 386i has system include files that preclude this pre SunOS 4.1
   * test for the presence of a type 4 keyboard however it really doesn't
   * matter since no 386i has ever been shipped with a type 3 keyboard.
   */
  #if !defined(i386) && OSMajorVersion == 4 && OSMinorVersion == 0
  #define TYPE4KEYBOARDOVERRIDE
  #endif
    
so that TYPE4KEYBOARDOVERRIDE is only enabled under 4.0[.x] on non-386i
machines, not on pre-4.0 machines, 386i's, or 4.1 machines.

guy@auspex.auspex.com (Guy Harris) (10/10/90)

>#ifndef KIOCGKEY
>#define TYPE4KEYBOARDOVERRIDE
>#endif

This is probably better than my fix; KIOCGKEY is the new keyboard
"ioctl" added to get the 16-bit translation table entries, and the above
fix is less dependent on getting the OS version #defines right.