bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-mailutils] Miscellaneous warnings cleanup on Mac OS X 10.6


From: Jonathan Creekmore
Subject: [bug-mailutils] Miscellaneous warnings cleanup on Mac OS X 10.6
Date: Sat, 30 Apr 2011 14:33:30 -0500
User-agent: Gnus/5.110015 (No Gnus v0.15)

I attempted to get the mailutils 2.2 package to build under Mac OS X
10.6 (a 64-bit platform), and I ran into several warnings that I thought
I should address, as well as a few other minor issues. I have attached
patches that address all of the issues that I found, except for two. The
two other issues I found were in the gnulib-generated code, one of which
was removed when I updated my own tree to the latest gnulib.

I hope this is helpful.

--- a/mailbox/msrv.c
+++ b/mailbox/msrv.c
@@ -22,6 +22,16 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+
+#if defined __APPLE__ && defined __MACH__
+/**
+ * On Mac OS X 10.5 and later, stdlib.h warns that the daemon() function 
+ * is deprecated in favor of using launchd. For portable code, we still 
+ * want to use daemon(). Use this to trick the macro.
+ */
+#define daemon deprecated
+#endif
+
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <stdlib.h>
@@ -42,6 +52,12 @@
 #include <mailutils/daemon.h>
 #include <mailutils/acl.h>
 
+#if defined __APPLE__ && defined __MACH__
+#undef daemon
+extern int daemon(int, int);
+#endif
+
+
 typedef RETSIGTYPE (*mu_sig_handler_t) (int);
 
 static mu_sig_handler_t
--- a/mh/send.c
+++ b/mh/send.c
@@ -19,12 +19,30 @@
 
 /* MH send command */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined __APPLE__ && defined __MACH__
+/**
+   * On Mac OS X 10.5 and later, stdlib.h warns that the daemon() function 
+   * is deprecated in favor of using launchd. For portable code, we still 
+   * want to use daemon(). Use this to trick the macro.
+   */
+#define daemon deprecated
+#endif
+
 #include <mh.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <pwd.h>
 
+#if defined __APPLE__ && defined __MACH__
+#undef daemon
+extern int daemon(int, int);
+#endif
+
 const char *program_version = "send (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH send")"\v"
 N_("Options marked with `*' are not yet implemented.\n\

From 23a4dcd9f6d1a83dfefe53a79b34b606f7f47767 Mon Sep 17 00:00:00 2001
From: Jonathan Creekmore <address@hidden>
Date: Tue, 26 Apr 2011 21:36:20 -0500
Subject: [PATCH 2/5] 64-bit warning cleanup. An off_t is not the same as a 
mu_off_t (per configure.ac for library reasons). However, the configure script 
confirms that they are the same size, so the cast should be ok.

---
 libproto/mbox/mboxscan.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libproto/mbox/mboxscan.c b/libproto/mbox/mboxscan.c
index 44eacfe..09e156b 100644
--- a/libproto/mbox/mboxscan.c
+++ b/libproto/mbox/mboxscan.c
@@ -428,6 +428,7 @@ mbox_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t 
*pcount, int do_notif)
   mbox_message_t mum = NULL;
   mu_off_t total = 0;
   size_t min_uid;
+  mu_off_t size;
   
   /* Sanity.  */
   if (mud == NULL)
@@ -443,12 +444,13 @@ mbox_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t 
*pcount, int do_notif)
 #endif
 
   /* Save the timestamp and size.  */
-  status = mu_stream_size (mailbox->stream, &mud->size);
+  status = mu_stream_size (mailbox->stream, &size);
   if (status != 0)
     {
       mu_monitor_unlock (mailbox->monitor);
       return status;
     }
