[PATCH:libxtrans 4/4] Rename index & stat variables to stop gcc -Wshadow warnings

Mark Kettenis mark.kettenis at xs4all.nl
Tue Dec 6 02:21:39 PST 2011


> From: Alan Coopersmith <alan.coopersmith at oracle.com>
> Date: Mon,  5 Dec 2011 20:36:32 -0800
> 
> It doesn't like local variables with the same name as system library
> functions.

Which IMHO is totally ridiculous and makes -Wshadow useless, since it
means that any namespace pollution from system headers will result in
warnings.  The GCC developers acknowledged that and future GCC
versions will not warn if the shadowed identifier is from a system
header.

I vote for not "fixing" this type of shadowing.

> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  Xtranslcl.c |   36 ++++++++++++++++++------------------
>  1 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/Xtranslcl.c b/Xtranslcl.c
> index 2d0bdd5..ab5aa5a 100644
> --- a/Xtranslcl.c
> +++ b/Xtranslcl.c
> @@ -1931,13 +1931,13 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por
>  #ifdef TRANS_REOPEN
>  
>  static XtransConnInfo
> -TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
> +TRANS(LocalReopenServer)(int type, int tindex, int fd, char *port)
>  
>  {
>      XtransConnInfo ciptr;
> -    int stat = 0;
> +    int status = 0;
>  
> -    prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd);
> +    prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, tindex, fd);
>  
>      if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
>      {
> @@ -1951,19 +1951,19 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
>      switch( type )
>      {
>      case XTRANS_OPEN_COTS_SERVER:
> -	stat = LOCALtrans2devtab[index].devcotsreopenserver(ciptr,fd,port);
> +	status = LOCALtrans2devtab[tindex].devcotsreopenserver(ciptr,fd,port);
>  	break;
>      case XTRANS_OPEN_CLTS_SERVER:
> -	stat = LOCALtrans2devtab[index].devcltsreopenserver(ciptr,fd,port);
> +	status = LOCALtrans2devtab[tindex].devcltsreopenserver(ciptr,fd,port);
>  	break;
>      default:
>  	prmsg(1,"LocalReopenServer: Unknown Open type %d\n",
>  	  type );
>      }
>  
> -    if( stat > 0 ) {
> -	ciptr->priv=(char *)&LOCALtrans2devtab[index];
> -	ciptr->index=index;
> +    if( status > 0 ) {
> +	ciptr->priv=(char *)&LOCALtrans2devtab[tindex];
> +	ciptr->index=tindex;
>  	ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
>  	return ciptr;
>      }
> @@ -2075,48 +2075,48 @@ static XtransConnInfo
>  TRANS(LocalReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
>  
>  {
> -    int index;
> +    int tindex;
>  
>      prmsg(2,"LocalReopenCOTSServer(%d,%s)\n", fd, port);
>  
> -    for(index=1;index<NUMTRANSPORTS;index++)
> +    for(tindex=1;tindex<NUMTRANSPORTS;tindex++)
>      {
>  	if( strcmp(thistrans->TransName,
> -	    LOCALtrans2devtab[index].transname) == 0 )
> +	    LOCALtrans2devtab[tindex].transname) == 0 )
>  	    break;
>      }
>  
> -    if (index >= NUMTRANSPORTS)
> +    if (tindex >= NUMTRANSPORTS)
>      {
>  	return (NULL);
>      }
>  
>      return TRANS(LocalReopenServer)(XTRANS_OPEN_COTS_SERVER,
> -	index, fd, port);
> +	tindex, fd, port);
>  }
>  
>  static XtransConnInfo
>  TRANS(LocalReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
>  
>  {
> -    int index;
> +    int tindex;
>  
>      prmsg(2,"LocalReopenCLTSServer(%d,%s)\n", fd, port);
>  
> -    for(index=1;index<NUMTRANSPORTS;index++)
> +    for(tindex=1;tindex<NUMTRANSPORTS;tindex++)
>      {
>  	if( strcmp(thistrans->TransName,
> -	    LOCALtrans2devtab[index].transname) == 0 )
> +	    LOCALtrans2devtab[tindex].transname) == 0 )
>  	    break;
>      }
>  
> -    if (index >= NUMTRANSPORTS)
> +    if (tindex >= NUMTRANSPORTS)
>      {
>  	return (NULL);
>      }
>  
>      return TRANS(LocalReopenServer)(XTRANS_OPEN_CLTS_SERVER,
> -	index, fd, port);
> +	tindex, fd, port);
>  }
>  
>  #endif /* TRANS_REOPEN */
> -- 
> 1.7.3.2
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list