From 7d7224d8543e85e3a34a1cddf99f3eac9aa9050b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 12 Apr 2011 21:27:45 -0700 Subject: Replace Xmalloc+bzero pairs with Xcalloc calls Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 7f79765e1..448cf41e6 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -360,10 +360,9 @@ _XimDefaultStyles( n = XIMNumber(supported_local_styles) - 1; len = sizeof(XIMStyles) + sizeof(XIMStyle) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); styles = (XIMStyles *)tmp; if (n > 0) { @@ -396,10 +395,9 @@ _XimDefaultIMValues( n = XIMNumber(supported_local_im_values_list); len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); values_list = (XIMValuesList *)tmp; if (n > 0) { @@ -433,10 +431,9 @@ _XimDefaultICValues( n = XIMNumber(supported_local_ic_values_list); len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); values_list = (XIMValuesList *)tmp; if (n > 0) { @@ -1085,10 +1082,9 @@ _XimDecodeStyles( num = styles->count_styles; len = sizeof(XIMStyles) + sizeof(XIMStyle) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); out = (XIMStyles *)tmp; if(num >0) { @@ -1124,10 +1120,9 @@ _XimDecodeValues( num = values_list->count_values; len = sizeof(XIMValuesList) + sizeof(char **) * num; - if(!(tmp = (char *)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); out = (XIMValuesList *)tmp; if(num) { @@ -2143,10 +2138,9 @@ _XimSetResourceList( XIMResourceList res; len = sizeof(XIMResource) * num_resource; - if(!(res = (XIMResourceList)Xmalloc(len))) { + if(!(res = Xcalloc(1, len))) { return False; } - bzero((char *)res, len); for(i = 0; i < num_resource; i++, id++) { res[i] = resource[i]; -- cgit v1.2.3 From dde00b2f6848a38e9fdbe1e4c85373c8b12944b4 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 12 Apr 2011 22:30:45 -0700 Subject: Convert malloc(strlen()); strcpy() sets to strdup Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 448cf41e6..3c28b1e29 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -793,19 +793,15 @@ _XimEncodeString( XPointer top, XPointer val) { - int len; char *string; char **out; if(val == (XPointer)NULL) { return False; } - len = strlen((char *)val); - if(!(string = (char *)Xmalloc(len + 1))) { + if (!(string = strdup((char *)val))) { return False; } - (void)strcpy(string, (char *)val); - string[len] = '\0'; out = (char **)((char *)top + info->offset); if(*out) { @@ -1163,21 +1159,18 @@ _XimDecodeString( XPointer top, XPointer val) { - int len = 0; char *in; char *string; in = *((char **)((char *)top + info->offset)); - if(in != (char *)NULL) { - len = strlen(in); + if (in != NULL) { + string = strdup(in); + } else { + string = Xcalloc(1, 1); /* strdup("") */ } - if(!(string = (char *)Xmalloc(len + 1))) { + if (string == NULL) { return False; } - if(in != (char *)NULL) { - (void)strcpy(string, in); - } - string[len] = '\0'; *((char **)val) = string; return True; } -- cgit v1.2.3 From cded3305d3c10f1b3918ea07120fb527f85b7802 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Tue, 11 Oct 2011 17:27:59 +0200 Subject: Return name instead of False in XSetICValues() In case of error, XSetICValues() must return the first argument that failed to be set. But in some error paths, it returns False, which is converted to NULL, so the function returns OK in case of error. Signed-off-by: Yann Droneaud Reviewed-by: Jeremy Huddleston Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 3c28b1e29..6761bd351 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -2881,13 +2881,13 @@ _XimSetICValueData( if(mode & XIM_PREEDIT_ATTR) { if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p)) - return False; + return p->name; } else if(mode & XIM_STATUS_ATTR) { if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p)) - return False; + return p->name; } else { if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag)) - return False; + return p->name; } if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) { return p->name; -- cgit v1.2.3 From bec22fe978b41f36e7d9f47480f1fd24d5a23973 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Sun, 9 Oct 2011 17:56:45 +0200 Subject: Return name instead of value in XGetIMValues() and XSetIMValues() As stated in man page (XOpenIM) and Xlib documentation (chapter 13.5.3), XGetIMValues() and XSetImValues() "returns the name of the first argument that could not be obtained." But currently, err = XGetIMValues(im, "invalid", &arg, NULL); returns &arg instead of "invalid". This patch fixes https://bugs.freedesktop.org/show_bug.cgi?id=12897 Signed-off-by: Yann Droneaud Reviewed-by: Jeremy Huddleston Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 6761bd351..b66bc1421 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -2250,17 +2250,17 @@ _XimSetIMValueData( for(p = values; p->name != NULL; p++) { if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; + return p->name; } check = _XimCheckIMMode(res, XIM_SETIMVALUES); if(check == XIM_CHECK_INVALID) { continue; } else if (check == XIM_CHECK_ERROR) { - return p->value; + return p->name; } if(!_XimEncodeLocalIMAttr(res, top, p->value)) { - return p->value; + return p->name; } } return NULL; @@ -2280,17 +2280,17 @@ _XimGetIMValueData( for(p = values; p->name != NULL; p++) { if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; + return p->name; } check = _XimCheckIMMode(res, XIM_GETIMVALUES); if(check == XIM_CHECK_INVALID) { continue; } else if (check == XIM_CHECK_ERROR) { - return p->value; + return p->name; } if(!_XimDecodeLocalIMAttr(res, top, p->value)) { - return p->value; + return p->name; } } return NULL; -- cgit v1.2.3 From 44e472068b163b7be001b74fec1ed98bcdde85e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 31 Jan 2011 14:02:01 +0200 Subject: ximcp/imRm: Handle leaking colormap_ret MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed memory leak by adding Xfree for colormap_ret Variable "colormap_ret" goes out of scope Reviewed-by: Alan Coopersmith Reviewed-by: Ander Conselvan de Oliveira Signed-off-by: Erkki Seppälä Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index b66bc1421..c0c6d8eb8 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -2808,6 +2808,8 @@ _XimEncodeLocalPreeditValue( ic->core.focus_window, &colormap_ret, &count, (Atom)p->value))) return False; + + Xfree(colormap_ret); } return True; } @@ -2828,6 +2830,8 @@ _XimEncodeLocalStatusValue( ic->core.focus_window, &colormap_ret, &count, (Atom)p->value))) return False; + + Xfree(colormap_ret); } return True; } -- cgit v1.2.3 From 11d6dac92b6c3c3f62d49817809ce8c6a61c9293 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 22 Oct 2012 13:54:11 -0500 Subject: XIM: remove Private and Public macros Private is a struct member name in mingw-w64 , causing this useless define in a private header to break the build. Signed-off-by: Yaakov Selkowitz Reviewed-by: Jon TURNEY Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 220 +++++++++++++++++++++++++------------------------- 1 file changed, 110 insertions(+), 110 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index c0c6d8eb8..34c9bfa35 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -58,7 +58,7 @@ typedef struct _XimValueOffsetInfo { } XimValueOffsetInfoRec, *XimValueOffsetInfo; #ifdef XIM_CONNECTABLE -Private Bool +static Bool _XimCheckBool(str) char *str; { @@ -69,7 +69,7 @@ _XimCheckBool(str) return False; } -Public void +void _XimSetProtoResource(im) Xim im; { @@ -344,7 +344,7 @@ static XIMStyle const supported_local_styles[] = { 0 /* dummy */ }; -Private Bool +static Bool _XimDefaultStyles( XimValueOffsetInfo info, XPointer top, @@ -379,7 +379,7 @@ _XimDefaultStyles( return True; } -Private Bool +static Bool _XimDefaultIMValues( XimValueOffsetInfo info, XPointer top, @@ -415,7 +415,7 @@ _XimDefaultIMValues( return True; } -Private Bool +static Bool _XimDefaultICValues( XimValueOffsetInfo info, XPointer top, @@ -451,7 +451,7 @@ _XimDefaultICValues( return True; } -Private Bool +static Bool _XimDefaultVisiblePos( XimValueOffsetInfo info, XPointer top, @@ -465,7 +465,7 @@ _XimDefaultVisiblePos( return True; } -Private Bool +static Bool _XimDefaultFocusWindow( XimValueOffsetInfo info, XPointer top, @@ -484,7 +484,7 @@ _XimDefaultFocusWindow( return True; } -Private Bool +static Bool _XimDefaultResName( XimValueOffsetInfo info, XPointer top, @@ -504,7 +504,7 @@ _XimDefaultResName( return True; } -Private Bool +static Bool _XimDefaultResClass( XimValueOffsetInfo info, XPointer top, @@ -524,7 +524,7 @@ _XimDefaultResClass( return True; } -Private Bool +static Bool _XimDefaultDestroyCB( XimValueOffsetInfo info, XPointer top, @@ -540,7 +540,7 @@ _XimDefaultDestroyCB( return True; } -Private Bool +static Bool _XimDefaultResetState( XimValueOffsetInfo info, XPointer top, @@ -554,7 +554,7 @@ _XimDefaultResetState( return True; } -Private Bool +static Bool _XimDefaultHotKeyState( XimValueOffsetInfo info, XPointer top, @@ -568,7 +568,7 @@ _XimDefaultHotKeyState( return True; } -Private Bool +static Bool _XimDefaultArea( XimValueOffsetInfo info, XPointer top, @@ -604,7 +604,7 @@ _XimDefaultArea( return True; } -Private Bool +static Bool _XimDefaultColormap( XimValueOffsetInfo info, XPointer top, @@ -629,7 +629,7 @@ _XimDefaultColormap( return True; } -Private Bool +static Bool _XimDefaultStdColormap( XimValueOffsetInfo info, XPointer top, @@ -643,7 +643,7 @@ _XimDefaultStdColormap( return True; } -Private Bool +static Bool _XimDefaultFg( XimValueOffsetInfo info, XPointer top, @@ -661,7 +661,7 @@ _XimDefaultFg( return True; } -Private Bool +static Bool _XimDefaultBg( XimValueOffsetInfo info, XPointer top, @@ -679,7 +679,7 @@ _XimDefaultBg( return True; } -Private Bool +static Bool _XimDefaultBgPixmap( XimValueOffsetInfo info, XPointer top, @@ -693,7 +693,7 @@ _XimDefaultBgPixmap( return True; } -Private Bool +static Bool _XimDefaultFontSet( XimValueOffsetInfo info, XPointer top, @@ -707,7 +707,7 @@ _XimDefaultFontSet( return True; } -Private Bool +static Bool _XimDefaultLineSpace( XimValueOffsetInfo info, XPointer top, @@ -736,7 +736,7 @@ _XimDefaultLineSpace( return True; } -Private Bool +static Bool _XimDefaultCursor( XimValueOffsetInfo info, XPointer top, @@ -750,7 +750,7 @@ _XimDefaultCursor( return True; } -Private Bool +static Bool _XimDefaultPreeditState( XimValueOffsetInfo info, XPointer top, @@ -764,7 +764,7 @@ _XimDefaultPreeditState( return True; } -Private Bool +static Bool _XimDefaultNest( XimValueOffsetInfo info, XPointer top, @@ -774,7 +774,7 @@ _XimDefaultNest( return True; } -Private Bool +static Bool _XimEncodeCallback( XimValueOffsetInfo info, XPointer top, @@ -787,7 +787,7 @@ _XimEncodeCallback( return True; } -Private Bool +static Bool _XimEncodeString( XimValueOffsetInfo info, XPointer top, @@ -811,7 +811,7 @@ _XimEncodeString( return True; } -Private Bool +static Bool _XimEncodeStyle( XimValueOffsetInfo info, XPointer top, @@ -824,7 +824,7 @@ _XimEncodeStyle( return True; } -Private Bool +static Bool _XimEncodeWindow( XimValueOffsetInfo info, XPointer top, @@ -837,7 +837,7 @@ _XimEncodeWindow( return True; } -Private Bool +static Bool _XimEncodeStringConv( XimValueOffsetInfo info, XPointer top, @@ -849,7 +849,7 @@ _XimEncodeStringConv( return True; } -Private Bool +static Bool _XimEncodeResetState( XimValueOffsetInfo info, XPointer top, @@ -862,7 +862,7 @@ _XimEncodeResetState( return True; } -Private Bool +static Bool _XimEncodeHotKey( XimValueOffsetInfo info, XPointer top, @@ -905,7 +905,7 @@ _XimEncodeHotKey( return True; } -Private Bool +static Bool _XimEncodeHotKetState( XimValueOffsetInfo info, XPointer top, @@ -918,7 +918,7 @@ _XimEncodeHotKetState( return True; } -Private Bool +static Bool _XimEncodeRectangle( XimValueOffsetInfo info, XPointer top, @@ -931,7 +931,7 @@ _XimEncodeRectangle( return True; } -Private Bool +static Bool _XimEncodeSpot( XimValueOffsetInfo info, XPointer top, @@ -944,7 +944,7 @@ _XimEncodeSpot( return True; } -Private Bool +static Bool _XimEncodeColormap( XimValueOffsetInfo info, XPointer top, @@ -957,7 +957,7 @@ _XimEncodeColormap( return True; } -Private Bool +static Bool _XimEncodeStdColormap( XimValueOffsetInfo info, XPointer top, @@ -970,7 +970,7 @@ _XimEncodeStdColormap( return True; } -Private Bool +static Bool _XimEncodeLong( XimValueOffsetInfo info, XPointer top, @@ -983,7 +983,7 @@ _XimEncodeLong( return True; } -Private Bool +static Bool _XimEncodeBgPixmap( XimValueOffsetInfo info, XPointer top, @@ -996,7 +996,7 @@ _XimEncodeBgPixmap( return True; } -Private Bool +static Bool _XimEncodeFontSet( XimValueOffsetInfo info, XPointer top, @@ -1009,7 +1009,7 @@ _XimEncodeFontSet( return True; } -Private Bool +static Bool _XimEncodeLineSpace( XimValueOffsetInfo info, XPointer top, @@ -1022,7 +1022,7 @@ _XimEncodeLineSpace( return True; } -Private Bool +static Bool _XimEncodeCursor( XimValueOffsetInfo info, XPointer top, @@ -1035,7 +1035,7 @@ _XimEncodeCursor( return True; } -Private Bool +static Bool _XimEncodePreeditState( XimValueOffsetInfo info, XPointer top, @@ -1048,7 +1048,7 @@ _XimEncodePreeditState( return True; } -Private Bool +static Bool _XimEncodeNest( XimValueOffsetInfo info, XPointer top, @@ -1057,7 +1057,7 @@ _XimEncodeNest( return True; } -Private Bool +static Bool _XimDecodeStyles( XimValueOffsetInfo info, XPointer top, @@ -1095,7 +1095,7 @@ _XimDecodeStyles( return True; } -Private Bool +static Bool _XimDecodeValues( XimValueOffsetInfo info, XPointer top, @@ -1133,7 +1133,7 @@ _XimDecodeValues( return True; } -Private Bool +static Bool _XimDecodeCallback( XimValueOffsetInfo info, XPointer top, @@ -1153,7 +1153,7 @@ _XimDecodeCallback( return True; } -Private Bool +static Bool _XimDecodeString( XimValueOffsetInfo info, XPointer top, @@ -1175,7 +1175,7 @@ _XimDecodeString( return True; } -Private Bool +static Bool _XimDecodeBool( XimValueOffsetInfo info, XPointer top, @@ -1188,7 +1188,7 @@ _XimDecodeBool( return True; } -Private Bool +static Bool _XimDecodeStyle( XimValueOffsetInfo info, XPointer top, @@ -1201,7 +1201,7 @@ _XimDecodeStyle( return True; } -Private Bool +static Bool _XimDecodeWindow( XimValueOffsetInfo info, XPointer top, @@ -1214,7 +1214,7 @@ _XimDecodeWindow( return True; } -Private Bool +static Bool _XimDecodeStringConv( XimValueOffsetInfo info, XPointer top, @@ -1226,7 +1226,7 @@ _XimDecodeStringConv( return True; } -Private Bool +static Bool _XimDecodeResetState( XimValueOffsetInfo info, XPointer top, @@ -1239,7 +1239,7 @@ _XimDecodeResetState( return True; } -Private Bool +static Bool _XimDecodeHotKey( XimValueOffsetInfo info, XPointer top, @@ -1273,7 +1273,7 @@ _XimDecodeHotKey( return True; } -Private Bool +static Bool _XimDecodeHotKetState( XimValueOffsetInfo info, XPointer top, @@ -1286,7 +1286,7 @@ _XimDecodeHotKetState( return True; } -Private Bool +static Bool _XimDecodeRectangle( XimValueOffsetInfo info, XPointer top, @@ -1304,7 +1304,7 @@ _XimDecodeRectangle( return True; } -Private Bool +static Bool _XimDecodeSpot( XimValueOffsetInfo info, XPointer top, @@ -1322,7 +1322,7 @@ _XimDecodeSpot( return True; } -Private Bool +static Bool _XimDecodeColormap( XimValueOffsetInfo info, XPointer top, @@ -1335,7 +1335,7 @@ _XimDecodeColormap( return True; } -Private Bool +static Bool _XimDecodeStdColormap( XimValueOffsetInfo info, XPointer top, @@ -1348,7 +1348,7 @@ _XimDecodeStdColormap( return True; } -Private Bool +static Bool _XimDecodeLong( XimValueOffsetInfo info, XPointer top, @@ -1361,7 +1361,7 @@ _XimDecodeLong( return True; } -Private Bool +static Bool _XimDecodeBgPixmap( XimValueOffsetInfo info, XPointer top, @@ -1374,7 +1374,7 @@ _XimDecodeBgPixmap( return True; } -Private Bool +static Bool _XimDecodeFontSet( XimValueOffsetInfo info, XPointer top, @@ -1387,7 +1387,7 @@ _XimDecodeFontSet( return True; } -Private Bool +static Bool _XimDecodeLineSpace( XimValueOffsetInfo info, XPointer top, @@ -1400,7 +1400,7 @@ _XimDecodeLineSpace( return True; } -Private Bool +static Bool _XimDecodeCursor( XimValueOffsetInfo info, XPointer top, @@ -1413,7 +1413,7 @@ _XimDecodeCursor( return True; } -Private Bool +static Bool _XimDecodePreeditState( XimValueOffsetInfo info, XPointer top, @@ -1426,7 +1426,7 @@ _XimDecodePreeditState( return True; } -Private Bool +static Bool _XimDecodeNest( XimValueOffsetInfo info, XPointer top, @@ -2118,7 +2118,7 @@ static const XimICMode ic_mode[] = { static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])]; static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])]; -Private Bool +static Bool _XimSetResourceList( XIMResourceList *res_list, unsigned int *list_num, @@ -2146,7 +2146,7 @@ _XimSetResourceList( return True; } -Public Bool +Bool _XimSetIMResourceList( XIMResourceList *res_list, unsigned int *list_num) @@ -2155,7 +2155,7 @@ _XimSetIMResourceList( im_resources, XIMNumber(im_resources), 100); } -Public Bool +Bool _XimSetICResourceList( XIMResourceList *res_list, unsigned int *list_num) @@ -2164,7 +2164,7 @@ _XimSetICResourceList( ic_resources, XIMNumber(ic_resources), 200); } -Public Bool +Bool _XimSetInnerIMResourceList( XIMResourceList *res_list, unsigned int *list_num) @@ -2173,7 +2173,7 @@ _XimSetInnerIMResourceList( im_inner_resources, XIMNumber(im_inner_resources), 100); } -Public Bool +Bool _XimSetInnerICResourceList( XIMResourceList *res_list, unsigned int *list_num) @@ -2182,7 +2182,7 @@ _XimSetInnerICResourceList( ic_inner_resources, XIMNumber(ic_inner_resources), 200); } -Private XIMResourceList +static XIMResourceList _XimGetResourceListRecByMode( XIMResourceList res_list, unsigned int list_num, @@ -2198,7 +2198,7 @@ _XimGetResourceListRecByMode( return (XIMResourceList)NULL; } -Public Bool +Bool _XimCheckCreateICValues( XIMResourceList res_list, unsigned int list_num) @@ -2209,7 +2209,7 @@ _XimCheckCreateICValues( return False; } -Public XIMResourceList +XIMResourceList _XimGetResourceListRecByQuark( XIMResourceList res_list, unsigned int list_num, @@ -2225,7 +2225,7 @@ _XimGetResourceListRecByQuark( return (XIMResourceList)NULL; } -Public XIMResourceList +XIMResourceList _XimGetResourceListRec( XIMResourceList res_list, unsigned int list_num, @@ -2236,7 +2236,7 @@ _XimGetResourceListRec( return _XimGetResourceListRecByQuark(res_list, list_num, quark); } -Public char * +char * _XimSetIMValueData( Xim im, XPointer top, @@ -2266,7 +2266,7 @@ _XimSetIMValueData( return NULL; } -Public char * +char * _XimGetIMValueData( Xim im, XPointer top, @@ -2296,7 +2296,7 @@ _XimGetIMValueData( return NULL; } -Public void +void _XimSetIMMode( XIMResourceList res_list, unsigned int list_num) @@ -2315,7 +2315,7 @@ _XimSetIMMode( return; } -Private int +static int _XimCheckSetIMDefaultsMode( XIMResourceList res) { @@ -2325,7 +2325,7 @@ _XimCheckSetIMDefaultsMode( return XIM_CHECK_INVALID; } -Private int +static int _XimCheckSetIMValuesMode( XIMResourceList res) { @@ -2335,7 +2335,7 @@ _XimCheckSetIMValuesMode( return XIM_CHECK_INVALID; } -Private int +static int _XimCheckGetIMValuesMode( XIMResourceList res) { @@ -2345,7 +2345,7 @@ Private int return XIM_CHECK_INVALID; } -Public int +int _XimCheckIMMode( XIMResourceList res, unsigned long mode) @@ -2364,7 +2364,7 @@ Public int } } -Public void +void _XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style) { XIMResourceList res; @@ -2406,7 +2406,7 @@ _XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style) return; } -Private int +static int _XimCheckSetICDefaultsMode( XIMResourceList res, unsigned long mode) @@ -2449,7 +2449,7 @@ _XimCheckSetICDefaultsMode( return XIM_CHECK_VALID; } -Private int +static int _XimCheckCreateICMode( XIMResourceList res, unsigned long mode) @@ -2502,7 +2502,7 @@ _XimCheckCreateICMode( return XIM_CHECK_VALID; } -Private int +static int _XimCheckSetICValuesMode( XIMResourceList res, unsigned long mode) @@ -2543,7 +2543,7 @@ _XimCheckSetICValuesMode( return XIM_CHECK_VALID; } -Private int +static int _XimCheckGetICValuesMode( XIMResourceList res, unsigned long mode) @@ -2578,7 +2578,7 @@ _XimCheckGetICValuesMode( return XIM_CHECK_VALID; } -Public int +int _XimCheckICMode( XIMResourceList res, unsigned long mode) @@ -2596,7 +2596,7 @@ Public int } } -Public Bool +Bool _XimSetLocalIMDefaults( Xim im, XPointer top, @@ -2635,7 +2635,7 @@ _XimSetLocalIMDefaults( return True; } -Public Bool +Bool _XimSetICDefaults( Xic ic, XPointer top, @@ -2700,7 +2700,7 @@ _XimSetICDefaults( return True; } -Private Bool +static Bool _XimEncodeAttr( XimValueOffsetInfo info, unsigned int num, @@ -2721,7 +2721,7 @@ _XimEncodeAttr( return False; } -Public Bool +Bool _XimEncodeLocalIMAttr( XIMResourceList res, XPointer top, @@ -2731,7 +2731,7 @@ _XimEncodeLocalIMAttr( res, top, val); } -Public Bool +Bool _XimEncodeLocalICAttr( Xic ic, XIMResourceList res, @@ -2756,7 +2756,7 @@ _XimEncodeLocalICAttr( return _XimEncodeAttr(info, num, res, top, arg->value); } -Private Bool +static Bool _XimEncodeLocalTopValue( Xic ic, XIMResourceList res, @@ -2792,7 +2792,7 @@ _XimEncodeLocalTopValue( return True; } -Private Bool +static Bool _XimEncodeLocalPreeditValue( Xic ic, XIMResourceList res, @@ -2814,7 +2814,7 @@ _XimEncodeLocalPreeditValue( return True; } -Private Bool +static Bool _XimEncodeLocalStatusValue( Xic ic, XIMResourceList res, @@ -2836,7 +2836,7 @@ _XimEncodeLocalStatusValue( return True; } -Public char * +char * _XimSetICValueData( Xic ic, XPointer top, @@ -2901,7 +2901,7 @@ _XimSetICValueData( return NULL; } -Private Bool +static Bool _XimCheckInputStyle( XIMStyles *styles, XIMStyle style) @@ -2917,7 +2917,7 @@ _XimCheckInputStyle( return False; } -Public Bool +Bool _XimCheckLocalInputStyle( Xic ic, XPointer top, @@ -2948,7 +2948,7 @@ _XimCheckLocalInputStyle( return False; } -Private Bool +static Bool _XimDecodeAttr( XimValueOffsetInfo info, unsigned int num, @@ -2969,7 +2969,7 @@ _XimDecodeAttr( return False; } -Public Bool +Bool _XimDecodeLocalIMAttr( XIMResourceList res, XPointer top, @@ -2979,7 +2979,7 @@ _XimDecodeLocalIMAttr( res, top, val); } -Public Bool +Bool _XimDecodeLocalICAttr( XIMResourceList res, XPointer top, @@ -3003,7 +3003,7 @@ _XimDecodeLocalICAttr( return _XimDecodeAttr(info, num, res, top, val); } -Public char * +char * _XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list, unsigned int list_num, XIMArg *values, unsigned long mode) { @@ -3052,7 +3052,7 @@ _XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list, return NULL; } -Public void +void _XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values) { bzero((char *)im_values, sizeof(XimDefIMValues)); @@ -3066,7 +3066,7 @@ _XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values) im_values->visible_position = im->core.visible_position; } -Public void +void _XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values) { im->core.styles = im_values->styles; @@ -3078,7 +3078,7 @@ _XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values) im->core.visible_position = im_values->visible_position; } -Public void +void _XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values) { bzero((char *)ic_values, sizeof(XimDefICValues)); @@ -3101,7 +3101,7 @@ _XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values) ic_values->status_attr = ic->core.status_attr; } -Public void +void _XimSetCurrentICValues( Xic ic, XimDefICValues *ic_values) @@ -3125,7 +3125,7 @@ _XimSetCurrentICValues( ic->core.status_attr = ic_values->status_attr; } -Private void +static void _XimInitialIMOffsetInfo(void) { unsigned int n = XIMNumber(im_attr_info); @@ -3136,7 +3136,7 @@ _XimInitialIMOffsetInfo(void) } } -Private void +static void _XimInitialICOffsetInfo(void) { unsigned int n; @@ -3158,7 +3158,7 @@ _XimInitialICOffsetInfo(void) } } -Private void +static void _XimInitialIMMode(void) { unsigned int n = XIMNumber(im_mode); @@ -3169,7 +3169,7 @@ _XimInitialIMMode(void) } } -Private void +static void _XimInitialICMode(void) { unsigned int n = XIMNumber(ic_mode); @@ -3180,7 +3180,7 @@ _XimInitialICMode(void) } } -Public void +void _XimInitialResourceInfo(void) { static Bool init_flag = False; -- cgit v1.2.3 From d03ab1de0b68290291e2b74834b0c7dbe8b6df21 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 9 Aug 2013 23:30:30 -0700 Subject: ximcp/imRm.c: convert sprintf calls to snprintf Signed-off-by: Alan Coopersmith Reviewed-by: Matthieu Herrb Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 34c9bfa35..a7565d94b 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -75,8 +75,10 @@ _XimSetProtoResource(im) { char res_name_buf[256]; char* res_name; + size_t res_name_len; char res_class_buf[256]; char* res_class; + size_t res_class_len; char* str_type; XrmValue value; XIMStyle preedit_style = 0; @@ -90,17 +92,31 @@ _XimSetProtoResource(im) if (!im->core.rdb) return; - if (strlen (im->core.res_name) < 200) res_name = res_name_buf; - else res_name = Xmalloc (strlen (im->core.res_name) + 50); - if (strlen (im->core.res_class) < 200) res_class = res_class_buf; - else res_class = Xmalloc (strlen (im->core.res_class) + 50); + res_name_len = strlen (im->core.res_name); + if (res_name_len < 200) { + res_name = res_name_buf; + res_name_len = sizeof(res_name_buf); + } + else { + res_name_len += 50; + res_name = Xmalloc (res_name_len); + } + res_class_len = strlen (im->core.res_class); + if (res_class_len < 200) { + res_class = res_class_buf; + res_class_len = sizeof(res_class_buf); + } + else { + res_class_len += 50; + res_class = Xmalloc (res_class_len); + } /* pretend malloc always works */ - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "useAuth"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "UseAuth"); @@ -111,11 +127,11 @@ _XimSetProtoResource(im) } } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "delaybinding"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "Delaybinding"); @@ -126,11 +142,11 @@ _XimSetProtoResource(im) } } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "reconnect"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "Reconnect"); @@ -147,11 +163,11 @@ _XimSetProtoResource(im) return; } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "preeditDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "PreeditDefaultStyle"); @@ -170,11 +186,11 @@ _XimSetProtoResource(im) if(!preedit_style) preedit_style = XIMPreeditNothing; - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "statusDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "StatusDefaultStyle"); -- cgit v1.2.3 From 069c1f4d52243d17fd8c23008e1b4fe1486477f7 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Aug 2013 22:32:42 -0700 Subject: i18n modules: Fix some const cast warnings 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 Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index a7565d94b..d46500ac7 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/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))); } return; } -- cgit v1.2.3 From c161df4fee61819a28089682963cc2e721ca22c8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Aug 2013 23:51:08 -0700 Subject: Remove even more casts of return values from Xmalloc/Xrealloc Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imRm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nx-X11/lib/X11/imRm.c') diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index d46500ac7..373217173 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -207,7 +207,7 @@ _XimSetProtoResource(im) if(!status_style) status_style = XIMStatusNothing; - if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){ + if(!(imstyles = Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){ if (res_name != res_name_buf) Xfree (res_name); if (res_class != res_class_buf) Xfree (res_class); return; @@ -902,7 +902,7 @@ _XimEncodeHotKey( } len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xmalloc(len))) { return False; } @@ -1159,7 +1159,7 @@ _XimDecodeCallback( XIMCallback *callback; in = (XIMCallback *)((char *)top + info->offset); - if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) { + if(!(callback = Xmalloc(sizeof(XIMCallback)))) { return False; } callback->client_data = in->client_data; @@ -1272,7 +1272,7 @@ _XimDecodeHotKey( in = *((XIMHotKeyTriggers **)((char *)top + info->offset)); num = in->num_hot_key; len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xmalloc(len))) { return False; } @@ -1312,7 +1312,7 @@ _XimDecodeRectangle( XRectangle *rect; in = (XRectangle *)((char *)top + info->offset); - if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) { + if(!(rect = Xmalloc(sizeof(XRectangle)))) { return False; } *rect = *in; @@ -1330,7 +1330,7 @@ _XimDecodeSpot( XPoint *spot; in = (XPoint *)((char *)top + info->offset); - if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) { + if(!(spot = Xmalloc(sizeof(XPoint)))) { return False; } *spot = *in; -- cgit v1.2.3