dtmail: Resolve 50 compiler warnings.
authorPeter Howkins <flibble@users.sf.net>
Tue, 6 Jan 2015 15:07:55 +0000 (15:07 +0000)
committerPeter Howkins <flibble@users.sf.net>
Tue, 6 Jan 2015 15:07:55 +0000 (15:07 +0000)
15 files changed:
cde/programs/dtmail/dtmail/Attachment.C
cde/programs/dtmail/dtmail/DmxPrintOptions.C
cde/programs/dtmail/dtmail/RoamApp.C
cde/programs/dtmail/dtmail/RoamApp.h
cde/programs/dtmail/dtmail/RoamCmds.C
cde/programs/dtmail/dtmail/RoamMenuWindow.C
cde/programs/dtmail/dtmail/SendMsgDialog.C
cde/programs/dtmail/dtmail/options_util.C
cde/programs/dtmail/dtmailpr/main.C
cde/programs/dtmail/dtmailpr/message.C
cde/programs/dtmail/dtmailpr/utils.C
cde/programs/dtmail/libDtMail/Common/DtMailError.C
cde/programs/dtmail/libDtMail/Common/DtMailRc.C
cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C
cde/programs/dtmail/libDtMail/RFC/RFCMessage.C

index a0d256733ee62363db78728c7cca3d2c2873188d..74a91da266ecc8f8205240e607ff73e5afe32d51 100644 (file)
@@ -439,7 +439,7 @@ Attachment::invokeAction(int index)
        int answer;
        char *buf = new char[2048];
 
