From: Paul Eggert Date: Tue, 5 Apr 2011 20:22:53 +0000 (-0700) Subject: * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~394^2~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=da09ccce7ac9eca4e19f409215cc2897866e0a50;p=emacs.git * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior by passing a long int to a printf format expecting an int. --- diff --git a/src/ChangeLog b/src/ChangeLog index 185d611ea6e..fd864a460f4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ Fix more problems found by GCC 4.6.0's static checks. + * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior + by passing a long int to a printf format expecting an int. + * lisp.h (message, message_nolog, doprint, error, verror, fatal): Mark as printf-like functions. diff --git a/src/fns.c b/src/fns.c index c45d9e31ef2..ca18dbfc100 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1076,7 +1076,10 @@ an error is signaled. */) EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); if (converted < chars) - error ("Can't convert the %dth character to unibyte", converted); + { + long lconverted = converted; + error ("Can't convert the %ldth character to unibyte", lconverted); + } string = make_unibyte_string ((char *) str, chars); xfree (str); }