From: Paul Eggert Date: Tue, 19 Apr 2011 07:22:13 +0000 (-0700) Subject: * lread.c (openp): Don't stuff size_t into an 'int'. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~244 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=640ee02d548592fda4d274487ef2fdc3873dfc7b;p=emacs.git * lread.c (openp): Don't stuff size_t into an 'int'. Use <= on length, not < on length + 1, to avoid GCC 4.6.0 warning about possible signed overflow. --- diff --git a/src/ChangeLog b/src/ChangeLog index d1ab9c4961e..5c6fa587b44 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-04-19 Paul Eggert + * lread.c (openp): Don't stuff size_t into an 'int'. + Use <= on length, not < on length + 1, to avoid GCC 4.6.0 warning + about possible signed overflow. + * gtkutil.c: Fix problems found by GCC 4.6.0 on Ubuntu 10.10. (GDK_KEY_g): Don't define if already defined. (xg_prepare_tooltip): Avoid pointer signedness problem. diff --git a/src/lread.c b/src/lread.c index d32f0b6a7e2..2f01b931e61 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1411,16 +1411,16 @@ int openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) { register int fd; - int fn_size = 100; + EMACS_INT fn_size = 100; char buf[100]; register char *fn = buf; int absolute = 0; - int want_size; + EMACS_INT want_length; Lisp_Object filename; struct stat st; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; Lisp_Object string, tail, encoded_fn; - int max_suffix_len = 0; + EMACS_INT max_suffix_len = 0; CHECK_STRING (str); @@ -1454,11 +1454,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto continue; } - /* Calculate maximum size of any filename made from + /* Calculate maximum length of any filename made from this path element/specified file name and any possible suffix. */ - want_size = max_suffix_len + SBYTES (filename) + 1; - if (fn_size < want_size) - fn = (char *) alloca (fn_size = 100 + want_size); + want_length = max_suffix_len + SBYTES (filename); + if (fn_size <= want_length) + fn = (char *) alloca (fn_size = 100 + want_length); /* Loop over suffixes. */ for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes;