[PATCH V2] libX11: do not shadow variables

Peter Hutterer peter.hutterer at who-t.net
Sun Jun 15 23:21:29 PDT 2014


On Mon, Jun 09, 2014 at 03:43:49PM +0200, walter harms wrote:
> 
> I noted by chance that i made a mistake when generating my
> former version of "do not shadow variables". this time it should be complet.
> 
> unshadow a few variables that fixes:
> imCallbk.c:627:15: warning: symbol 'len' shadows an earlier one
> imCallbk.c:627:8: warning: declaration of 'len' shadows a parameter [-Wshadow]
> imCallbk.c:597:9: warning: shadowed declaration is here [-Wshadow]
> imLcLkup.c:64:18: warning: symbol 'mb' shadows an earlier one
> imLcLkup.c:64:11: warning: declaration of 'mb' shadows a previous local [-Wshadow]
> imLcLkup.c:53:11: warning: shadowed declaration is here [-Wshadow]
> lcCT.c:1024:21: warning: symbol 'char_size' shadows an earlier one
> lcCT.c:1024:21: warning: declaration of 'char_size' shadows a previous local [-Wshadow]
> lcCT.c:884:9: warning: shadowed declaration is here [-Wshadow]
> StrKeysym.c:118:14: warning: symbol 'c' shadows an earlier one
> StrKeysym.c:118:7: warning: declaration of 'c' shadows a previous local [-Wshadow]
> StrKeysym.c:80:18: warning: shadowed declaration is here [-Wshadow]
> 
> Signed-off-by: Harms <wharms at bfs,de>
> ---
>  modules/im/ximcp/imCallbk.c | 6 +++---
>  modules/im/ximcp/imLcLkup.c | 6 +++---
>  src/StrKeysym.c             | 1 -
>  src/xcms/LRGB.c             | 8 ++++----
>  src/xlibi18n/lcCT.c         | 5 +++--
>  5 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/modules/im/ximcp/imCallbk.c b/modules/im/ximcp/imCallbk.c
> index 4e091d8..51430cb 100644
> --- a/modules/im/ximcp/imCallbk.c
> +++ b/modules/im/ximcp/imCallbk.c
> @@ -624,16 +624,16 @@ _XimPreeditCaretCallback(Xim im,
>       */
>      {
>  	CARD8 buf[sz_ximPacketHeader + sz_ximPreeditCaretReply];
> -	INT16 len = sz_XIMID + sz_XICID + sz_ximPreeditCaretReply;
> +	INT16 len16 = sz_XIMID + sz_XICID + sz_ximPreeditCaretReply;
>  	int p;
> 
> -	_XimSetHeader((XPointer)buf, XIM_PREEDIT_CARET_REPLY, 0, &len);
> +	_XimSetHeader((XPointer)buf, XIM_PREEDIT_CARET_REPLY, 0, &len16);
>  	p = XIM_HEADER_SIZE;
>  	*(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
>  	*(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
>  	*(CARD32*)&buf[p] = (CARD32)cbs.position;
> 
> -	if (!(_XimWriteData(im, len, buf))) {
> +	if (!(_XimWriteData(im, len16, buf))) {
>  	    return XimCbError;
>  	}
>  	_XimFlushData(im);
> diff --git a/modules/im/ximcp/imLcLkup.c b/modules/im/ximcp/imLcLkup.c
> index 9e4aec3..56dba96 100644
> --- a/modules/im/ximcp/imLcLkup.c
> +++ b/modules/im/ximcp/imLcLkup.c
> @@ -61,8 +61,8 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
>  	    ||(ic->private.local.brl_committed != 0))) {
>  	if (ic->private.local.brl_committed != 0) { /* Braille Event */
>  	    unsigned char pattern = ic->private.local.brl_committed;
> -	    char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)];
> -	    ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern);
> +	    char mb2[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)];
> +	    ret = _Xlcwctomb(ic->core.im->core.lcd, mb2, BRL_UC_ROW | pattern);
>  	    if(ret > bytes) {
>  		if(status) *status = XBufferOverflow;
>  		return(ret);
> @@ -74,7 +74,7 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
>  		} else {
>  		    if(status) *status = XLookupChars;
>  		}
> -		memcpy(buffer, mb, ret);
> +		memcpy(buffer, mb2, ret);
>  	    } else {
>  		if(keysym) {
>  		    if(status) *status = XLookupKeySym;
> diff --git a/src/StrKeysym.c b/src/StrKeysym.c
> index 12fce68..99cf7e4 100644
> --- a/src/StrKeysym.c
> +++ b/src/StrKeysym.c
> @@ -115,7 +115,6 @@ XStringToKeysym(_Xconst char *s)
>      {
>  	XrmValue result;
>  	XrmRepresentation from_type;
> -	char c;
>  	XrmQuark names[2];
> 
>  	names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False);
> diff --git a/src/xcms/LRGB.c b/src/xcms/LRGB.c
> index 461d07d..33c8c70 100644
> --- a/src/xcms/LRGB.c
> +++ b/src/xcms/LRGB.c
> @@ -227,7 +227,7 @@ XcmsFunctionSet	XcmsLinearRGBFunctionSet =
>   * MODEL		Tek4300, Tek4800
>   */
> 
> -static IntensityRec const Default_RGB_RedTuples[] = {
> +static IntensityRec Default_RGB_RedTuples[] = {

I don't think this is supposed to be in the same patch

>      /* {unsigned short value, XcmsFloat intensity} */
>              { 0x0000,    0.000000 },
>              { 0x0909,    0.000000 },
> @@ -283,7 +283,7 @@ static IntensityRec const Default_RGB_RedTuples[] = {
>              { 0xffff,    1.000000 }
>  };
> 
> -static IntensityRec const Default_RGB_GreenTuples[] = {
> +static IntensityRec Default_RGB_GreenTuples[] = {

same here
>      /* {unsigned short value, XcmsFloat intensity} */
>              { 0x0000,    0.000000 },
>              { 0x1313,    0.000000 },
> @@ -337,7 +337,7 @@ static IntensityRec const Default_RGB_GreenTuples[] = {
>              { 0xffff,    1.000000 }
>  };
> 
> -static IntensityRec const Default_RGB_BlueTuples[] = {
> +static IntensityRec Default_RGB_BlueTuples[] = {

smame here

>      /* {unsigned short value, XcmsFloat intensity} */
>              { 0x0000,    0.000000 },
>              { 0x0e0e,    0.000000 },
> @@ -394,7 +394,7 @@ static IntensityRec const Default_RGB_BlueTuples[] = {
> 
>  static IntensityTbl Default_RGB_RedTbl = {
>      /* IntensityRec *pBase */
> -	(IntensityRec *) Default_RGB_RedTuples,
> +	(IntensityRec *)Default_RGB_RedTuples,

same here

>      /* unsigned int nEntries */
>  	52
>  };
> diff --git a/src/xlibi18n/lcCT.c b/src/xlibi18n/lcCT.c
> index b161300..e9db4f2 100644
> --- a/src/xlibi18n/lcCT.c
> +++ b/src/xlibi18n/lcCT.c
> @@ -1021,13 +1021,14 @@ cstoct(
>             ) {
>              while (csstr_len > 0 && ct_len > 0) {
>                  unsigned char ch = * (const unsigned char *) csptr;
> -                int char_size = (ch < 0xc0 ? 1 :
> +                int i;
> +                     char_size = (ch < 0xc0 ? 1 :
>                                   ch < 0xe0 ? 2 :
>                                   ch < 0xf0 ? 3 :
>                                   ch < 0xf8 ? 4 :
>                                   ch < 0xfc ? 5 :
>                                               6);

indentation is a bit mixed up here

Cheers,
   Peter

> -                int i;
> +
>                  if (!(csstr_len >= char_size && ct_len >= char_size))
>                      break;
>                  for (i = char_size; i > 0; i--)
> -- 
> 1.8.4.5


More information about the xorg-devel mailing list