+  mud->size = (off_t)size;
 
   if ((status = mu_locker_lock (mailbox->locker)))
     {
-- 
1.7.4.1

From aee42dc0b5f3072d0c717e40248b391e7065a614 Mon Sep 17 00:00:00 2001
From: Jonathan Creekmore <address@hidden>
Date: Tue, 26 Apr 2011 21:44:09 -0500
Subject: [PATCH 3/5] Patch format string vulnerabilities.

---
 libproto/nntp/nntp_sendline.c |    2 +-
 libproto/pop/pop3_sendline.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libproto/nntp/nntp_sendline.c b/libproto/nntp/nntp_sendline.c
index 86db395..6484906 100644
--- a/libproto/nntp/nntp_sendline.c
+++ b/libproto/nntp/nntp_sendline.c
@@ -112,7 +112,7 @@ mu_nntp_sendline (mu_nntp_t nntp, const char *line)
 {
   if (line)
     {
-      int status = mu_nntp_writeline (nntp, line);
+      int status = mu_nntp_writeline (nntp, "%s", line);
       if (status)
        return status;
     }
diff --git a/libproto/pop/pop3_sendline.c b/libproto/pop/pop3_sendline.c
index 54c1cac..24b6e23 100644
--- a/libproto/pop/pop3_sendline.c
+++ b/libproto/pop/pop3_sendline.c
@@ -112,7 +112,7 @@ mu_pop3_sendline (mu_pop3_t pop3, const char *line)
 {
   if (line)
     {
-      int status = mu_pop3_writeline (pop3, line);
+      int status = mu_pop3_writeline (pop3, "%s", line);
       if (status)
        return status;
     }
-- 
1.7.4.1

From 0a0bbfd72656636fc23612caf313756cc130df82 Mon Sep 17 00:00:00 2001
From: Jonathan Creekmore <address@hidden>
Date: Tue, 26 Apr 2011 23:44:21 -0500
Subject: [PATCH 4/5] More 64-bit changes.

---
 am/utmp.m4               |    4 +++-
 libproto/maildir/mbox.c  |    2 +-
 mailbox/mapfile_stream.c |    2 +-
 mailbox/socket_stream.c  |    2 +-
 mailbox/tcp.c            |    2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/am/utmp.m4 b/am/utmp.m4
index ce9406a..b16ee03 100644
--- a/am/utmp.m4
+++ b/am/utmp.m4
@@ -11,4 +11,6 @@ AC_DEFUN([MU_CHECK_UTMP],
          [Define if your system has the three ???utent functions]),
                  [if test "$ac_cv_header_utmp_h" = "yes"; then
                   AC_LIBOBJ([utmp])
-                fi])])
+                fi])
+  AM_CONDITIONAL(HAVE_GETUTENT_CALLS, test "$ac_cv_header_utmp_h" = "yes")
+])
diff --git a/libproto/maildir/mbox.c b/libproto/maildir/mbox.c
index c9d7470..1fa9497 100644
--- a/libproto/maildir/mbox.c
+++ b/libproto/maildir/mbox.c
@@ -321,7 +321,7 @@ maildir_uniq (struct _amd_data *amd, int fd)
       PFX ('V', "%lX", (unsigned long) st.st_dev);
     }
 
-  PFX ('M', "%lu", tv.tv_usec);
+  PFX ('M', "%lu", (long int)tv.tv_usec);
   PFX ('P', "%lu", (unsigned long) getpid ());
   PFX ('Q', "%lu", (unsigned long) amd->msg_count);
   PFX ('.', "%s", hostname);
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index e70d701..4c7e7aa 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -246,7 +246,7 @@ _mapfile_get_transport2 (mu_stream_t stream, mu_transport_t 
*pin, mu_transport_t
     *pout = NULL;
   
   if (pin)
-    *pin = (mu_transport_t) mfs->fd;
+    *pin = (mu_transport_t)(unsigned long) mfs->fd;
   return 0;
 }
 
diff --git a/mailbox/socket_stream.c b/mailbox/socket_stream.c
index a28a447..33e158a 100644
--- a/mailbox/socket_stream.c
+++ b/mailbox/socket_stream.c
@@ -193,7 +193,7 @@ _s_shutdown (mu_stream_t stream, int how)
       flag = SHUT_WR;
     }
 
-  if (shutdown ((int) trans, flag))
+  if (shutdown ((int)(unsigned long) trans, flag))
     return errno;
   return 0;
 }
