aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-04-06 20:34:05 -0700
committerPaul Eggert2011-04-06 20:34:05 -0700
commit5fdb398c4b75b0c834aff7132f90b0ce5317a25a (patch)
tree29ebb8fc5700fefdd867fa497eac27fb7d0bcfe0
parentb189fa667ed7ac7b17f9665cd8a0c26316b3c521 (diff)
downloademacs-5fdb398c4b75b0c834aff7132f90b0ce5317a25a.tar.gz
emacs-5fdb398c4b75b0c834aff7132f90b0ce5317a25a.zip
error: Print 32- and 64-bit integers portably (Bug#8435).
Without this change, on typical 64-bit hosts error ("...%d...", N) was used to print both 32- and 64-bit integers N, which relied on undefined behavior. * lisp.h, src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h (pEd): New macro. * lisp.h (error, verror): Mark as printf-like functions. * eval.c (verror): Use vsnprintf, not doprnt, to do the real work. Report overflow in size calculations when allocating printf buffer. Do not truncate output string at its first null byte. * xdisp.c (vmessage): Use vsnprintf, not doprnt, to do the real work. Truncate the output at a character boundary, since vsnprintf does not do that. * charset.c (check_iso_charset_parameter): Convert internal character to string before calling 'error', since %c now has the printf meaning. * coding.c (Fdecode_sjis_char, Fdecode_big5_char): Avoid int overflow when computing char to be passed to 'error'. Do not pass Lisp_Object to 'error'; pass the integer instead. * nsfns.m (Fns_do_applescript): Use int, not long, since it's formatted with plain %d.
-rw-r--r--src/ChangeLog22
-rw-r--r--src/category.c4
-rw-r--r--src/charset.c18
-rw-r--r--src/coding.c53
-rw-r--r--src/doc.c4
-rw-r--r--src/eval.c21
-rw-r--r--src/fns.c2
-rw-r--r--src/intervals.c2
-rw-r--r--src/lisp.h7
-rw-r--r--src/m/amdx86-64.h1
-rw-r--r--src/m/ia64.h1
-rw-r--r--src/m/ibms390x.h2
-rw-r--r--src/nsfns.m15
-rw-r--r--src/sysdep.c3
-rw-r--r--src/window.c4
-rw-r--r--src/xdisp.c16
-rw-r--r--src/xfns.c2
17 files changed, 117 insertions, 60 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6f2509429d2..c1bea6b4cc7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,27 @@
12011-04-07 Paul Eggert <eggert@cs.ucla.edu> 12011-04-07 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 error: Print 32- and 64-bit integers portably (Bug#8435).
4 Without this change, on typical 64-bit hosts error ("...%d...", N)
5 was used to print both 32- and 64-bit integers N, which relied on
6 undefined behavior.
7 * lisp.h, src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h (pEd):
8 New macro.
9 * lisp.h (error, verror): Mark as printf-like functions.
10 * eval.c (verror): Use vsnprintf, not doprnt, to do the real work.
11 Report overflow in size calculations when allocating printf buffer.
12 Do not truncate output string at its first null byte.
13 * xdisp.c (vmessage): Use vsnprintf, not doprnt, to do the real work.
14 Truncate the output at a character boundary, since vsnprintf does not
15 do that.
16 * charset.c (check_iso_charset_parameter): Convert internal
17 character to string before calling 'error', since %c now has the
18 printf meaning.
19 * coding.c (Fdecode_sjis_char, Fdecode_big5_char): Avoid int
20 overflow when computing char to be passed to 'error'. Do not
21 pass Lisp_Object to 'error'; pass the integer instead.
22 * nsfns.m (Fns_do_applescript): Use int, not long, since it's
23 formatted with plain %d.
24
3 * eval.c (internal_lisp_condition_case): Don't pass spurious arg. 25 * eval.c (internal_lisp_condition_case): Don't pass spurious arg.
4 26
5 * keyboard.c (access_keymap_keyremap): Print func name, not garbage. 27 * keyboard.c (access_keymap_keyremap): Print func name, not garbage.
diff --git a/src/category.c b/src/category.c
index cc7ff88474f..bba030360c4 100644
--- a/src/category.c
+++ b/src/category.c
@@ -128,7 +128,7 @@ the current buffer's category table. */)
128 table = check_category_table (table); 128 table = check_category_table (table);
129 129
130 if (!NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) 130 if (!NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
131 error ("Category `%c' is already defined", XFASTINT (category)); 131 error ("Category `%c' is already defined", (int) XFASTINT (category));
132 if (!NILP (Vpurify_flag)) 132 if (!NILP (Vpurify_flag))
133 docstring = Fpurecopy (docstring); 133 docstring = Fpurecopy (docstring);
134 CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring; 134 CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring;
@@ -373,7 +373,7 @@ then delete CATEGORY from the category set instead of adding it. */)
373 table = check_category_table (table); 373 table = check_category_table (table);
374 374
375 if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category)))) 375 if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
376 error ("Undefined category: %c", XFASTINT (category)); 376 error ("Undefined category: %c", (int) XFASTINT (category));
377 377
378 set_value = NILP (reset) ? Qt : Qnil; 378 set_value = NILP (reset) ? Qt : Qnil;
379 379
diff --git a/src/charset.c b/src/charset.c
index 32836d459f3..55cbfc4a399 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -493,7 +493,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co
493 unbind_to (count, Qnil); 493 unbind_to (count, Qnil);
494 if (fd < 0 494 if (fd < 0
495 || ! (fp = fdopen (fd, "r"))) 495 || ! (fp = fdopen (fd, "r")))
496 error ("Failure in loading charset map: %S", SDATA (mapfile)); 496 error ("Failure in loading charset map: %s", SDATA (mapfile));
497 497
498 /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is 498 /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
499 large (larger than MAX_ALLOCA). */ 499 large (larger than MAX_ALLOCA). */
@@ -1000,7 +1000,7 @@ usage: (define-charset-internal ...) */)
1000 { 1000 {
1001 CHECK_NUMBER (val); 1001 CHECK_NUMBER (val);
1002 if (XINT (val) < '0' || XINT (val) > 127) 1002 if (XINT (val) < '0' || XINT (val) > 127)
1003 error ("Invalid iso-final-char: %d", XINT (val)); 1003 error ("Invalid iso-final-char: %"pEd, XINT (val));
1004 charset.iso_final = XINT (val); 1004 charset.iso_final = XINT (val);
1005 } 1005 }
1006 1006
@@ -1022,7 +1022,7 @@ usage: (define-charset-internal ...) */)
1022 { 1022 {
1023 CHECK_NATNUM (val); 1023 CHECK_NATNUM (val);
1024 if ((XINT (val) > 0 && XINT (val) <= 128) || XINT (val) >= 256) 1024 if ((XINT (val) > 0 && XINT (val) <= 128) || XINT (val) >= 256)
1025 error ("Invalid emacs-mule-id: %d", XINT (val)); 1025 error ("Invalid emacs-mule-id: %"pEd, XINT (val));
1026 charset.emacs_mule_id = XINT (val); 1026 charset.emacs_mule_id = XINT (val);
1027 } 1027 }
1028 1028
@@ -1440,11 +1440,17 @@ check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Obje
1440 CHECK_NATNUM (final_char); 1440 CHECK_NATNUM (final_char);
1441 1441
1442 if (XINT (dimension) > 3) 1442 if (XINT (dimension) > 3)
1443 error ("Invalid DIMENSION %d, it should be 1, 2, or 3", XINT (dimension)); 1443 error ("Invalid DIMENSION %"pEd", it should be 1, 2, or 3",
1444 XINT (dimension));
1444 if (XINT (chars) != 94 && XINT (chars) != 96) 1445 if (XINT (chars) != 94 && XINT (chars) != 96)
1445 error ("Invalid CHARS %d, it should be 94 or 96", XINT (chars)); 1446 error ("Invalid CHARS %"pEd", it should be 94 or 96", XINT (chars));
1446 if (XINT (final_char) < '0' || XINT (final_char) > '~') 1447 if (XINT (final_char) < '0' || XINT (final_char) > '~')
1447 error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", XINT (chars)); 1448 {
1449 unsigned char str[MAX_MULTIBYTE_LENGTH + 1];
1450 int len = CHAR_STRING (XINT (chars), str);
1451 str[len] = '\0';
1452 error ("Invalid FINAL-CHAR %s, it should be `0'..`~'", str);
1453 }
1448} 1454}
1449 1455
1450 1456
diff --git a/src/coding.c b/src/coding.c
index 798e5c533f6..f099605c774 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9023,14 +9023,15 @@ Return the corresponding character. */)
9023{ 9023{
9024 Lisp_Object spec, attrs, val; 9024 Lisp_Object spec, attrs, val;
9025 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; 9025 struct charset *charset_roman, *charset_kanji, *charset_kana, *charset;
9026 EMACS_INT c; 9026 EMACS_INT ch;
9027 int c;
9027 9028
9028 CHECK_NATNUM (code); 9029 CHECK_NATNUM (code);
9029 c = XFASTINT (code); 9030 ch = XFASTINT (code);
9030 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); 9031 CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec);
9031 attrs = AREF (spec, 0); 9032 attrs = AREF (spec, 0);
9032 9033
9033 if (ASCII_BYTE_P (c) 9034 if (ASCII_BYTE_P (ch)
9034 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) 9035 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)))
9035 return code; 9036 return code;
9036 9037
@@ -9039,27 +9040,31 @@ Return the corresponding character. */)
9039 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); 9040 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
9040 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); 9041 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val)));
9041 9042
9042 if (c <= 0x7F) 9043 if (ch <= 0x7F)
9043 charset = charset_roman; 9044 {
9044 else if (c >= 0xA0 && c < 0xDF) 9045 c = ch;
9046 charset = charset_roman;
9047 }
9048 else if (ch >= 0xA0 && ch < 0xDF)
9045 { 9049 {
9050 c = ch - 0x80;
9046 charset = charset_kana; 9051 charset = charset_kana;
9047 c -= 0x80;
9048 } 9052 }
9049 else 9053 else
9050 { 9054 {
9051 EMACS_INT c1 = c >> 8; 9055 EMACS_INT c1 = ch >> 8;
9052 int c2 = c & 0xFF; 9056 int c2 = ch & 0xFF;
9053 9057
9054 if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF 9058 if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
9055 || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) 9059 || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
9056 error ("Invalid code: %d", code); 9060 error ("Invalid code: %"pEd, ch);
9061 c = ch;
9057 SJIS_TO_JIS (c); 9062 SJIS_TO_JIS (c);
9058 charset = charset_kanji; 9063 charset = charset_kanji;
9059 } 9064 }
9060 c = DECODE_CHAR (charset, c); 9065 c = DECODE_CHAR (charset, c);
9061 if (c < 0) 9066 if (c < 0)
9062 error ("Invalid code: %d", code); 9067 error ("Invalid code: %"pEd, ch);
9063 return make_number (c); 9068 return make_number (c);
9064} 9069}
9065 9070
@@ -9099,14 +9104,15 @@ Return the corresponding character. */)
9099{ 9104{
9100 Lisp_Object spec, attrs, val; 9105 Lisp_Object spec, attrs, val;
9101 struct charset *charset_roman, *charset_big5, *charset; 9106 struct charset *charset_roman, *charset_big5, *charset;
9107 EMACS_INT ch;
9102 int c; 9108 int c;
9103 9109
9104 CHECK_NATNUM (code); 9110 CHECK_NATNUM (code);
9105 c = XFASTINT (code); 9111 ch = XFASTINT (code);
9106 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); 9112 CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec);
9107 attrs = AREF (spec, 0); 9113 attrs = AREF (spec, 0);
9108 9114
9109 if (ASCII_BYTE_P (c) 9115 if (ASCII_BYTE_P (ch)
9110 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) 9116 && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)))
9111 return code; 9117 return code;
9112 9118
@@ -9114,19 +9120,24 @@ Return the corresponding character. */)
9114 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); 9120 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
9115 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); 9121 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
9116 9122
9117 if (c <= 0x7F) 9123 if (ch <= 0x7F)
9118 charset = charset_roman; 9124 {
9125 c = ch;
9126 charset = charset_roman;
9127 }
9119 else 9128 else
9120 { 9129 {
9121 int b1 = c >> 8, b2 = c & 0x7F; 9130 EMACS_INT b1 = ch >> 8;
9131 int b2 = ch & 0x7F;
9122 if (b1 < 0xA1 || b1 > 0xFE 9132 if (b1 < 0xA1 || b1 > 0xFE
9123 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) 9133 || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE)
9124 error ("Invalid code: %d", code); 9134 error ("Invalid code: %"pEd, ch);
9135 c = ch;
9125 charset = charset_big5; 9136 charset = charset_big5;
9126 } 9137 }
9127 c = DECODE_CHAR (charset, (unsigned )c); 9138 c = DECODE_CHAR (charset, c);
9128 if (c < 0) 9139 if (c < 0)
9129 error ("Invalid code: %d", code); 9140 error ("Invalid code: %"pEd, ch);
9130 return make_number (c); 9141 return make_number (c);
9131} 9142}
9132 9143
@@ -9298,7 +9309,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
9298 || (EQ (operation, Qinsert_file_contents) && CONSP (target) 9309 || (EQ (operation, Qinsert_file_contents) && CONSP (target)
9299 && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) 9310 && STRINGP (XCAR (target)) && BUFFERP (XCDR (target)))
9300 || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) 9311 || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
9301 error ("Invalid %dth argument", XFASTINT (target_idx) + 1); 9312 error ("Invalid %"pEd"th argument", XFASTINT (target_idx) + 1);
9302 if (CONSP (target)) 9313 if (CONSP (target))
9303 target = XCAR (target); 9314 target = XCAR (target);
9304 9315
@@ -9774,7 +9785,7 @@ usage: (define-coding-system-internal ...) */)
9774 CHECK_CHARSET_GET_ID (tmp1, id); 9785 CHECK_CHARSET_GET_ID (tmp1, id);
9775 CHECK_NATNUM_CDR (val); 9786 CHECK_NATNUM_CDR (val);
9776 if (XINT (XCDR (val)) >= 4) 9787 if (XINT (XCDR (val)) >= 4)
9777 error ("Invalid graphic register number: %d", XINT (XCDR (val))); 9788 error ("Invalid graphic register number: %"pEd, XINT (XCDR (val)));
9778 XSETCAR (val, make_number (id)); 9789 XSETCAR (val, make_number (id));
9779 } 9790 }
9780 9791
diff --git a/src/doc.c b/src/doc.c
index 158b09790f7..ed0d2323ed5 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -154,7 +154,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
154 if (0 > lseek (fd, position - offset, 0)) 154 if (0 > lseek (fd, position - offset, 0))
155 { 155 {
156 emacs_close (fd); 156 emacs_close (fd);
157 error ("Position %ld out of range in doc string file \"%s\"", 157 error ("Position %"pEd" out of range in doc string file \"%s\"",
158 position, name); 158 position, name);
159 } 159 }
160 160
@@ -669,7 +669,7 @@ the same file name is found in the `doc-directory'. */)
669 ; /* Just a source file name boundary marker. Ignore it. */ 669 ; /* Just a source file name boundary marker. Ignore it. */
670 670
671 else 671 else
672 error ("DOC file invalid at position %d", pos); 672 error ("DOC file invalid at position %"pEd, pos);
673 } 673 }
674 } 674 }
675 pos += end - buf; 675 pos += end - buf;
diff --git a/src/eval.c b/src/eval.c
index 8b029967e7a..77411a911ee 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1977,21 +1977,26 @@ void
1977verror (const char *m, va_list ap) 1977verror (const char *m, va_list ap)
1978{ 1978{
1979 char buf[200]; 1979 char buf[200];
1980 EMACS_INT size = 200; 1980 size_t size = sizeof buf;
1981 int mlen; 1981 size_t size_max = (size_t) -1;
1982 char *buffer = buf; 1982 char *buffer = buf;
1983 int allocated = 0; 1983 int allocated = 0;
1984 int used;
1984 Lisp_Object string; 1985 Lisp_Object string;
1985 1986
1986 mlen = strlen (m);
1987
1988 while (1) 1987 while (1)
1989 { 1988 {
1990 EMACS_INT used; 1989 used = vsnprintf (buffer, size, m, ap);
1991 used = doprnt (buffer, size, m, m + mlen, ap); 1990 if (used < 0)
1991 used = 0;
1992 if (used < size) 1992 if (used < size)
1993 break; 1993 break;
1994 size *= 2; 1994 if (size <= size_max / 2)
1995 size *= 2;
1996 else if (size < size_max)
1997 size = size_max;
1998 else
1999 memory_full ();
1995 if (allocated) 2000 if (allocated)
1996 buffer = (char *) xrealloc (buffer, size); 2001 buffer = (char *) xrealloc (buffer, size);
1997 else 2002 else
@@ -2001,7 +2006,7 @@ verror (const char *m, va_list ap)
2001 } 2006 }
2002 } 2007 }
2003 2008
2004 string = build_string (buffer); 2009 string = make_string (buffer, used);
2005 if (allocated) 2010 if (allocated)
2006 xfree (buffer); 2011 xfree (buffer);
2007 2012
diff --git a/src/fns.c b/src/fns.c
index c45d9e31ef2..09ce8c1b597 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1076,7 +1076,7 @@ an error is signaled. */)
1076 EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); 1076 EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0);
1077 1077
1078 if (converted < chars) 1078 if (converted < chars)
1079 error ("Can't convert the %dth character to unibyte", converted); 1079 error ("Can't convert the %"pEd"th character to unibyte", converted);
1080 string = make_unibyte_string ((char *) str, chars); 1080 string = make_unibyte_string ((char *) str, chars);
1081 xfree (str); 1081 xfree (str);
1082 } 1082 }
diff --git a/src/intervals.c b/src/intervals.c
index 729e6810f74..952f826778c 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -777,7 +777,7 @@ update_interval (register INTERVAL i, EMACS_INT pos)
777 i = i->right; /* Move to the right child */ 777 i = i->right; /* Move to the right child */
778 } 778 }
779 else if (NULL_PARENT (i)) 779 else if (NULL_PARENT (i))
780 error ("Point %d after end of properties", pos); 780 error ("Point %"pEd" after end of properties", pos);
781 else 781 else
782 i = INTERVAL_PARENT (i); 782 i = INTERVAL_PARENT (i);
783 continue; 783 continue;
diff --git a/src/lisp.h b/src/lisp.h
index 41a64d2f47d..7999fb42d5f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -38,6 +38,7 @@ extern void check_cons_list (void);
38#ifndef EMACS_INT 38#ifndef EMACS_INT
39#define EMACS_INT long 39#define EMACS_INT long
40#define BITS_PER_EMACS_INT BITS_PER_LONG 40#define BITS_PER_EMACS_INT BITS_PER_LONG
41#define pEd "ld"
41#endif 42#endif
42#ifndef EMACS_UINT 43#ifndef EMACS_UINT
43#define EMACS_UINT unsigned long 44#define EMACS_UINT unsigned long
@@ -46,6 +47,7 @@ extern void check_cons_list (void);
46#ifndef EMACS_INT 47#ifndef EMACS_INT
47#define EMACS_INT int 48#define EMACS_INT int
48#define BITS_PER_EMACS_INT BITS_PER_INT 49#define BITS_PER_EMACS_INT BITS_PER_INT
50#define pEd "d"
49#endif 51#endif
50#ifndef EMACS_UINT 52#ifndef EMACS_UINT
51#define EMACS_UINT unsigned int 53#define EMACS_UINT unsigned int
@@ -2872,8 +2874,9 @@ extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (size_t, Lisp_Obje
2872extern void specbind (Lisp_Object, Lisp_Object); 2874extern void specbind (Lisp_Object, Lisp_Object);
2873extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); 2875extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object);
2874extern Lisp_Object unbind_to (int, Lisp_Object); 2876extern Lisp_Object unbind_to (int, Lisp_Object);
2875extern void error (const char *, ...) NO_RETURN; 2877extern void error (const char *, ...) NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 2);
2876extern void verror (const char *, va_list) NO_RETURN; 2878extern void verror (const char *, va_list)
2879 NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0);
2877extern void do_autoload (Lisp_Object, Lisp_Object); 2880extern void do_autoload (Lisp_Object, Lisp_Object);
2878extern Lisp_Object un_autoload (Lisp_Object); 2881extern Lisp_Object un_autoload (Lisp_Object);
2879EXFUN (Ffetch_bytecode, 1); 2882EXFUN (Ffetch_bytecode, 1);
diff --git a/src/m/amdx86-64.h b/src/m/amdx86-64.h
index 441f41b4444..dbca9b5b838 100644
--- a/src/m/amdx86-64.h
+++ b/src/m/amdx86-64.h
@@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 28
29/* Define the type to use. */ 29/* Define the type to use. */
30#define EMACS_INT long 30#define EMACS_INT long
31#define pEd "ld"
31#define EMACS_UINT unsigned long 32#define EMACS_UINT unsigned long
32 33
33/* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ 34/* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
diff --git a/src/m/ia64.h b/src/m/ia64.h
index 101d56e648b..a1374d7c224 100644
--- a/src/m/ia64.h
+++ b/src/m/ia64.h
@@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 28
29/* Define the type to use. */ 29/* Define the type to use. */
30#define EMACS_INT long 30#define EMACS_INT long
31#define pEd "ld"
31#define EMACS_UINT unsigned long 32#define EMACS_UINT unsigned long
32 33
33#ifdef REL_ALLOC 34#ifdef REL_ALLOC
diff --git a/src/m/ibms390x.h b/src/m/ibms390x.h
index d4ef5c291ef..14228b61e56 100644
--- a/src/m/ibms390x.h
+++ b/src/m/ibms390x.h
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 24
25/* Define the type to use. */ 25/* Define the type to use. */
26#define EMACS_INT long 26#define EMACS_INT long
27#define pEd "ld"
27#define EMACS_UINT unsigned long 28#define EMACS_UINT unsigned long
28 29
29/* On the 64 bit architecture, we can use 60 bits for addresses */ 30/* On the 64 bit architecture, we can use 60 bits for addresses */
@@ -31,4 +32,3 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 32
32/* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ 33/* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
33#define XPNTR(a) XUINT (a) 34#define XPNTR(a) XUINT (a)
34
diff --git a/src/nsfns.m b/src/nsfns.m
index 6a5adbd7bf3..d4445d1d627 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -483,7 +483,7 @@ ns_set_name_internal (FRAME_PTR f, Lisp_Object name)
483 if (!STRINGP (f->icon_name)) 483 if (!STRINGP (f->icon_name))
484 encoded_icon_name = encoded_name; 484 encoded_icon_name = encoded_name;
485 else 485 else
486 encoded_icon_name = ENCODE_UTF_8 (f->icon_name); 486 encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
487 487
488 str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)]; 488 str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)];
489 489
@@ -637,7 +637,7 @@ ns_set_name_as_filename (struct frame *f)
637 637
638 if (FRAME_ICONIFIED_P (f)) 638 if (FRAME_ICONIFIED_P (f))
639 [[view window] setMiniwindowTitle: str]; 639 [[view window] setMiniwindowTitle: str];
640 else 640 else
641 { 641 {
642 NSString *fstr; 642 NSString *fstr;
643 643
@@ -1021,8 +1021,8 @@ frame_parm_handler ns_frame_parm_handlers[] =
1021 0, /* x_set_fullscreen will ignore */ 1021 0, /* x_set_fullscreen will ignore */
1022 x_set_font_backend, /* generic OK */ 1022 x_set_font_backend, /* generic OK */
1023 x_set_alpha, 1023 x_set_alpha,
1024 0, /* x_set_sticky */ 1024 0, /* x_set_sticky */
1025 0, /* x_set_tool_bar_position */ 1025 0, /* x_set_tool_bar_position */
1026}; 1026};
1027 1027
1028 1028
@@ -2044,7 +2044,7 @@ In case the execution fails, an error is signaled. */)
2044 (Lisp_Object script) 2044 (Lisp_Object script)
2045{ 2045{
2046 Lisp_Object result; 2046 Lisp_Object result;
2047 long status; 2047 int status;
2048 2048
2049 CHECK_STRING (script); 2049 CHECK_STRING (script);
2050 check_ns (); 2050 check_ns ();
@@ -2330,7 +2330,7 @@ If omitted or nil, that stands for the selected frame's display. */)
2330{ 2330{
2331 struct ns_display_info *dpyinfo; 2331 struct ns_display_info *dpyinfo;
2332 check_ns (); 2332 check_ns ();
2333 2333
2334 dpyinfo = check_ns_display_info (display); 2334 dpyinfo = check_ns_display_info (display);
2335 /* We force 24+ bit depths to 24-bit to prevent an overflow. */ 2335 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2336 return make_number (1 << min (dpyinfo->n_planes, 24)); 2336 return make_number (1 << min (dpyinfo->n_planes, 24));
@@ -2373,7 +2373,7 @@ compute_tip_xy (struct frame *f,
2373 pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top) 2373 pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top)
2374 - height; 2374 - height;
2375 } 2375 }
2376 2376
2377 /* Ensure in bounds. (Note, screen origin = lower left.) */ 2377 /* Ensure in bounds. (Note, screen origin = lower left.) */
2378 if (INTEGERP (left)) 2378 if (INTEGERP (left))
2379 *root_x = pt.x; 2379 *root_x = pt.x;
@@ -2655,4 +2655,3 @@ be used as the image of the icon representing the frame. */);
2655 check_window_system_func = check_ns; 2655 check_window_system_func = check_ns;
2656 2656
2657} 2657}
2658
diff --git a/src/sysdep.c b/src/sysdep.c
index a165a9ca52f..f4f767dac3f 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2361,7 +2361,8 @@ serial_configure (struct Lisp_Process *p,
2361 CHECK_NUMBER (tem); 2361 CHECK_NUMBER (tem);
2362 err = cfsetspeed (&attr, XINT (tem)); 2362 err = cfsetspeed (&attr, XINT (tem));
2363 if (err != 0) 2363 if (err != 0)
2364 error ("cfsetspeed(%d) failed: %s", XINT (tem), emacs_strerror (errno)); 2364 error ("cfsetspeed(%"pEd") failed: %s", XINT (tem),
2365 emacs_strerror (errno));
2365 childp2 = Fplist_put (childp2, QCspeed, tem); 2366 childp2 = Fplist_put (childp2, QCspeed, tem);
2366 2367
2367 /* Configure bytesize. */ 2368 /* Configure bytesize. */
diff --git a/src/window.c b/src/window.c
index 5ca46dd3316..ebfd1b0f778 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3804,7 +3804,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples. */)
3804 error ("Window height %d too small (after splitting)", size_int); 3804 error ("Window height %d too small (after splitting)", size_int);
3805 if (size_int + window_safe_height > XFASTINT (o->total_lines)) 3805 if (size_int + window_safe_height > XFASTINT (o->total_lines))
3806 error ("Window height %d too small (after splitting)", 3806 error ("Window height %d too small (after splitting)",
3807 XFASTINT (o->total_lines) - size_int); 3807 (int) (XFASTINT (o->total_lines) - size_int));
3808 if (NILP (o->parent) 3808 if (NILP (o->parent)
3809 || NILP (XWINDOW (o->parent)->vchild)) 3809 || NILP (XWINDOW (o->parent)->vchild))
3810 { 3810 {
@@ -3821,7 +3821,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples. */)
3821 error ("Window width %d too small (after splitting)", size_int); 3821 error ("Window width %d too small (after splitting)", size_int);
3822 if (size_int + window_safe_width > XFASTINT (o->total_cols)) 3822 if (size_int + window_safe_width > XFASTINT (o->total_cols))
3823 error ("Window width %d too small (after splitting)", 3823 error ("Window width %d too small (after splitting)",
3824 XFASTINT (o->total_cols) - size_int); 3824 (int) (XFASTINT (o->total_cols) - size_int));
3825 if (NILP (o->parent) 3825 if (NILP (o->parent)
3826 || NILP (XWINDOW (o->parent)->hchild)) 3826 || NILP (XWINDOW (o->parent)->hchild))
3827 { 3827 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 16954d0f809..a296fb33a9f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8407,10 +8407,18 @@ vmessage (const char *m, va_list ap)
8407 { 8407 {
8408 if (m) 8408 if (m)
8409 { 8409 {
8410 EMACS_INT len; 8410 char *buf = FRAME_MESSAGE_BUF (f);
8411 8411 size_t bufsize = FRAME_MESSAGE_BUF_SIZE (f);
8412 len = doprnt (FRAME_MESSAGE_BUF (f), 8412 int len = vsnprintf (buf, bufsize, m, ap);
8413 FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap); 8413 if (len < 0)
8414 len = 0;
8415
8416 /* Do any truncation at a character boundary. */
8417 if (0 < bufsize && bufsize <= len)
8418 for (len = bufsize - 1;
8419 len && ! CHAR_HEAD_P (buf[len - 1]);
8420 len--)
8421 continue;
8414 8422
8415 message2 (FRAME_MESSAGE_BUF (f), len, 0); 8423 message2 (FRAME_MESSAGE_BUF (f), len, 0);
8416 } 8424 }
diff --git a/src/xfns.c b/src/xfns.c
index 8e5639681df..04b8e44b561 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -215,7 +215,7 @@ check_x_display_info (Lisp_Object object)
215 struct terminal *t = get_terminal (object, 1); 215 struct terminal *t = get_terminal (object, 1);
216 216
217 if (t->type != output_x_window) 217 if (t->type != output_x_window)
218 error ("Terminal %d is not an X display", XINT (object)); 218 error ("Terminal %"pEd" is not an X display", XINT (object));
219 219
220 dpyinfo = t->display_info.x; 220 dpyinfo = t->display_info.x;
221 } 221 }