dtpdm: XtVaGetValues, XtPointer, XtArgVal, ...
authorMarcin Cieslak <saper@saper.info>
Mon, 24 Sep 2012 16:11:36 +0000 (18:11 +0200)
committerJon Trulson <jon@radscan.com>
Tue, 25 Sep 2012 00:31:25 +0000 (18:31 -0600)
Make XtVaGetValues return variables safe for 64-bit

cde/programs/dtpdm/Main.c
cde/programs/dtpdm/MainWindow.c
cde/programs/dtpdm/PrinterBox.c

index 7a59de1ef32da0f3b43564964f3c66bb262b1dea..d892e344a8f3f6b5e6c725a11179478937d60947 100644 (file)
@@ -275,6 +275,7 @@ PdmShellPresent(PdmShell* me)
 {
     int parent_abs_x, parent_abs_y;
     Position x, y;
+    XtArgVal  width0, height0;
     Dimension width, height;
     Window dummy_child;
     /*
@@ -290,7 +291,9 @@ PdmShellPresent(PdmShell* me)
      * get the dimensions of the PDM window
      */
     XtRealizeWidget(me->widget);
-    XtVaGetValues(me->widget, XmNwidth, &width, XmNheight, &height, NULL);
+    XtVaGetValues(me->widget, XmNwidth, &width0, XmNheight, &height0, NULL);
+    width = (Dimension)width0;
+    height = (Dimension)height0;
     /*
      * determine the origin of the PDM popup such that it is
      * centered w.r.t. the parent window
index 6e8a6c5147a0f71ad9f026f3bcae8f43a4661323..de87777543a37c1a4d54064ff4ee151441d6354f 100644 (file)
@@ -447,12 +447,13 @@ PdmMainWinHelpCB(Widget w, XtPointer client_data, XtPointer call_data)
      * determine the current setup box
      */
     {
-       int current_page, i;
+       XtArgVal current_page;
+       int i;
        PdmBoxNode* node;
        
        XtVaGetValues(me->notebook, XmNcurrentPageNumber, &current_page, NULL);
        node = me->box_list_head;
-       for(i = 1; i < current_page; i++)
+       for(i = 1; i < (int)current_page; i++)
            node = node->next;
        box = node->box;
     }
index d3ff718133be9e0e0c26da0ba77c301fca9ca8a9..1992181089cf7304cbe0130d102adfc3a47e013d 100644 (file)
@@ -825,8 +825,8 @@ PdmPrinterBoxResizeCB(Widget w,
     PdmSetupBox* me = (PdmSetupBox*)client_data;
     PdmPrinterBoxData* data = (PdmPrinterBoxData*)me->subclass_data;
     typedef struct {
-       Position x, y;
-       Dimension width, height;
+       XtArgVal /* Position */ x, y;
+       XtArgVal /* Dimension */ width, height;
     } PdmRect;
     PdmRect rt, rs, ro, rp, c1, c2, r1, r2;
     /*
@@ -1121,9 +1121,9 @@ static void
 OrientCtlResizeCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     OrientCtl* me = (OrientCtl*)client_data;
-    Dimension height, width, margin_width, new_width;
-    Position menu_x, menu_y, icon_x, icon_y;
-    Dimension menu_h, menu_w, icon_h, icon_w;
+    XtArgVal /* Dimension */ height, width, margin_width, new_width;
+    XtArgVal /* Position */ menu_x, menu_y, icon_x, icon_y;
+    XtArgVal /* Dimension */ menu_h, menu_w, icon_h, icon_w;
     /*
      * get current layout info
      */
@@ -1212,7 +1212,7 @@ static void
 OrientCtlSelectCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     OrientCtl* me;
-    int selected_item = (int)client_data;
+    XtArgVal /* int */ selected_item = (XtArgVal)client_data;
 
     XtVaGetValues(w, XmNuserData, &me, NULL);
     OrientCtlSetSelectedItem(me, selected_item);
@@ -1574,9 +1574,9 @@ static void
 PlexCtlResizeCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     PlexCtl* me = (PlexCtl*)client_data;
-    Dimension height, width, margin_width, new_width;
-    Position menu_x, menu_y, icon_x, icon_y;
-    Dimension menu_h, menu_w, icon_h, icon_w;
+    XtArgVal /* Dimension */ height, width, margin_width, new_width;
+    XtArgVal /* Position  */ menu_x, menu_y, icon_x, icon_y;
+    XtArgVal /* Dimension */ menu_h, menu_w, icon_h, icon_w;
     /*
      * get current layout info
      */
@@ -1665,7 +1665,7 @@ static void
 PlexCtlSelectCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     PlexCtl* me;
-    int selected_item = (int)client_data;
+    XtArgVal /* int */ selected_item = (XtArgVal)client_data;
 
     XtVaGetValues(w, XmNuserData, &me, NULL);
     PlexCtlSetSelectedItem(me, selected_item);
@@ -2072,8 +2072,8 @@ static void
 TrayCtlResizeCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     TrayCtl* me = (TrayCtl*)client_data;
-    Dimension height, menu_h;
-    Position menu_y;
+    XtArgVal /* Dimension */ height, menu_h;
+    XtArgVal /* Position  */ menu_y;
     /*
      * get current layout info
      */
@@ -2217,7 +2217,7 @@ static void
 TrayCtlSelectCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     TrayCtl* me;
-    int selected_item = (int)client_data;
+    XtArgVal /* int */ selected_item = (XtArgVal)client_data;
 
     XtVaGetValues(w, XmNuserData, &me, NULL);
     TrayCtlSetSelectedItem(me, selected_item);
@@ -2725,9 +2725,9 @@ static void
 SizeCtlResizeCB(Widget w, XtPointer client_data, XtPointer call_data)
 {
     SizeCtl* me = (SizeCtl*)client_data;
-    Dimension height, width, margin_width, new_width;
-    Position list_x, list_y, radio_x, radio_y;
-    Dimension list_h, list_w, radio_h, radio_w;
+    XtArgVal /* Dimension */ height, width, margin_width, new_width;
+    XtArgVal /* Position  */ list_x, list_y, radio_x, radio_y;
+    XtArgVal /* Dimension */ list_h, list_w, radio_h, radio_w;
     Widget scrolled_list = XtParent(me->list_box);
     /*
      * get current layout info
@@ -2969,7 +2969,7 @@ CreateOptionMenuPulldown(String pulldown_name,
                                         NULL);
        if(activate_proc != (XtCallbackProc)NULL)
            XtAddCallback(button, XmNactivateCallback,
-                         activate_proc, (XtPointer)i);
+                         activate_proc, (XtPointer)(XtArgVal)i);
        if(i == initial_item)
            initial_selected = button;
     }
@@ -3063,6 +3063,7 @@ IconMaxDimension(Widget icon_label,
                 Dimension* max_width, Dimension* max_height)
 {
     Dimension width, height;
+    XtArgVal width0, height0;
     /*
      * set the pixmap in the label
      */
@@ -3073,9 +3074,11 @@ IconMaxDimension(Widget icon_label,
      * get the label dimensions
      */
     XtVaGetValues(icon_label,
-                 XmNwidth, &width,
-                 XmNheight, &height,
+                 XmNwidth, &width0,
+                 XmNheight, &height0,
                  NULL);
+    width  = (Dimension)width0;
+    height = (Dimension)height0;
     /*
      * update the max dimensions
      */
@@ -3104,6 +3107,7 @@ PdmPixmapListNew(int count,
                 Boolean stipple)
 {
     PdmPixmapList* me = (PdmPixmapList*)XtCalloc(1, sizeof(PdmPixmapList));
+    XtArgVal fg, bg;
 
     me->pixmap = (Pixmap*)XtCalloc(count, sizeof(Pixmap));
     me->image_name = (char**)XtCalloc(count, sizeof(char*));
@@ -3118,9 +3122,11 @@ PdmPixmapListNew(int count,
        me->stipple = None;
     }
     XtVaGetValues(w,
-                 XmNforeground, &me->foreground,
-                 XmNbackground, &me->background,
+                 XmNforeground, &fg,
+                 XmNbackground, &bg,
                  NULL);
+    me->foreground = (Pixel)fg;
+    me->background = (Pixel)bg;
 
     return me;
 }
@@ -3263,6 +3269,7 @@ PdmPixmapListGetPixmap(PdmPixmapList* me, int i)
 static void
 SetListBoxSelection(Widget list_box, int position)
 {
+    XtArgVal visible_item_count0, item_count0;
     int visible_item_count;
     int item_count;
     int middle_offset;
@@ -3273,9 +3280,11 @@ SetListBoxSelection(Widget list_box, int position)
      * it the initial selection.
      */
     XtVaGetValues(list_box,
-                 XmNitemCount, &item_count,
-                 XmNvisibleItemCount, &visible_item_count,
+                 XmNitemCount, &item_count0,
+                 XmNvisibleItemCount, &visible_item_count0,
                  NULL);
+    item_count = (int)item_count0;
+    visible_item_count = (int)visible_item_count0;
 
     if(item_count > visible_item_count)
     {