diff --git a/mailbox/tcp.c b/mailbox/tcp.c
index 4d36648..1047d73 100644
--- a/mailbox/tcp.c
+++ b/mailbox/tcp.c
@@ -197,7 +197,7 @@ _tcp_get_transport2 (mu_stream_t stream, mu_transport_t *tr,
     return EINVAL;
 
   if (tr)
-    *tr = (mu_transport_t) tcp->fd;
+    *tr = (mu_transport_t)(unsigned long) tcp->fd;
   if (tr2)
     *tr2 = NULL;
   return 0;
-- 
1.7.4.1

From bdfd51595b70fae3460a00ab1fd0e0ab0425d46f Mon Sep 17 00:00:00 2001
From: Jonathan Creekmore <address@hidden>
Date: Wed, 27 Apr 2011 15:33:30 -0500
Subject: [PATCH 5/5] Multiple warnings to cleanup.

---
 comsat/comsat.c                   |    4 ++--
 imap4d/append.c                   |    2 +-
 imap4d/close.c                    |    2 +-
 imap4d/create.c                   |    2 +-
 imap4d/delete.c                   |    2 +-
 imap4d/rename.c                   |    2 +-
 imap4d/status.c                   |    2 +-
 imap4d/util.c                     |    2 +-
 lib/mailcap.c                     |    2 +-
 libmu_scm/mu_dbgport.c            |    2 +-
 libmu_scm/mu_mailbox.c            |    2 +-
 libmu_scm/mu_port.c               |   10 +++++-----
 libmu_sieve/extensions/vacation.c |    2 +-
 maidag/maidag.c                   |    2 +-
 mail/quit.c                       |    4 ++--
 mail/retain.c                     |    2 +-
 mail/summary.c                    |    2 +-
 mail/unset.c                      |    2 +-
 mh/mhn.c                          |    7 ++-----
 mh/send.c                         |   18 ++++++++++++++++++
 20 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/comsat/comsat.c b/comsat/comsat.c
index 82e8056..0027ee0 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -368,8 +368,8 @@ comsat_connection (int fd, struct sockaddr *sa, int salen,
     {
       char *p = mu_sockaddr_to_astr (sa, salen);
       mu_diag_output (MU_DIAG_INFO,
-                     ngettext ("received %d byte from %s",
-                               "received %d bytes from %s", rdlen),
+                     ngettext ("received %zu byte from %s",
+                               "received %zu bytes from %s", rdlen),
                      rdlen, p);
       mu_diag_output (MU_DIAG_INFO, "string: %s", buffer);
       free (p);
diff --git a/imap4d/append.c b/imap4d/append.c
index f6662aa..91ac721 100644
--- a/imap4d/append.c
+++ b/imap4d/append.c
@@ -204,7 +204,7 @@ imap4d_append (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
   if (status == 0)
     return util_finish (command, RESP_OK, "Completed");
 
-  return util_finish (command, RESP_NO, err_text);
+  return util_finish (command, RESP_NO, "%s", err_text);
 }
 
 
diff --git a/imap4d/close.c b/imap4d/close.c
index 732e849..e1450ce 100644
--- a/imap4d/close.c
+++ b/imap4d/close.c
@@ -51,7 +51,7 @@ imap4d_close0 (struct imap4d_command *command, 
imap4d_tokbuf_t tok,
   mu_mailbox_destroy (&mbox);
 
   if (msg)
-    return util_finish (command, RESP_NO, msg);
+    return util_finish (command, RESP_NO, "%s", msg);
   return util_finish (command, RESP_OK, "Completed");
 }
 
diff --git a/imap4d/create.c b/imap4d/create.c
index 0768d9f..29b6e3a 100644
--- a/imap4d/create.c
+++ b/imap4d/create.c
@@ -165,5 +165,5 @@ imap4d_create (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
       msg = "already exists";
     }
 
-  return util_finish (command, rc, msg);
+  return util_finish (command, rc, "%s", msg);
 }
diff --git a/imap4d/delete.c b/imap4d/delete.c
index b6f4f90..8adae0e 100644
--- a/imap4d/delete.c
+++ b/imap4d/delete.c
@@ -59,5 +59,5 @@ imap4d_delete (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
       rc = RESP_NO;
       msg = "Cannot remove";
     }
-  return util_finish (command, rc, msg);
+  return util_finish (command, rc, "%s", msg);
 }
diff --git a/imap4d/rename.c b/imap4d/rename.c
index 97cfa41..3400273 100644
--- a/imap4d/rename.c
+++ b/imap4d/rename.c
@@ -135,5 +135,5 @@ imap4d_rename (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
   if (oldname)
     free (oldname);
   free (newname);
-  return util_finish (command, rc, msg);
+  return util_finish (command, rc, "%s", msg);
 }
diff --git a/imap4d/status.c b/imap4d/status.c
index 3933a79..08bfd6d 100644
--- a/imap4d/status.c
+++ b/imap4d/status.c
@@ -148,7 +148,7 @@ imap4d_status (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
       if (count == 0)
        return util_finish (command, RESP_BAD, "Too few args (empty list)");
       else if (err_msg)
-       return util_finish (command, RESP_BAD, err_msg);
+       return util_finish (command, RESP_BAD, "%s", err_msg);
       return util_finish (command, RESP_OK, "Completed");
     }
   
diff --git a/imap4d/util.c b/imap4d/util.c
index d697a33..62e26cf 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -649,7 +649,7 @@ util_print_flags (mu_attribute_t attr)
          util_send (" ");
        else
          space = 1;
-       util_send (_imap4d_attrlist[i].name);
+       util_send ("%s", _imap4d_attrlist[i].name);
       }
 
   if (MU_ATTRIBUTE_IS_UNSEEN (flags))
