dtpad: Use XtArgVal for int conversion
authorMarcin Cieslak <saper@saper.info>
Mon, 24 Sep 2012 01:15:20 +0000 (03:15 +0200)
committerJon Trulson <jon@radscan.com>
Mon, 24 Sep 2012 01:45:56 +0000 (19:45 -0600)
Avoid overwrite of local variables when using
short (int, etc.) types with XtVaGetValues().

Cast XtPointer using (XtArgVal) without
the need to use C99 <stdint.h> and friends.

cde/programs/dtpad/main.c
cde/programs/dtpad/printJob.c
cde/programs/dtpad/printOutput.c
cde/programs/dtpad/printSetup.c

index cccff2bb2704cb5f1aba8a0e31201e8aa877d57b..402e688e531c7016ab19e09bc567a0aedf6446aa 100644 (file)
@@ -924,7 +924,7 @@ SendMessageToServer(
      ttdt_subcontract_manage(msg,
                        pStatusCB,
                        NULL,
-                       (void *) ((int) pPad->xrdb.blocking));/* client data */
+                       (void *) ((XtArgVal) pPad->xrdb.blocking));/* client data */
 
      /* Add pArgs to msg using tt_message_context_set */
      SetupLoadArgs(msg, pPad);
@@ -1163,7 +1163,7 @@ StartDbUpdate(
 void
 exitCB(Widget w, XtPointer callData, XtPointer clientData)
 {
-    exit((int) clientData);
+    exit((XtArgVal) clientData);
 }
 
 /************************************************************************
index cc1e0aef5d2df4585e8c19b5b1d05e7916587991..3372603d4c35ba94e5d0b198acedf94481cfe76c 100644 (file)
@@ -953,14 +953,17 @@ _pjPrintOnePageCB(
 
     if (pJob->pOutput == NULL)
     {
-       Dimension       width, height;
+        XtArgVal       width0, height0;
+        Dimension      width, height;
 
         width = 0; height=0;
         XtVaGetValues(
                 pJob->pShell,
-                XmNwidth, &width,
-                XmNheight, &height,
+                XmNwidth, &width0,
+                XmNheight, &height0,
                 NULL);
+        width = (Dimension)width0;
+        height = (Dimension)height0;
 
 #if defined(PRINT_TO_VIDEO)
         printf("PrintShell in _pjPrintOnePageCB: <W %d - H %d>\n",width,height);
index 071145ea5a33318e849703dd9e5e46910e909ef5..ca61c38698d068c5502576eeaa70154d366eedc0 100644 (file)
@@ -569,6 +569,7 @@ PrintOutputGetLinesPerPage(PrintOutput *pOutput)
 int
 PrintOutputGetNumLines(PrintOutput *pOutput)
 {
+    XtArgVal p;
     int        total = 0;
     int saveTop;
 
@@ -581,7 +582,8 @@ PrintOutputGetNumLines(PrintOutput *pOutput)
     DtEditorGoToLine(pOutput->editor, saveTop);
     pOutput->currentLine = saveTop;
 #else
-    XtVaGetValues(pOutput->editor, XmNtotalLines, &total, NULL);
+    XtVaGetValues(pOutput->editor, XmNtotalLines, &p, NULL);
+    total = (int)p;
 #endif
     return(total);
 }
@@ -698,7 +700,7 @@ PrintOutputLoadFile( PrintOutput *pOutput, char *file)
 static int
 _poDoGetLinesPerPage(PrintOutput *pOutput)
 {
-    Dimension   lpp;
+    XtArgVal   lpp;
 
     XtVaGetValues(pOutput->editor, XmNrows, &lpp, NULL);
     return ((int) lpp);
@@ -714,23 +716,29 @@ _poSetInnerPageDimensions(
                        Dimension left
                        )
 {
+    XtArgVal   outer_height0, outer_width0, footer_height0, header_height0;
     Dimension  inner_height, inner_width, inner_x, inner_y,
                outer_height, outer_width,
                editor_height, footer_height, header_height;
 
     XtVaGetValues(pOutput->page,
-                 XmNheight, &outer_height,
-                 XmNwidth, &outer_width,
+                 XmNheight, &outer_height0,
+                 XmNwidth, &outer_width0,
                  NULL);
 
     XtVaGetValues(pOutput->headerLeft,
-                 XmNheight, &header_height,
+                 XmNheight, &header_height0,
                  NULL);
 
     XtVaGetValues(pOutput->footerLeft,
-                 XmNheight, &footer_height,
+                 XmNheight, &footer_height0,
                  NULL);
 
+    outer_height = (Dimension)outer_height0;
+    outer_width = (Dimension)outer_width0;
+    header_height = (Dimension)header_height0;
+    footer_height = (Dimension)footer_height0;
+
     inner_x = left;
     inner_y = top;
     inner_height = (outer_height > (Dimension) (top + bottom)) ?
index 4c74e14079c3762502be02870c903fb88e9c0a56..33e537e776c91287d24ee897e36b424102546e26 100644 (file)
@@ -614,7 +614,7 @@ _psSetupToUi(PrintSetup *pSetup)
 static void
 _psUiToSetup(PrintSetup *pSetup)
 {
-    unsigned char      isSet;
+    XtArgVal           isSet;
     Widget             frame, w;
     PrintOptions       *pOption;
     char               *marginSpec;