From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Clean up a couple of compiler warnings Date: Thu, 18 May 2017 20:48:42 -0700 Organization: UCLA Computer Science Department Message-ID: References: <20170518202450.75747-1-phst@google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F26F171D45AA11209E605B70" X-Trace: blaine.gmane.org 1495165750 26888 195.159.176.226 (19 May 2017 03:49:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 May 2017 03:49:10 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 Cc: Philipp Stephani To: Philipp Stephani , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 19 05:49:02 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBYuR-0006i0-E1 for ged-emacs-devel@m.gmane.org; Fri, 19 May 2017 05:48:59 +0200 Original-Received: from localhost ([::1]:56433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBYuV-0007qK-6k for ged-emacs-devel@m.gmane.org; Thu, 18 May 2017 23:49:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBYuN-0007qE-QV for emacs-devel@gnu.org; Thu, 18 May 2017 23:48:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBYuJ-00078X-T2 for emacs-devel@gnu.org; Thu, 18 May 2017 23:48:55 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBYuJ-00077t-Gj for emacs-devel@gnu.org; Thu, 18 May 2017 23:48:51 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C21F51600AD; Thu, 18 May 2017 20:48:49 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id MxmN0gJkl07t; Thu, 18 May 2017 20:48:45 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7E8A11600B0; Thu, 18 May 2017 20:48:45 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HYYNFewOTTYS; Thu, 18 May 2017 20:48:45 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.153.188.248]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 5400E1600AD; Thu, 18 May 2017 20:48:45 -0700 (PDT) In-Reply-To: <20170518202450.75747-1-phst@google.com> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214972 Archived-At: This is a multi-part message in MIME format. --------------F26F171D45AA11209E605B70 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Philipp Stephani wrote: > * sysdep.c (system_process_attributes): Remove unused variables. Thanks, I installed that in your name (1st attached patch). > * emacs.c (using_utf8): Don't assume anything about mbstate_t type. The old code doesn't assume anything about the type either, and should wo= rk=20 regardless of how mbstate_t is implemented. The proposed change makes the= code a=20 bit harder to read, so I'd rather avoid it if possible. I couldn't reprod= uce the=20 warning that you're evidently seeing. Perhaps you can work around the pro= blem in=20 the same way I worked around the problem with floats and doubles (see bel= ow)? > * emacs-module.c (MODULE_SETJMP_1): Mark dummy variable as unused. Rather than do that, let's just use the variable; that's more robust. I=20 installed the 2nd attached patch. > * lread.c (string_to_number): Use constants of double type. > * editfns.c (decode_float_time): > * fns.c (make_hash_table, maybe_resize_hash_table) > (Fhash_table_rehash_size, Fhash_table_rehash_threshold): > Explicitly cast floating-point values. There should be no problem (i.e., no loss of info) converting a float to = a=20 double, so these changes are not needed. I assume you're using clang. I=20 reproduced its false alarms on Fedora 25 x86-64, which uses clang 3.9.1, = and=20 installed the 3rd attached patch to work around the problem. > * fileio.c (file_name_case_insensitive_p): Add cast. Rather than waste time static-checking the DARWIN_OS_CASE_SENSITIVE_FIXME= =3D=3D 2=20 code let's just #ifdef it out. I did that in the 4th attached patch. Mayb= e we=20 should just remove it, since nobody is using it and (as you note) it does= n't=20 work anyway. --------------F26F171D45AA11209E605B70 Content-Type: text/x-patch; name="0001-Clean-up-some-compiler-warnings.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Clean-up-some-compiler-warnings.patch" =46rom e41030971f37375b9bb16c248f3b5d8d12064743 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 18 May 2017 19:15:26 -0700 Subject: [PATCH 1/4] Clean up some compiler warnings * src/sysdep.c (system_process_attributes) [DARWIN_OS]: Remove unused locals. --- src/sysdep.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sysdep.c b/src/sysdep.c index 91b2a5c..ac6eed0 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -3707,14 +3707,9 @@ Lisp_Object system_process_attributes (Lisp_Object pid) { int proc_id; - int pagesize =3D getpagesize (); - unsigned long npages; - int fscale; struct passwd *pw; struct group *gr; char *ttyname; - size_t len; - char args[MAXPATHLEN]; struct timeval starttime; struct timespec t, now; struct rusage *rusage; --=20 2.7.4 --------------F26F171D45AA11209E605B70 Content-Type: text/x-patch; name="0002-Clean-up-compiler-warning-in-emacs-module.c.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-Clean-up-compiler-warning-in-emacs-module.c.patch" =46rom 9647430ae8744bd4dee29f1269b74f65c09274d2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 18 May 2017 20:02:42 -0700 Subject: [PATCH 2/4] Clean up compiler warning in emacs-module.c * src/emacs-module.c (MODULE_SETJMP_1): Use the local var instead of leaving it unused, to pacify picky compilers. (module_reset_handlerlist): Now takes a dummy pointer to a struct handler *, instead of a dummy pointer to an int. All uses changed. --- src/emacs-module.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/emacs-module.c b/src/emacs-module.c index cd025a1..5aa8a88 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -109,7 +109,7 @@ static void module_handle_throw (emacs_env *, Lisp_Ob= ject); static void module_non_local_exit_signal_1 (emacs_env *, Lisp_Object, Li= sp_Object); static void module_non_local_exit_throw_1 (emacs_env *, Lisp_Object, Lis= p_Object); static void module_out_of_memory (emacs_env *); -static void module_reset_handlerlist (const int *); +static void module_reset_handlerlist (struct handler *const *); =20 /* We used to return NULL when emacs_value was a different type from Lisp_Object, but nowadays we just use Qnil instead. Although they @@ -160,17 +160,18 @@ static emacs_value const module_nil =3D 0; =20 /* TODO: Make backtraces work if this macros is used. */ =20 -#define MODULE_SETJMP_1(handlertype, handlerfunc, retval, c, dummy) \ +#define MODULE_SETJMP_1(handlertype, handlerfunc, retval, c0, c) \ if (module_non_local_exit_check (env) !=3D emacs_funcall_exit_return) = \ return retval; \ - struct handler *c =3D push_handler_nosignal (Qt, handlertype); \ - if (!c) \ + struct handler *c0 =3D push_handler_nosignal (Qt, handlertype); \ + if (!c0) \ { \ module_out_of_memory (env); \ return retval; \ } \ verify (module_has_cleanup); \ - int dummy __attribute__ ((cleanup (module_reset_handlerlist))); \ + struct handler *c __attribute__ ((cleanup (module_reset_handlerlist)))= \ + =3D c0; \ if (sys_setjmp (c->jmp)) \ { \ (handlerfunc) (env, c->val); \ @@ -919,7 +920,7 @@ finalize_environment (struct emacs_env_private *env) code in eval.c for details. The macros below arrange for this function to be called automatically. DUMMY is ignored. */ static void -module_reset_handlerlist (const int *dummy) +module_reset_handlerlist (struct handler *const *dummy) { handlerlist =3D handlerlist->next; } --=20 2.7.4 --------------F26F171D45AA11209E605B70 Content-Type: text/x-patch; name="0003-Port-enable-gcc-warnings-to-clang-3.9.1.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-Port-enable-gcc-warnings-to-clang-3.9.1.patch" =46rom af4ac3dc852647e5ea41be5ffc387be591978aee Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 18 May 2017 20:27:11 -0700 Subject: [PATCH 3/4] Port --enable-gcc-warnings to clang 3.9.1 * configure.ac (WERROR_CFLAGS): Omit -Wdouble-promotion if clang. Problem reported by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00495.html --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 34b75a7..03542a6 100644 --- a/configure.ac +++ b/configure.ac @@ -963,6 +963,7 @@ AC_DEFUN =20 if test $emacs_cv_clang =3D yes; then nw=3D"$nw -Wcast-align" + nw=3D"$nw -Wdouble-promotion" fi =20 # This causes too much noise in the MinGW build --=20 2.7.4 --------------F26F171D45AA11209E605B70 Content-Type: text/x-patch; name="0004-Fix-DARWIN_OS_CASE_SENSITIVE_FIXME-2-false-alarm.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0004-Fix-DARWIN_OS_CASE_SENSITIVE_FIXME-2-false-alarm.patch" =46rom 7e3e51f4e288379be6a8731b739b63b9386940f7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 18 May 2017 20:40:42 -0700 Subject: [PATCH 4/4] Fix DARWIN_OS_CASE_SENSITIVE_FIXME=3D=3D2 false alar= m MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * src/fileio.c (file_name_case_insensitive_p): Don=E2=80=99t compile the (DARWIN_OS_CASE_SENSITIVE_FIXME =3D=3D 2) code unless DARWIN_OS_CASE_SENSITIVE_FIXME is 2. Problem reported by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00495.html --- src/fileio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index acbf76e..e5e3505 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2294,10 +2294,14 @@ file_name_case_insensitive_p (const char *filenam= e) & VOL_CAP_FMT_CASE_SENSITIVE); } } - else if (DARWIN_OS_CASE_SENSITIVE_FIXME =3D=3D 2) +# if DARWIN_OS_CASE_SENSITIVE_FIXME =3D=3D 2 { /* The following is based on - http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */= + http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. + It is normally not even compiled, since it runs afoul of + static checking. See: + http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00495.html + */ struct attrlist alist; unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (si= ze_t)]; =20 @@ -2309,6 +2313,7 @@ file_name_case_insensitive_p (const char *filename)= vol_capabilities_attr_t *vcaps =3D buffer; return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); } +# endif #endif /* DARWIN_OS */ =20 #if defined CYGWIN || defined DOS_NT --=20 2.7.4 --------------F26F171D45AA11209E605B70--