diff --git a/lib/mailcap.c b/lib/mailcap.c
index 88eab36..3fe792f 100644
--- a/lib/mailcap.c
+++ b/lib/mailcap.c
@@ -375,7 +375,7 @@ dump_mailcap_entry (mu_mailcap_entry_t entry)
                    mu_strerror (status));
          break;
        }
-      printf ("fields[%d]: %s\n", i, buffer);
+      printf ("fields[%zu]: %s\n", i, buffer);
     }
   printf ("\n");
 }
diff --git a/libmu_scm/mu_dbgport.c b/libmu_scm/mu_dbgport.c
index f118cb4..0757db3 100644
--- a/libmu_scm/mu_dbgport.c
+++ b/libmu_scm/mu_dbgport.c
@@ -95,7 +95,7 @@ _mu_debug_port_write (SCM port, const void *data, size_t size)
 {
   struct _mu_debug_port *dp = MU_DEBUG_PORT (port);
 
-  mu_debug_printf (dp->debug, dp->level, "%.*s", size, (const char *)data);
+  mu_debug_printf (dp->debug, dp->level, "%.*s", (int)size, (const char 
*)data);
 }
 
 static int
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 90ee4da..a1516f6 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -82,7 +82,7 @@ mu_scm_mailbox_print (SCM mailbox_smob, SCM port, 
scm_print_state * pstate)
          
          scm_puts (p, port);
          
-         snprintf (buf, sizeof (buf), " (%d)", count);
+         snprintf (buf, sizeof (buf), " (%zu)", count);
          scm_puts (buf, port);
        }
       else
diff --git a/libmu_scm/mu_port.c b/libmu_scm/mu_port.c
index 6f3e452..d83e773 100644
--- a/libmu_scm/mu_port.c
+++ b/libmu_scm/mu_port.c
@@ -220,8 +220,8 @@ mu_port_end_input (SCM port, int offset)
   pt->rw_active = SCM_PORT_NEITHER;
 }
 
-static mu_off_t
-mu_port_seek (SCM port, mu_off_t offset, int whence)
+static off_t
+mu_port_seek (SCM port, off_t offset, int whence)
 {
   struct mu_port *mp = MU_PORT (port);
   scm_port *pt = SCM_PTAB_ENTRY (port);
@@ -253,16 +253,16 @@ mu_port_seek (SCM port, mu_off_t offset, int whence)
 
   if (offset > size)
     return -1;
-  mp->offset = offset;
+  mp->offset = (mu_off_t)offset;
   return offset;
 }
 
 static void
