First Uno complaint

Jerry James james at xemacs.org
Wed Aug 11 23:41:21 EDT 2004


Here's the first Uno complaint.  It thinks that the variable "len" might
be used uninitialized in x_to_emacs_keysym, event-Xt.c.  The use is on
line 1063, the definition on line 973.  I *think* this is a false
positive, but somebody help me out with this analysis.  Here's the top
part of that function, the only part where "len" is assigned a value.

------------------------------------------------------------------------
static Lisp_Object
x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p)
     /* simple_p means don't try too hard (ASCII only) */
{
  KeySym keysym = 0;

#ifdef HAVE_XIM
  int len;
  /* Some implementations of XmbLookupString don't return
     XBufferOverflow correctly, so increase the size of the xim input
     buffer from 64 to the more reasonable size 513, as Emacs has done.
     From Kenichi Handa. */
  char buffer[513];
  char *bufptr = buffer;
  int   bufsiz = sizeof (buffer);
  Status status;
#ifdef XIM_XLIB
  XIC xic = FRAME_X_XIC (x_any_window_to_frame
			 (get_device_from_display (event->display),
			  event->window));
#endif /* XIM_XLIB */
#endif /* HAVE_XIM */

  /* We use XLookupString if we're not using XIM, or are using
     XIM_XLIB but input context creation failed. */
#if ! (defined (HAVE_XIM) && defined (XIM_MOTIF))
#if defined (HAVE_XIM) && defined (XIM_XLIB)
     if (!xic)
#endif /* XIM_XLIB */
    {
      /* Apparently it's necessary to specify a dummy here (rather
         than passing in 0) to avoid crashes on German IRIX */
      char dummy[256];
      XLookupString (event, dummy, 200, &keysym, 0);
      return (IsModifierKey (keysym) || keysym == XK_Mode_switch )
	? Qnil : x_keysym_to_emacs_keysym (keysym, simple_p);
    }
#endif /* ! XIM_MOTIF */

#ifdef HAVE_XIM
 Lookup_String: /* Come-From XBufferOverflow */
#ifdef XIM_MOTIF
  len = XmImMbLookupString (XtWindowToWidget (event->display, event->window),
			    event, bufptr, bufsiz, &keysym, &status);
#else /* XIM_XLIB */
  if (xic)
    len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status);
#endif /* XIM_MOTIF */
------------------------------------------------------------------------

So len exists only if HAVE_XIM.  Looking at configure.in, it appears
that HAVE_XIM implies that either XIM_XLIB or XIM_MOTIF is defined
... or both?  That wouldn't seem to make any sense, yet I don't see that
the configure.in stuff rules it out.

If XIM_MOTIF is defined, then len is definitely initialized.  So what
about XIM_XLIB only being defined?  In that case, if xic is NULL, we
return without ever setting or referencing "len".  In the last #else
block in the code above, it looks to me like xic is guaranteed to be
non-NULL, in which case the "if (xic)" is redundant and "len" is always
initialized.

Is that right?
-- 
Jerry James
http://www.ittc.ku.edu/~james/




More information about the XEmacs-Beta mailing list