[PATCH libXaw3d 4/5] Use intptr_t instead of int when casting from and to XtPointer

Guillem Jover guillem at hadrons.org
Mon Oct 3 20:35:02 PDT 2011


Fixes gcc warnings:
Scrollbar.c: In function 'NotifyScroll':
Scrollbar.c:955:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Text.c: In function 'HScroll':
Text.c:1274:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
Text.c: In function 'VScroll':
Text.c:1431:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
TextPop.c: In function 'DoSearch':
TextPop.c:808:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
TextPop.c: In function 'Replace':
TextPop.c:942:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
Viewport.c: In function 'ScrollUpDownProc':
Viewport.c:866:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signed-off-by: Guillem Jover <guillem at hadrons.org>
---
 configure.ac    |    1 +
 src/Scrollbar.c |    8 +++++---
 src/Text.c      |    5 +++--
 src/TextPop.c   |    5 +++--
 src/Viewport.c  |    4 +++-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index c70959c..d74ccc4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,7 @@ AC_PROG_LEX
 PKG_CHECK_MODULES(X11, [x11 xt xmu xext])
 AC_CHECK_HEADERS([wctype.h wchar.h widec.h])
 AC_CHECK_FUNCS([iswspace])
+AC_TYPE_INTPTR_T
 
 XAW3D_CPPFLAGS=
 
diff --git a/src/Scrollbar.c b/src/Scrollbar.c
index 98aac74..429a660 100644
--- a/src/Scrollbar.c
+++ b/src/Scrollbar.c
@@ -69,6 +69,8 @@ SOFTWARE.
 
 #include <X11/Xmu/Drawing.h>
 
+#include <stdint.h>
+
 /* Private definitions. */
 
 #ifdef XAW_ARROW_SCROLLBARS
@@ -785,7 +787,7 @@ RepeatNotify(XtPointer client_data, XtIntervalId *idp)
 {
 #define A_FEW_PIXELS 5
     ScrollbarWidget sbw = (ScrollbarWidget) client_data;
-    int call_data;
+    intptr_t call_data;
     if (sbw->scrollbar.scroll_mode != 1 && sbw->scrollbar.scroll_mode != 3) {
 	sbw->scrollbar.timer_id = (XtIntervalId) 0;
 	return;
@@ -874,7 +876,7 @@ static void
 NotifyScroll (Widget w, XEvent *event, String *params, Cardinal *num_params)
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
-    int call_data;
+    intptr_t call_data;
     Position x, y;
 
     if (sbw->scrollbar.scroll_mode == 2  /* if scroll continuous */
@@ -920,7 +922,7 @@ static void
 NotifyScroll (Widget w, XEvent *event, String *params, Cardinal *num_params)
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
-    int call_data;
+    intptr_t call_data;
     char style;
     Position x, y;
 
diff --git a/src/Text.c b/src/Text.c
index 36bef53..be4d592 100644
--- a/src/Text.c
+++ b/src/Text.c
@@ -58,6 +58,7 @@ SOFTWARE.
 #ifdef XAW_INTERNATIONALIZATION
 #include "XawI18n.h"
 #endif
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xmu/Atoms.h>
@@ -1271,7 +1272,7 @@ HScroll(Widget w, XtPointer closure, XtPointer callData)
 {
   TextWidget ctx = (TextWidget) closure;
   Widget tw = (Widget) ctx;
-  Position old_left, pixels = (Position)(int) callData;
+  Position old_left, pixels = (Position)(intptr_t) callData;
   XRectangle rect, t_rect;
   int s = ((ThreeDWidget)ctx->text.threeD)->threeD.shadow_width;
 
@@ -1428,7 +1429,7 @@ static void
 VScroll(Widget w, XtPointer closure, XtPointer callData)
 {
   TextWidget ctx = (TextWidget)closure;
-  int height, nlines, lines = (int) callData;
+  int height, nlines, lines = (intptr_t) callData;
 
   height = ctx->core.height - VMargins(ctx);
   if (height < 1)
diff --git a/src/TextPop.c b/src/TextPop.c
index 5233f30..037fd5b 100644
--- a/src/TextPop.c
+++ b/src/TextPop.c
@@ -63,6 +63,7 @@ in this Software without prior written authorization from the X Consortium.
 #ifdef XAW_INTERNATIONALIZATION
 #include "XawI18n.h"
 #endif
+#include <stdint.h>
 #include <stdio.h>
 #include <X11/Xos.h>		/* for O_RDONLY */
 #include <errno.h>
@@ -805,7 +806,7 @@ DoSearch(struct SearchAndReplace * search)
       text.length = strlen(text.ptr);
   text.firstPos = 0;
 
-  dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
+  dir = (XawTextScanDirection)(intptr_t) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
 				R_OFFSET);
 
   pos = XawTextSearch( tw, dir, &text);
@@ -939,7 +940,7 @@ Replace(struct SearchAndReplace *search, Boolean once_only, Boolean show_current
 #endif
       replace.length = strlen(replace.ptr);
 
-  dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
+  dir = (XawTextScanDirection)(intptr_t) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
 				R_OFFSET);
   /* CONSTCOND */
   while (TRUE) {
diff --git a/src/Viewport.c b/src/Viewport.c
index d8b1188..abb8961 100644
--- a/src/Viewport.c
+++ b/src/Viewport.c
@@ -57,6 +57,8 @@ SOFTWARE.
 #include <X11/Xaw3d/Scrollbar.h>
 #include <X11/Xaw3d/ViewportP.h>
 
+#include <stdint.h>
+
 static void ScrollUpDownProc(Widget, XtPointer, XtPointer);
 static void ThumbProc(Widget, XtPointer, XtPointer);
 static Boolean GetGeometry(Widget, Dimension, Dimension);
@@ -863,7 +865,7 @@ ScrollUpDownProc(Widget widget, XtPointer closure, XtPointer call_data)
 {
     ViewportWidget w = (ViewportWidget)closure;
     Widget child = w->viewport.child;
-    int pix = (int)call_data;
+    int pix = (intptr_t) call_data;
     Position x, y;
 
     if (child == NULL) return;	/* no child to scroll. */
-- 
1.7.6.3



More information about the xorg-devel mailing list