-       sprintf(buf,
+       sprintf(buf, "%s",
                GETMSG(DT_catd, 3, 81, "This attachment may contain commands that can cause serious\ndamage.  It is recommended that you only execute it after you\nare certain it is safe to do so.\n\nPress OK if you are certain it is safe,\nCancel to cancel execution."));
 
        answer = parent()->handleQuestionDialog(
@@ -868,7 +868,7 @@ Attachment::action(
        /* NL_COMMENT
         * Post a dialog explaining that the action was invalid
         */
-       sprintf(buf, 
+       sprintf(buf, "%s",
                GETMSG(
                        DT_catd, 3, 91, "Cannot execute invalid action."));
 
@@ -883,7 +883,7 @@ Attachment::action(
        /* NL_COMMENT 
         * Post a dialog explaining that the action failed.
         */
-       sprintf(buf, 
+       sprintf(buf, "%s",
                GETMSG(DT_catd, 3, 92, "Executing action failed!"));
 
        answer = parent()->handleErrorDialog(GETMSG(DT_catd, 1, 86, "Mailer"),
index 306f1da13e6c2592e9bb87f035b34a84eadd205b..3efaf32fc69d6fde29af90d92c4566616010d7b8 100644 (file)
@@ -317,7 +317,7 @@ DmxPrintOptions::DmxPrintOptions (
                                        _FROM_MAILRC,
                                        margin_keys[j].key,
                                        DmxPrintOptions::isValidMarginSpec,
-                                       (void*) margin_keys[j].which);
+                                       (void*) (intptr_t) margin_keys[j].which);
         _propui_array->append(pui);
     }
 
index 354d6c6da18ecbbc97d341c98044814bb1642c89..99f21bf336c6abb5a4d44123f55e367db275c29c 100644 (file)
@@ -1334,7 +1334,7 @@ void RoamApp::initialize(int *argcp, char **argv)
 
            DtMailGenDialog *install_errDialog =
                new DtMailGenDialog("Dialog", theApplication->baseWidget());
-            sprintf(buf, GETMSG(DT_catd, 2, 4,
+            sprintf(buf, "%s", GETMSG(DT_catd, 2, 4,
                 "Mailer has not been properly installed,\n\
 and cannot run because the execution group\n\
 is incorrectly set."));
@@ -2008,7 +2008,7 @@ RoamApp::vacation()
     return (_vacation);
 }
 
-char *formatPropPair(char * key, void * data)
+char *formatPropPair(char * key, const void * data)
 {
     char *formatted_str = NULL;
     char *white_space = NULL;
@@ -2036,18 +2036,18 @@ char *formatPropPair(char * key, void * data)
                 + strlen((char *)data) + strlen(" = ") + 1;
        formatted_str = (char *)malloc(m_size);
 
-       sprintf(formatted_str, "%s%s = %s",key, white_space, data);
+       sprintf(formatted_str, "%s%s = %s",key, white_space, (const char *) data);
 
       }
     else
       {
                /* make an alias string */
-       formatted_str = (char *)malloc(key_len + strlen((char *)data) + 2);
+       formatted_str = (char *)malloc(key_len + strlen((const char *)data) + 2);
     
-       m_size = key_len + strlen((char *)data) + strlen(" = ") + 1;
+       m_size = key_len + strlen((const char *)data) + strlen(" = ") + 1;
        formatted_str = (char *)malloc(m_size);
 
-       sprintf(formatted_str, "%s = %s",key, data);
+       sprintf(formatted_str, "%s = %s",key, (const char *) data);
 
       }
     
index 990667d5016df51e371d5b98a1a8afd265a575ae..e38bc20b2c60c9d3becf8e37f95c4df6ec01e7d1 100644 (file)
@@ -184,7 +184,7 @@ struct PropStringPair {
     ~PropStringPair(void);
 };
 
-char *formatPropPair(char * key, void * data);
+char *formatPropPair(char * key, const void * data);
 void parsePropString(const char * input, DtVirtArray<PropStringPair *> & result);
 char* getPropStringValue(DtVirtArray<PropStringPair *> &result, const char *value);
 
index 7efe96921dcdfdaf9335cd82942ba72001f39bd8..67b6e074254b9ace444180be53afb28d85f226a2 100644 (file)
@@ -2427,7 +2427,7 @@ Check file permissions and retry."),
     if (NULL == _roam_menu_window)
     {
        char    *text_buf = _text_editor->get_contents();
-       writeText((XtPointer) fd, text_buf);
+       writeText((XtPointer) (intptr_t) fd, text_buf);
         XtFree((char*) text_buf);
     }
     else
@@ -2492,8 +2492,8 @@ SaveAsTextCmd::writeTextFromScrolledList(int fd)
        next_msg->display(
                        visible_headers,
                        &SaveAsTextCmd::writeText,
-                       (XtPointer) fd);
-       writeText((XtPointer) fd, "\n\n");
+                       (XtPointer) (intptr_t) fd);
+       writeText((XtPointer) (intptr_t) fd, "\n\n");
     } while ((next_msg = mailbox->nextMessage()) != (DmxMsg *) NULL);
     delete mailbox;
 
@@ -2725,7 +2725,7 @@ void RenameAttachCmd::doit()
     
     renameDialog = aa->getRenameDialog();
     
-    sprintf(buf, GETMSG(DT_catd, 3, 57, "Rename attachment as"));
+    sprintf(buf, "%s", GETMSG(DT_catd, 3, 57, "Rename attachment as"));
     
     message = XmStringCreateLocalized(buf);
     
@@ -3473,7 +3473,7 @@ VacationCmd::handleForwardFile()
        else
          dialog = theRoamApp.genDialog();
 
-       sprintf(error_buf, GETMSG(DT_catd, 1, 102, "You are already using the forwarding facility for\nsomething other than Vacation.  While Vacation is\nrunning, Vacation will be appended to this other\nforwarding activity. Is it still OK to start Vacation?\0"));
+       sprintf(error_buf, "%s", GETMSG(DT_catd, 1, 102, "You are already using the forwarding facility for\nsomething other than Vacation.  While Vacation is\nrunning, Vacation will be appended to this other\nforwarding activity. Is it still OK to start Vacation?\0"));
 
        dialog->setToQuestionDialog(GETMSG(DT_catd, 1, 103, "Mailer"), 
                                    error_buf);
@@ -3521,7 +3521,7 @@ VacationCmd::handleForwardFile()
        else
          dialog = theRoamApp.genDialog();
 
-       sprintf(error_buf, GETMSG(DT_catd, 1, 104, "You are already running the vacation program in your .forward file.\nConsult documentation on how to stop it and remove it from your .forward file.\nTry this command after fixing that problem.\0"));
+       sprintf(error_buf, "%s", GETMSG(DT_catd, 1, 104, "You are already running the vacation program in your .forward file.\nConsult documentation on how to stop it and remove it from your .forward file.\nTry this command after fixing that problem.\0"));
        
        dialog->setToErrorDialog("Error", error_buf);
        helpId = DTMAILHELPREMOVEVACATION;
@@ -3791,7 +3791,7 @@ VacationCmd::recoverForwardFile(
        char *buf = new char[BUFSIZ+1];
        int  fd;
 
-       sprintf(buf, file);
+       sprintf(buf, "%s", file);
        strcat(buf, _backupSuffix);
 
        if (rename(buf, file) < 0) {
@@ -3898,7 +3898,7 @@ VacationCmd::parseVacationMessage()
     struct stat buf;
     if (SafeFStat(fd, &buf) < 0) {
 
-       sprintf(dialog_text, 
+       sprintf(dialog_text, "%s",
                GETMSG(DT_catd, 1, 105, "Cannot open .vacation.msg file -- No write permission."));
        dialog->setToQuestionDialog("Mailer", dialog_text);
        helpId = DTMAILHELPNOWRITEVACATION;
@@ -4086,7 +4086,7 @@ VacationCmd::handleMessageFile(
     }
 
     if (msg_file_exists >= 0 &&  text_changed) {
-       sprintf(dialog_text, 
+       sprintf(dialog_text, "%s",
                GETMSG(DT_catd, 1, 106, ".vacation.msg file exists.  Replace with new text?"));
        dialog->setToQuestionDialog("Mailer", dialog_text);
        helpId = DTMAILHELPEXISTSVACATION;
@@ -4104,7 +4104,7 @@ VacationCmd::handleMessageFile(
 
        fd = SafeOpen(messagefile, O_WRONLY | O_CREAT);
        if (fd < 0) {
-           sprintf(dialog_text, 
+           sprintf(dialog_text, "%s",
                GETMSG(DT_catd, 1, 107, "Cannot open .vacation.msg file -- No write permission."));
            dialog->setToQuestionDialog("Mailer", dialog_text);
            helpId = DTMAILHELPERROR;
index 33d0b85f8201ec1e4ad3d7d3029a9ce136aaa18c..446c89a576451e74347a54fab37382ade7e0ae93 100644 (file)
@@ -655,7 +655,7 @@ RoamMenuWindow::initialize()
     if (!this->baseWidget())
     {
        fprintf(
-               stderr, 
+               stderr, "%s",
                GETMSG(DT_catd, 2, 3,
                  "Unable to initialize windows. Exiting.\n"));
        exit(1);
@@ -1615,7 +1615,7 @@ RoamMenuWindow::open(
        else if ((DTMailError_t)error == DTME_BadRunGroup)
        {
 
-           sprintf(buf, GETMSG(DT_catd, 2, 4,
+           sprintf(buf, "%s", GETMSG(DT_catd, 2, 4,
                   "Mailer has not been properly installed,\n\
 and cannot run because the execution group\n\
 is incorrectly set."));
@@ -1796,7 +1796,7 @@ RoamMenuWindow::propsChanged(void)
            //
            displayInCurrentWorkspace();
            sprintf(
-               buf,
+               buf, "%s",
                GETMSG(DT_catd, 99, 99,"The INBOX path has changed.\nReopen?"));
            _genDialog->setToQuestionDialog(
                                        GETMSG(DT_catd, 3, 22, "Mailer"),
@@ -2240,7 +2240,7 @@ RoamMenuWindow::message( char *text )
     }
     else {
        buf = new char[2];
-       sprintf(buf, "");
+       sprintf(buf, "%s", "");
        labelStr = XmStringCreateLocalized(buf);
        _clear_message_p = FALSE;
     }
index d2dcd9a4d30b6ce46feb7af40618fd526e500625..473853dcb5fac2d63b4c15e45d810f57b8c915d1 100644 (file)
@@ -1062,7 +1062,7 @@ SendMsgDialog::sendmailErrorProc (int, int status, void *data)
             * There was an error in one or more of the email addresses.  
             * Ask the user to type in a valid address and try again.
             */
-           sprintf(buf, GETMSG(DT_catd, 5, 5, 
+           sprintf(buf, "%s", GETMSG(DT_catd, 5, 5, 
 "Some of the addresses in the message are incorrect,\n\
 and do not refer to any known users in the system.\n\
 Please make sure all of the addresses are valid and try again."));
@@ -1076,7 +1076,7 @@ Please make sure all of the addresses are valid and try again."));
             * applications so there will be more memory available.
             */
  
-            sprintf(buf, GETMSG(DT_catd, 5, 6,
+            sprintf(buf, "%s", GETMSG(DT_catd, 5, 6,
 "Mailer does not have enough memory\n\
 available to send this message.\n\
 Try quitting other applications and\n\
@@ -1091,7 +1091,7 @@ resend this message."));
             * There was an error from the mail transport (sendmail).
             */
 
-           sprintf(buf, GETMSG(DT_catd, 5, 7,
+           sprintf(buf, "%s", GETMSG(DT_catd, 5, 7,
 "An error occurred while trying to send your message.\n\
 Check to make sure the message was received.  If not,\n\
 you may have to resend this message."));
@@ -1153,7 +1153,7 @@ SendMsgDialog::send_message(const char * trans_impl, int trans_type)
     if (!this->hasAddressee()) {
        // Message has no valid addressee.  Pop up error dialog.
 
-       sprintf(buf, GETMSG(DT_catd, 5, 8,
+       sprintf(buf, "%s", GETMSG(DT_catd, 5, 8,
                 "Try Send after specifying  recipient(s) of the message in \nthe To:, Cc:, or Bcc: fields."));
 
        helpId = DTMAILHELPNEEDADDRESSEE;
@@ -1197,7 +1197,7 @@ SendMsgDialog::send_message(const char * trans_impl, int trans_type)
     
     
     numPendingActions = attachArea->getNumPendingActions();
-    sprintf(buf, GETMSG(
+    sprintf(buf, "%s", GETMSG(
                        DT_catd, 
                        3, 
                        77, 
@@ -1330,7 +1330,7 @@ SendMsgDialog::popupMemoryError(DtMailEnv &error)
             * Mailer ran out of memory.  Ask the user to quit some other
             * applications so there will be more memory available.
             */
-           sprintf(buf, GETMSG(DT_catd, 5, 6,
+           sprintf(buf, "%s", GETMSG(DT_catd, 5, 6,
 "Mailer does not have enough memory\n\
 available to send this message.\n\
 Try quitting other applications and\n\
@@ -3409,7 +3409,7 @@ SendMsgDialog::renameAttachmentOK()
     if (attachArea->getIconSelectedCount() > 1) {
        char *buf = new char[512];
        
-       sprintf(buf, GETMSG(DT_catd, 5, 4, "Select only one attachment\n\
+       sprintf(buf, "%s", GETMSG(DT_catd, 5, 4, "Select only one attachment\n\
 and then choose rename"));
        
        _genDialog->setToQuestionDialog(
index aa845cde7f79aa1d32c3fe8686d856301b47bc7e..e40d2afc7ea97082b423283247da0483ae45bb7f 100644 (file)
@@ -101,7 +101,7 @@ options_radiobox_init(
        XtAddCallback(items[i], XmNvalueChangedCallback, 
                        options_setting_chgCB, (XtPointer)dirty_bit);
        XtAddCallback(items[i], XmNvalueChangedCallback, 
-                       options_radiobox_itemCB, (XtPointer)item_values[i]);
+                       options_radiobox_itemCB, (XtPointer) (intptr_t) item_values[i]);
 
        /* Ensure Radiobox has a default Value set */
        if (i == 0)
index caa31ecfc7baa60a3c9ab89bd1be8f8225748235..3f51492a578144df9bf03a2b7f7bd896468be600 100644 (file)
@@ -49,13 +49,17 @@ gid_t       _originalRgid;    // startup real gid
 void   
 enableGroupPrivileges(void *)
 {
-    (void) setgid(_originalEgid);
+    if(-1 == setgid(_originalEgid)) {
+        fprintf(stderr, "Failed to enable group priviledges\n");
+    }
 }
 
 void   
 disableGroupPrivileges(void *)
 {
-    (void) setgid(_originalRgid);
+    if(-1 == setgid(_originalRgid)) {
+        fprintf(stderr, "Failed to disable group priviledges\n");
+    }
 }
 
 int
index 93a4715418a11f7f3597c621a5c939d1b98e7358..a1cc32c839499d746c9aa56d536ca5589aeb3b4f 100644 (file)
@@ -417,7 +417,7 @@ DmxMsg::display (void)
                        name = "(name)";
 
                printf ("[%d] \"%s\"%s, ", i, name, description);
-               printf ("%s, %d bytes\n", type, length);
+               printf ("%s, %lu bytes\n", type, length);
 
                if (attbuf != NULL)
                        delete [] attbuf;
index 86cd8301085ca9abf7523f5b9861978ab1cb0b9d..9ce88c081032897249b4070d7ce5da2cb824d5f4 100644 (file)
@@ -122,7 +122,7 @@ formatHeader (DtMailHeaderLine &info, enum DmxHeaderType htype)
        {
                case MSGLIST:
                        sprintf (fbuf,
-                       "%-18.18s %-16.16s %4ld/%-5s %-.25s",
+                       "%-18.18s %-16.16s %4d/%-5s %-.25s",
                                dispname (header [DMXFROM]),
                                header [DMXDATE],
                                atoi (header [DMXCLENGTH]) / 40,
index e85cf1aa6564f59bc828f5e19adf111976754a74..4650b7b44ab56e0976418cbced22a4b55b0be44b 100644 (file)
@@ -606,7 +606,7 @@ DtMailEnv::logError(DtMailBoolean criticalError, const char *format, ...) const
   va_end(var_args);
 
   syslog(criticalError == DTM_TRUE ? LOG_CRIT|LOG_ERR : LOG_ERR,
-        messageBuffer);
+        "%s", messageBuffer);
   
   _DtSimpleError("libDtMail", criticalError  == DTM_TRUE ? DtError : DtWarning,
                NULL, messageBuffer);
index 9a372d7d29667773c70463cb24d4377b3d1a7748..f251fa5b54a4d13b3e366e118edaea1736a99f16 100644 (file)
@@ -1373,7 +1373,7 @@ DtMail::MailRc::nalias(char * key, void * data, void * client_data)
                 + strlen((char *)data) + strlen(" = ") + 1;
        new_alias = (char *)malloc(m_size);
     
-       sprintf(new_alias, "%s%s = %s",key, white_space, data);
+       sprintf(new_alias, "%s%s = %s",key, white_space, (char *) data);
 
       }
     else
@@ -1382,7 +1382,7 @@ DtMail::MailRc::nalias(char * key, void * data, void * client_data)
        m_size = key_len + strlen((char *)data) + strlen(" = ") + 1;
        new_alias = (char *)malloc(m_size);
     
-       sprintf(new_alias, "%s = %s",key, data);
+       sprintf(new_alias, "%s = %s",key, (char *) data);
 
       }
     
index 91bc8ec394a2aaef7b28ad55813043b8bd272eb6..0b1409194d6f67e0e01e4ef2b254e409127deea7 100644 (file)
@@ -228,7 +228,7 @@ void HexDump(FILE *pfp, char *pmsg, unsigned char *pbufr, int plen, int plimit)
     delete [] dumpfilename;
   }
 
-  (void) fprintf(pfp_r, "--> %s (%d bytes at 0x%08lx):\n", pmsg, plen, pbufr);
+  (void) fprintf(pfp_r, "--> %s (%d bytes at %p):\n", pmsg, plen, pbufr);
   fflush(pfp_r);
   memset((char *)save, 0, sizeof(save));
   save[0] = ~pbufr[0];
@@ -236,7 +236,7 @@ void HexDump(FILE *pfp, char *pmsg, unsigned char *pbufr, int plen, int plimit)
   cnt = plen;
   for (x = 0; cnt > 0; x++, z += 16)
   {
-    (void) fprintf(pfp_r, "0x%08lx(+%6.6ld) ", pbufr + z, z);
+    (void) fprintf(pfp_r, "%p(+%6.6ld) ", pbufr + z, z);
     for (y = 0; y < 16; y++)
     {
       save[y] = pbufr[x * 16 + y];
@@ -901,7 +901,10 @@ RFCMailBox::open(DtMailEnv & error,
          pread(_fd, (void *)inbuf, 5, 0);
 #else
          lseek(_fd, (off_t) 0L, SEEK_SET);
-         read(_fd, (void *)inbuf, 5);
+         if(-1 == read(_fd, (void *)inbuf, 5)) {
+           error.setError(DTME_NotMailBox);
+           return;
+          }
          lseek(_fd, (off_t) 0L, SEEK_SET);
 #endif
          inbuf[5] = (char)0;
@@ -4588,21 +4591,21 @@ RFCMailBox::dumpMaps(const char *str)
     memset((void*) &ctime_buf, 0, sizeof(_Xctimeparams));
     fprintf(df, "--------------------- pid=%ld %s", 
            (long)getpid(), _XCtime(&clockTime, ctime_buf));
-    fprintf(df, str);
+    fprintf(df, "%s", str);
     fprintf(df, "---------------------\n");
     fprintf(df, "Mappings = %d\n", _mappings.length());
     fprintf(df, "Map Entries:\n");
     for (int m = 0; m < _mappings.length(); m++) {
       MapRegion *map = _mappings[m];
-      fprintf(df, "map[%d]: map_region = 0x%08lx, map_size = 0x%08lx(%08ld)\n",
+      fprintf(df, "map[%d]: map_region = %p, map_size = 0x%08lx(%08ld)\n",
              m, map->map_region, map->map_size, map->map_size);
       if (map->map_size % memoryPageSize()) {
-       fprintf(df, "ERROR! map->map_size not mod %d\n", memoryPageSize());
+       fprintf(df, "ERROR! map->map_size not mod %lu\n", memoryPageSize());
       }
       HexDump(df, "map_region", (unsigned char *)map->map_region,
              (int) map->file_size, _errorLogging ? 0 : 10);
       fprintf(df,
-             "map[%d]: file_region = 0x%08lx, file_size = 0x%08lx(%08ld)\n",
+             "map[%d]: file_region = %p, file_size = 0x%08lx(%08ld)\n",
              m, map->file_region, map->file_size, map->file_size);
       fprintf(df, "map[%d]: offset = 0x%08lx(%08ld)\n",
              m, map->offset, map->offset);
@@ -4621,12 +4624,12 @@ RFCMailBox::dumpMaps(const char *str)
       total_file_size += (off_t) map->file_size;
       if ((total_file_size % 4096) == 0) {
        fprintf(df,
-               "Total file size falls on page boundary, totalsize = %d\n",
+               "Total file size falls on page boundary, totalsize = %lu\n",
                total_file_size);
       }
     }
   
-    fprintf(df, "\nstat buffer entries: st_ino = %d, st_dev = %d, st_nlink = %d, st_size = %ld\n",
+    fprintf(df, "\nstat buffer entries: st_ino = %lu, st_dev = %lu, st_nlink = %lu, st_size = %ld\n",
            buf.st_ino, buf.st_dev, buf.st_nlink, buf.st_size);
   
     fprintf(df, "\n\n");
index b55d2c9e97c73b95489c6eb5d5b96971f815db9f..5e6c5b595ec7be8f06ec21d27bde7b5be34844bc 100644 (file)
@@ -995,7 +995,7 @@ RFCMessage::findMsgEnd(DtMailEnv & error, const char * eof)
     content_length = content_length < 0 ? 0 : content_length;
 
     char buf[20];
-    sprintf(buf, "%d", content_length);
+    sprintf(buf, "%lu", content_length);
     _envelope->setHeader(error, "Content-Length", DTM_TRUE, buf);
 
     return(real_end);
@@ -1607,7 +1607,7 @@ RFCMessage::extractBoundary(const char * content_type)
 
     if (!content_type) {
        char * new_bdry = (char *)malloc(78);
-       sprintf(new_bdry, "%08lx-%08lx-%08lx", new_bdry, (long)time(NULL), &new_bdry);
+       sprintf(new_bdry, "%p-%08lx-%p", new_bdry, (long)time(NULL), &new_bdry);
     }
 
     // We will need the boundary to find the message boundaries.