emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Clean up a couple of compiler warnings


From: Philipp Stephani
Subject: [PATCH] Clean up a couple of compiler warnings
Date: Thu, 18 May 2017 22:24:50 +0200

* emacs.c (using_utf8): Don't assume anything about mbstate_t type.

* fileio.c (file_name_case_insensitive_p): Add cast.

* 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.

* sysdep.c (system_process_attributes): Remove unused variables.

* emacs-module.c (MODULE_SETJMP_1): Mark dummy variable as unused.
---
 src/editfns.c      |  2 +-
 src/emacs-module.c |  2 +-
 src/emacs.c        |  3 ++-
 src/fileio.c       |  6 +++++-
 src/fns.c          | 10 +++++-----
 src/lread.c        |  4 ++--
 src/sysdep.c       |  5 -----
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 75eb75a729..8b7854cda5 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1763,7 +1763,7 @@ decode_float_time (double t, struct lisp_time *result)
   EMACS_INT hi = small_t;
   double t_sans_hi = t - hi * lo_multiplier;
   int lo = t_sans_hi;
-  long double fracps = (t_sans_hi - lo) * 1e12L;
+  long double fracps = (long double) (t_sans_hi - lo) * 1e12L;
 #ifdef INT_FAST64_MAX
   int_fast64_t ifracps = fracps;
   int us = ifracps / 1000000;
diff --git a/src/emacs-module.c b/src/emacs-module.c
index cd025a1396..2f7e37d5be 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -170,7 +170,7 @@ static emacs_value const module_nil = 0;
       return retval;                                                   \
     }                                                                  \
   verify (module_has_cleanup);                                         \
-  int dummy __attribute__ ((cleanup (module_reset_handlerlist)));      \
+  int dummy __attribute__ ((cleanup (module_reset_handlerlist), unused)); \
   if (sys_setjmp (c->jmp))                                             \
     {                                                                  \
       (handlerfunc) (env, c->val);                                     \
diff --git a/src/emacs.c b/src/emacs.c
index 3aa914f22f..208b4b2a3f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -347,7 +347,8 @@ using_utf8 (void)
 {
 #ifdef HAVE_WCHAR_H
   wchar_t wc;
-  mbstate_t mbs = { 0 };
+  mbstate_t mbs;
+  memset (&mbs, 0, sizeof mbs);
   return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100;
 #else
   return false;
diff --git a/src/fileio.c b/src/fileio.c
index acbf76e0d8..be1a2659b8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2282,6 +2282,10 @@ file_name_case_insensitive_p (const char *filename)
   int DARWIN_OS_CASE_SENSITIVE_FIXME = 0;
 # endif
 
+  /* FIXME: The next two branches are both incorrect because the
+     attribute buffer starts with a 32-bit integer specifying its
+     size.  This size is not included in the vol_capabilities_attr
+     structure.  */
   if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1)
     {
       /* This is based on developer.apple.com's getattrlist man page.  */
@@ -2306,7 +2310,7 @@ file_name_case_insensitive_p (const char *filename)
       if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0)
          || !(alist.volattr & ATTR_VOL_CAPABILITIES))
        return 0;
-      vol_capabilities_attr_t *vcaps = buffer;
+      vol_capabilities_attr_t *vcaps = (void *) buffer;
       return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE);
     }
 #endif /* DARWIN_OS */
diff --git a/src/fns.c b/src/fns.c
index 0332ab5dad..bd05b4803e 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3772,7 +3772,7 @@ make_hash_table (struct hash_table_test test, EMACS_INT 
size,
   if (size == 0)
     size = 1;
 
-  double threshold = rehash_threshold;
+  double threshold = (double) rehash_threshold;
   index_float = size / threshold;
   index_size = (index_float < INDEX_SIZE_BOUND + 1
                ? next_almost_prime (index_float)
@@ -3854,7 +3854,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
       ptrdiff_t old_size = HASH_TABLE_SIZE (h);
       EMACS_INT new_size, index_size, nsize;
       ptrdiff_t i;
-      double rehash_size = h->rehash_size;
+      double rehash_size = (double) h->rehash_size;
       double index_float;
 
       if (rehash_size < 0)
@@ -3869,7 +3869,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
        }
       if (new_size <= old_size)
        new_size = old_size + 1;
-      double threshold = h->rehash_threshold;
+      double threshold = (double) h->rehash_threshold;
       index_float = new_size / threshold;
       index_size = (index_float < INDEX_SIZE_BOUND + 1
                    ? next_almost_prime (index_float)
@@ -4564,7 +4564,7 @@ DEFUN ("hash-table-rehash-size", Fhash_table_rehash_size,
        doc: /* Return the current rehash size of TABLE.  */)
   (Lisp_Object table)
 {
-  double rehash_size = check_hash_table (table)->rehash_size;
+  double rehash_size = (double) check_hash_table (table)->rehash_size;
   if (rehash_size < 0)
     {
       EMACS_INT s = -rehash_size;
@@ -4580,7 +4580,7 @@ DEFUN ("hash-table-rehash-threshold", 
Fhash_table_rehash_threshold,
        doc: /* Return the current rehash threshold of TABLE.  */)
   (Lisp_Object table)
 {
-  return make_float (check_hash_table (table)->rehash_threshold);
+  return make_float ((double) check_hash_table (table)->rehash_threshold);
 }
 
 
diff --git a/src/lread.c b/src/lread.c
index 5e737d690c..87cac3cc25 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3568,7 +3568,7 @@ string_to_number (char const *string, int base, bool 
ignore_trailing)
            {
              state |= E_EXP;
              cp += 3;
-             value = INFINITY;
+             value = HUGE_VAL;
            }
          else if (cp[-1] == '+'
                   && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N')
@@ -3576,7 +3576,7 @@ string_to_number (char const *string, int base, bool 
ignore_trailing)
              state |= E_EXP;
              cp += 3;
              /* NAN is a "positive" NaN on all known Emacs hosts.  */
-             value = NAN;
+             value = nan(NULL);
            }
          else
            cp = ecp;
diff --git a/src/sysdep.c b/src/sysdep.c
index 91b2a5cb94..ac6eed0e58 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 = 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;
-- 
2.13.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]