-mu_port_truncate (SCM port, mu_off_t length)
+mu_port_truncate (SCM port, off_t length)
 {
   struct mu_port *mp = MU_PORT (port);
   int status;
-  status = mu_stream_truncate (mp->stream, length);
+  status = mu_stream_truncate (mp->stream, (mu_off_t)length);
   if (status)
     mu_scm_error ("mu_stream_truncate", status,
                  "Error truncating stream", SCM_BOOL_F);
diff --git a/libmu_sieve/extensions/vacation.c 
b/libmu_sieve/extensions/vacation.c
index a2debf5..3dfb5c7 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -347,7 +347,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char 
*from)
   mu_sieve_error (mach,
               /* TRANSLATORS: 'vacation' and ':days' are Sieve keywords.
                  Do not translate them! */
-              _("%d: vacation compiled without DBM support. Ignoring :days 
tag"),
+              _("%zu: vacation compiled without DBM support. Ignoring :days 
tag"),
               mu_sieve_get_message_num (mach));
   return 0;
 #endif
diff --git a/maidag/maidag.c b/maidag/maidag.c
index ea04f07..d65cd75 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -293,7 +293,7 @@ cb2_group (mu_debug_t debug, const char *gname, void *data)
   if (!group)
     mu_cfg_format_error (debug, MU_DEBUG_ERROR, _("unknown group: %s"), gname);
   else
-    mu_list_append (*plist, (void*)group->gr_gid);
+    mu_list_append (*plist, (void*)(unsigned long)group->gr_gid);
   return 0;
 }
   
diff --git a/mail/quit.c b/mail/quit.c
index 4efeaf4..c12ea16 100644
--- a/mail/quit.c
+++ b/mail/quit.c
@@ -52,8 +52,8 @@ mail_mbox_close ()
   mu_mailbox_get_url (mbox, &url);
   mu_mailbox_messages_count (mbox, &held_count);
   fprintf (ofile, 
-           ngettext ("Held %d message in %s\n",
-                     "Held %d messages in %s\n",
+           ngettext ("Held %zu message in %s\n",
+                     "Held %zu messages in %s\n",
                      held_count),
            held_count, util_url_to_string (url));
   mu_mailbox_close (mbox);
diff --git a/mail/retain.c b/mail/retain.c
index 07656aa..0fa6178 100644
--- a/mail/retain.c
+++ b/mail/retain.c
@@ -33,7 +33,7 @@ process_list (int argc, char **argv,
   if (argc == 1)
     {
       if (mu_list_is_empty (*list))
-       fprintf (ofile, _(msg));
+       fprintf (ofile, "%s", _(msg));
       else
        util_slist_print (*list, 1);
       return 0;
diff --git a/mail/summary.c b/mail/summary.c
index 4e7721b..62e5f67 100644
--- a/mail/summary.c
+++ b/mail/summary.c
@@ -64,7 +64,7 @@ mail_summary (int argc MU_ARG_UNUSED, char **argv 
MU_ARG_UNUSED)
     mu_mailbox_get_url (mbox, &url);
     printf("\"%s\": ", util_url_to_string (url));
   }
-  printf (ngettext ("%d message", "%d messages", count), count);
+  printf (ngettext ("%zu message", "%zu messages", count), count);
   if (mnew > 0)
     printf (ngettext (" %d new", " %d new", mnew), mnew);
   if (mseen > 0)
diff --git a/mail/unset.c b/mail/unset.c
index cbc6118..291ee97 100644
--- a/mail/unset.c
+++ b/mail/unset.c
@@ -38,7 +38,7 @@ mail_unset (int argc, char **argv)
          char *buf = xmalloc ((7+strlen (argv[i])) * sizeof (char));
          strcpy (buf, "set no");
          strcat (buf, argv[i]);
-         if (!util_do_command (buf))
+         if (!util_do_command ("%s", buf))
            status = 1;
          free (buf);
        }
diff --git a/mh/mhn.c b/mh/mhn.c
index b764e97..490b140 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1388,7 +1388,7 @@ show_handler (mu_message_t msg, msg_part_t part, char 
*type, char *encoding,
     return 0;
 
   mu_stream_get_transport (out, &trans);
-  fd = (int) trans; /* FIXME */
+  fd = (int)(unsigned long) trans; /* FIXME */
 
   if (mode_options & OPT_PAUSE)
     flags |= MHN_CONFIRM;
@@ -1640,13 +1640,9 @@ store_handler (mu_message_t msg, msg_part_t part, char 
*type, char *encoding,
 
   if (!(mode_options & OPT_QUIET) && access (name, R_OK) == 0)
     {
-      char *p;
       int rc;
        
-      asprintf (&p, _("File %s already exists. Rewrite"), name);
-      rc = mh_getyn (p);
-      free (p);
+      rc = mh_getyn (_("File %s already exists. Rewrite"), name);
       if (!rc)
        {
          free (name);
-- 
1.7.4.1

-- 
Jonathan Creekmore
address@hidden

Attachment: pgpfNbA2Ay5ip.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]