[PATCH 08/15] xkb: Don't check for NULL when pointer can't be NULL

Peter Hutterer peter.hutterer at who-t.net
Tue Jul 27 16:05:36 PDT 2010


On Tue, Jul 27, 2010 at 03:09:49PM +0300, Pauli Nieminen wrote:
> Caller quarantines that changes pointer is valid.
           ^^ "guarantees"?
 
this is a bad description IMO. for better or worse,
XkbUpdateKeyTypesFromCore is _X_EXPORT and could thus be called from a
module, not just from the single place in the tree. if changes was NULL
however, the server would segfault a few lines below anyway since we
unconditionally dereference changes. This should be in the commit message.

Cheers,
  Peter

> Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
> ---
>  xkb/xkbUtils.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
> index 14dc784..31aff93 100644
> --- a/xkb/xkbUtils.c
> +++ b/xkb/xkbUtils.c
> @@ -223,7 +223,6 @@ XkbDescPtr		xkb;
>  unsigned		key,nG,explicit;
>  int			types[XkbNumKbdGroups];
>  KeySym			tsyms[XkbMaxSymsPerKey],*syms;
> -XkbMapChangesPtr	mc;
>  
>      xkb= pXDev->key->xkbInfo->desc;
>      if (first+num-1>xkb->max_key_code) {
> @@ -231,8 +230,6 @@ XkbMapChangesPtr	mc;
>  	num= xkb->max_key_code-first+1;
>      }
>  
> -    mc= (changes?(&changes->map):NULL);
> -
>      syms= &pCore->map[(first - pCore->minKeyCode) * pCore->mapWidth];
>      for (key=first; key<(first+num); key++,syms+= pCore->mapWidth) {
>          explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
> @@ -242,7 +239,7 @@ XkbMapChangesPtr	mc;
>          types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
>          nG= XkbKeyTypesForCoreSymbols(xkb,pCore->mapWidth,syms,explicit,types,
>  									tsyms);
> -	XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
> +	XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,&changes->map);
>  	memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
>  					XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
>      }
> -- 
> 1.6.3.3




More information about the xorg-devel mailing list