[PATCH:libX11 17/22] i18n modules: Fix some const cast warnings

walter harms wharms at bfs.de
Mon Aug 12 04:58:54 PDT 2013



Am 12.08.2013 09:04, schrieb Alan Coopersmith:
> imRm.c: In function '_XimSetICMode':
> imRm.c:2419:37: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
> imRm.c:2420:30: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
> 
> lcGenConv.c: In function 'byteM_parse_codeset':
> lcGenConv.c:345:13: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  modules/im/ximcp/imRm.c    |    4 ++--
>  modules/lc/gen/lcGenConv.c |    2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c
> index 4c46252..4e6eae6 100644
> --- a/modules/im/ximcp/imRm.c
> +++ b/modules/im/ximcp/imRm.c
> @@ -2416,8 +2416,8 @@ _XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
>  						list_num, ic_mode_quark[i]))) {
>  	    continue;
>  	}
> -	res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
> -		    | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
> +	res->mode = ( (*(const unsigned short *)((const char *)&ic_mode[i] + pre_offset))
> +		    | (*(const unsigned short *)((const char *)&ic_mode[i] + sts_offset)));
>      }

maybe you could improve readability with a tmp-var

>      return;
>  }
> diff --git a/modules/lc/gen/lcGenConv.c b/modules/lc/gen/lcGenConv.c
> index 1041dc7..96904af 100644
> --- a/modules/lc/gen/lcGenConv.c
> +++ b/modules/lc/gen/lcGenConv.c
> @@ -342,7 +342,7 @@ byteM_parse_codeset(
>  	    continue;
>  
>          for (j = 0; j < codeset->length; j++) {
> -	    ch = *((unsigned char *)(inbufptr + j));
> +	    ch = *((const unsigned char *)(inbufptr + j));

again readability, does
ch=(const unsigned char *)inbufpre[j];
work ?

note: i have noted is not you fault :)

just my 2 cents,
 wh

>  	    byteM_rec = byteM[j];
>  	    byteinfo = byteM_rec.byteinfo;
>  





More information about the xorg-devel mailing list