changeset: 6469:8c16206f50a1
user:      Kevin McCarthy <[email protected]>
date:      Thu Jul 23 14:57:04 2015 -0700
link:      http://dev.mutt.org/hg/mutt/rev/8c16206f50a1

Fix compiler type warnings. (closes #3765)

The output of mutt_local_tz() was being passed to abs().  Technically
the return type is time_t, but it represents a small value: the timezone
offset in seconds.  Add a safe explicit cast to int.

Change the txt parameter of mutt_make_help() to type const char *.
Typically all calls run the txt parameter through _(), which
accepts const char * and returns a char *. However, if NLS is not
enabled, _() is a noop, simply returning the parameter itself.  In
mutt_compile_help(), items[i].name is const char *, so it will generate
a warning when passed as the txt parameter of mutt_make_help().

On some systems, e.g. OS X, snprintf is defined as a macro.  One call
in hcache.c was embedding directives inside the snprintf call.  This is
apparently undefined behavior, so duplicate the call instead.

diffs (89 lines):

diff -r c60fed102d79 -r 8c16206f50a1 hcache.c
--- a/hcache.c  Wed Jul 22 19:23:12 2015 -0700
+++ b/hcache.c  Thu Jul 23 14:57:04 2015 -0700
@@ -550,21 +550,33 @@
   {
     md5_buffer (folder, strlen (folder), &md5sum);
 
+    /* On some systems (e.g. OS X), snprintf is defined as a macro.
+     * Embedding directives inside macros is undefined, so we have to duplicate
+     * the whole call:
+     */
+#ifndef HAVE_ICONV
     ret = snprintf(hcpath, _POSIX_PATH_MAX,
                    "%s/%02x%02x%02x%02x%02x%02x%02x%02x"
                    "%02x%02x%02x%02x%02x%02x%02x%02x"
-#ifndef HAVE_ICONV
                   "-%s"
-#endif
                   ,
                   path, md5sum[0], md5sum[1], md5sum[2], md5sum[3],
                    md5sum[4], md5sum[5], md5sum[6], md5sum[7], md5sum[8],
                    md5sum[9], md5sum[10], md5sum[11], md5sum[12],
                    md5sum[13], md5sum[14], md5sum[15]
-#ifndef HAVE_ICONV
                   ,chs
+                  );
+#else
+    ret = snprintf(hcpath, _POSIX_PATH_MAX,
+                   "%s/%02x%02x%02x%02x%02x%02x%02x%02x"
+                   "%02x%02x%02x%02x%02x%02x%02x%02x"
+                  ,
+                  path, md5sum[0], md5sum[1], md5sum[2], md5sum[3],
+                   md5sum[4], md5sum[5], md5sum[6], md5sum[7], md5sum[8],
+                   md5sum[9], md5sum[10], md5sum[11], md5sum[12],
+                   md5sum[13], md5sum[14], md5sum[15]
+                  );
 #endif
-                  );
   }
   
   if (ret <= 0)
diff -r c60fed102d79 -r 8c16206f50a1 help.c
--- a/help.c    Wed Jul 22 19:23:12 2015 -0700
+++ b/help.c    Thu Jul 23 14:57:04 2015 -0700
@@ -54,7 +54,7 @@
   return (NULL);
 }
 
-void mutt_make_help (char *d, size_t dlen, char *txt, int menu, int op)
+void mutt_make_help (char *d, size_t dlen, const char *txt, int menu, int op)
 {
   char buf[SHORT_STRING];
 
diff -r c60fed102d79 -r 8c16206f50a1 imap/util.c
--- a/imap/util.c       Wed Jul 22 19:23:12 2015 -0700
+++ b/imap/util.c       Thu Jul 23 14:57:04 2015 -0700
@@ -591,7 +591,7 @@
   snprintf (buf, IMAP_DATELEN, "%02d-%s-%d %02d:%02d:%02d %+03d%02d",
       tm->tm_mday, Months[tm->tm_mon], tm->tm_year + 1900,
       tm->tm_hour, tm->tm_min, tm->tm_sec,
-      (int) tz / 60, (int) abs (tz) % 60);
+      (int) tz / 60, (int) abs ((int) tz) % 60);
 }
 
 /* imap_qualify_path: make an absolute IMAP folder target, given IMAP_MBOX
diff -r c60fed102d79 -r 8c16206f50a1 protos.h
--- a/protos.h  Wed Jul 22 19:23:12 2015 -0700
+++ b/protos.h  Thu Jul 23 14:57:04 2015 -0700
@@ -213,7 +213,7 @@
 void mutt_check_lookup_list (BODY *, char *, int);
 void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out);
 void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur);
-void mutt_make_help (char *, size_t, char *, int, int);
+void mutt_make_help (char *, size_t, const char *, int, int);
 void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, 
ENVELOPE *curenv);
 void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out);
 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra);
diff -r c60fed102d79 -r 8c16206f50a1 sendlib.c
--- a/sendlib.c Wed Jul 22 19:23:12 2015 -0700
+++ b/sendlib.c Thu Jul 23 14:57:04 2015 -0700
@@ -1486,7 +1486,7 @@
   snprintf (s, len,  "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
            Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon],
            l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec,
-           (int) tz / 60, (int) abs (tz) % 60);
+           (int) tz / 60, (int) abs ((int) tz) % 60);
   return (s);
 }
 

Reply via email to