diff options
| author | Paul Eggert | 2018-04-28 16:49:24 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-04-28 16:56:48 -0700 |
| commit | 8c3215e7a47e3caaa005bf573765ed63e0739b89 (patch) | |
| tree | 0b90cacdef1a62ff888e92d0742b715ee69705ce | |
| parent | 2b9ab8c8fba849da8bf2aa45e65b122bb937a6b3 (diff) | |
| download | emacs-8c3215e7a47e3caaa005bf573765ed63e0739b89.tar.gz emacs-8c3215e7a47e3caaa005bf573765ed63e0739b89.zip | |
Port --enable-gcc-warnings to GCC 8
* configure.ac: Do not use GCC 8’s new -Wcast-align flag.
* lib-src/ebrowse.c (xmalloc):
* lib-src/emacsclient.c (xmalloc, xstrdup):
* lib-src/etags.c (xmalloc):
* lib-src/make-docfile.c (xmalloc):
* lib-src/movemail.c (xmalloc):
* src/dispnew.c (new_glyph_pool):
* src/regex.c (xmalloc):
* src/term.c (tty_menu_create):
* src/tparam.h (tparam):
Use ATTRIBUTE_MALLOC. Also see GCC bug 85562.
* lib-src/emacsclient.c (fail):
Do not dereference a null pointer.
* src/frame.c (delete_frame):
Add a decl with UNINIT to work around GCC bug 85563.
* src/menu.h (finish_menu_items):
Do not use attribute const.
* src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
| -rw-r--r-- | configure.ac | 1 | ||||
| -rw-r--r-- | lib-src/ebrowse.c | 2 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 25 | ||||
| -rw-r--r-- | lib-src/etags.c | 2 | ||||
| -rw-r--r-- | lib-src/make-docfile.c | 2 | ||||
| -rw-r--r-- | lib-src/movemail.c | 2 | ||||
| -rw-r--r-- | src/dispnew.c | 2 | ||||
| -rw-r--r-- | src/frame.c | 1 | ||||
| -rw-r--r-- | src/menu.h | 2 | ||||
| -rw-r--r-- | src/regex.c | 5 | ||||
| -rw-r--r-- | src/term.c | 2 | ||||
| -rw-r--r-- | src/tparam.h | 2 |
12 files changed, 26 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac index d2269d6f35b..a49b7727975 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -952,6 +952,7 @@ AS_IF([test $gl_gcc_warnings = no], | |||
| 952 | AS_IF([test $gl_gcc_warnings = yes], | 952 | AS_IF([test $gl_gcc_warnings = yes], |
| 953 | [WERROR_CFLAGS=-Werror]) | 953 | [WERROR_CFLAGS=-Werror]) |
| 954 | 954 | ||
| 955 | nw="$nw -Wcast-align -Wcast-align=strict" # Emacs is tricky with pointers. | ||
| 955 | nw="$nw -Wduplicated-branches" # Too many false alarms | 956 | nw="$nw -Wduplicated-branches" # Too many false alarms |
| 956 | nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776 | 957 | nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776 |
| 957 | nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings | 958 | nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings |
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index fa78c35a8b4..33af4f02daf 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c | |||
| @@ -494,7 +494,7 @@ yyerror (const char *format, const char *s) | |||
| 494 | /* Like malloc but print an error and exit if not enough memory is | 494 | /* Like malloc but print an error and exit if not enough memory is |
| 495 | available. */ | 495 | available. */ |
| 496 | 496 | ||
| 497 | static void * | 497 | static void * ATTRIBUTE_MALLOC |
| 498 | xmalloc (size_t nbytes) | 498 | xmalloc (size_t nbytes) |
| 499 | { | 499 | { |
| 500 | void *p = malloc (nbytes); | 500 | void *p = malloc (nbytes); |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 574bec850fa..739e6d5949e 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -192,7 +192,7 @@ struct option longopts[] = | |||
| 192 | 192 | ||
| 193 | /* Like malloc but get fatal error if memory is exhausted. */ | 193 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 194 | 194 | ||
| 195 | static void * | 195 | static void * ATTRIBUTE_MALLOC |
| 196 | xmalloc (size_t size) | 196 | xmalloc (size_t size) |
| 197 | { | 197 | { |
| 198 | void *result = malloc (size); | 198 | void *result = malloc (size); |
| @@ -219,7 +219,7 @@ xrealloc (void *ptr, size_t size) | |||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | /* Like strdup but get a fatal error if memory is exhausted. */ | 221 | /* Like strdup but get a fatal error if memory is exhausted. */ |
| 222 | char *xstrdup (const char *); | 222 | char *xstrdup (const char *) ATTRIBUTE_MALLOC; |
| 223 | 223 | ||
| 224 | char * | 224 | char * |
| 225 | xstrdup (const char *s) | 225 | xstrdup (const char *s) |
| @@ -261,7 +261,7 @@ get_current_dir_name (void) | |||
| 261 | #endif | 261 | #endif |
| 262 | ) | 262 | ) |
| 263 | { | 263 | { |
| 264 | buf = (char *) xmalloc (strlen (pwd) + 1); | 264 | buf = xmalloc (strlen (pwd) + 1); |
| 265 | strcpy (buf, pwd); | 265 | strcpy (buf, pwd); |
| 266 | } | 266 | } |
| 267 | else | 267 | else |
| @@ -312,12 +312,15 @@ w32_get_resource (HKEY predefined, const char *key, LPDWORD type) | |||
| 312 | 312 | ||
| 313 | if (RegOpenKeyEx (predefined, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) | 313 | if (RegOpenKeyEx (predefined, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
| 314 | { | 314 | { |
| 315 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS) | 315 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) |
| 316 | == ERROR_SUCCESS) | ||
| 316 | { | 317 | { |
| 317 | result = (char *) xmalloc (cbData); | 318 | result = xmalloc (cbData); |
| 318 | 319 | ||
| 319 | if ((RegQueryValueEx (hrootkey, key, NULL, type, (LPBYTE)result, &cbData) != ERROR_SUCCESS) | 320 | if ((RegQueryValueEx (hrootkey, key, NULL, type, (LPBYTE) result, |
| 320 | || (*result == 0)) | 321 | &cbData) |
| 322 | != ERROR_SUCCESS) | ||
| 323 | || *result == 0) | ||
| 321 | { | 324 | { |
| 322 | free (result); | 325 | free (result); |
| 323 | result = NULL; | 326 | result = NULL; |
| @@ -369,7 +372,7 @@ w32_getenv (const char *envvar) | |||
| 369 | 372 | ||
| 370 | if ((size = ExpandEnvironmentStrings (value, NULL, 0))) | 373 | if ((size = ExpandEnvironmentStrings (value, NULL, 0))) |
| 371 | { | 374 | { |
| 372 | char *buffer = (char *) xmalloc (size); | 375 | char *buffer = xmalloc (size); |
| 373 | if (ExpandEnvironmentStrings (value, buffer, size)) | 376 | if (ExpandEnvironmentStrings (value, buffer, size)) |
| 374 | { | 377 | { |
| 375 | /* Found and expanded. */ | 378 | /* Found and expanded. */ |
| @@ -700,7 +703,7 @@ fail (void) | |||
| 700 | { | 703 | { |
| 701 | size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *); | 704 | size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *); |
| 702 | size_t new_argv_size = extra_args_size; | 705 | size_t new_argv_size = extra_args_size; |
| 703 | char **new_argv = NULL; | 706 | char **new_argv = xmalloc (new_argv_size); |
| 704 | char *s = xstrdup (alternate_editor); | 707 | char *s = xstrdup (alternate_editor); |
| 705 | unsigned toks = 0; | 708 | unsigned toks = 0; |
| 706 | 709 | ||
| @@ -833,7 +836,7 @@ send_to_emacs (HSOCKET s, const char *data) | |||
| 833 | static void | 836 | static void |
| 834 | quote_argument (HSOCKET s, const char *str) | 837 | quote_argument (HSOCKET s, const char *str) |
| 835 | { | 838 | { |
| 836 | char *copy = (char *) xmalloc (strlen (str) * 2 + 1); | 839 | char *copy = xmalloc (strlen (str) * 2 + 1); |
| 837 | const char *p; | 840 | const char *p; |
| 838 | char *q; | 841 | char *q; |
| 839 | 842 | ||
| @@ -1843,7 +1846,7 @@ main (int argc, char **argv) | |||
| 1843 | careful to expand <relpath> with the default directory | 1846 | careful to expand <relpath> with the default directory |
| 1844 | corresponding to <drive>. */ | 1847 | corresponding to <drive>. */ |
| 1845 | { | 1848 | { |
| 1846 | char *filename = (char *) xmalloc (MAX_PATH); | 1849 | char *filename = xmalloc (MAX_PATH); |
| 1847 | DWORD size; | 1850 | DWORD size; |
| 1848 | 1851 | ||
| 1849 | size = GetFullPathName (argv[i], MAX_PATH, filename, NULL); | 1852 | size = GetFullPathName (argv[i], MAX_PATH, filename, NULL); |
diff --git a/lib-src/etags.c b/lib-src/etags.c index 588921bc700..b3b4575e0a6 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -7304,7 +7304,7 @@ linebuffer_setlen (linebuffer *lbp, int toksize) | |||
| 7304 | } | 7304 | } |
| 7305 | 7305 | ||
| 7306 | /* Like malloc but get fatal error if memory is exhausted. */ | 7306 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 7307 | static void * | 7307 | static void * ATTRIBUTE_MALLOC |
| 7308 | xmalloc (size_t size) | 7308 | xmalloc (size_t size) |
| 7309 | { | 7309 | { |
| 7310 | void *result = malloc (size); | 7310 | void *result = malloc (size); |
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index a5ed6e36071..23728e7251e 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -123,7 +123,7 @@ memory_exhausted (void) | |||
| 123 | 123 | ||
| 124 | /* Like malloc but get fatal error if memory is exhausted. */ | 124 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 125 | 125 | ||
| 126 | static void * | 126 | static void * ATTRIBUTE_MALLOC |
| 127 | xmalloc (ptrdiff_t size) | 127 | xmalloc (ptrdiff_t size) |
| 128 | { | 128 | { |
| 129 | void *result = malloc (size); | 129 | void *result = malloc (size); |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 4495c38f6ec..7a37e164dd0 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -145,7 +145,7 @@ static bool mbx_delimit_end (FILE *); | |||
| 145 | || (!defined DISABLE_DIRECT_ACCESS && !defined MAIL_USE_SYSTEM_LOCK)) | 145 | || (!defined DISABLE_DIRECT_ACCESS && !defined MAIL_USE_SYSTEM_LOCK)) |
| 146 | /* Like malloc but get fatal error if memory is exhausted. */ | 146 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 147 | 147 | ||
| 148 | static void * | 148 | static void * ATTRIBUTE_MALLOC |
| 149 | xmalloc (size_t size) | 149 | xmalloc (size_t size) |
| 150 | { | 150 | { |
| 151 | void *result = malloc (size); | 151 | void *result = malloc (size); |
diff --git a/src/dispnew.c b/src/dispnew.c index 324c05ddc4c..b854d179d51 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -1280,7 +1280,7 @@ row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p) | |||
| 1280 | with zeros. If GLYPH_DEBUG and ENABLE_CHECKING are in effect, the global | 1280 | with zeros. If GLYPH_DEBUG and ENABLE_CHECKING are in effect, the global |
| 1281 | variable glyph_pool_count is incremented for each pool allocated. */ | 1281 | variable glyph_pool_count is incremented for each pool allocated. */ |
| 1282 | 1282 | ||
| 1283 | static struct glyph_pool * | 1283 | static struct glyph_pool * ATTRIBUTE_MALLOC |
| 1284 | new_glyph_pool (void) | 1284 | new_glyph_pool (void) |
| 1285 | { | 1285 | { |
| 1286 | struct glyph_pool *result = xzalloc (sizeof *result); | 1286 | struct glyph_pool *result = xzalloc (sizeof *result); |
diff --git a/src/frame.c b/src/frame.c index 86caa32615d..da82621b8a0 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1937,6 +1937,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) | |||
| 1937 | if (f == sf) | 1937 | if (f == sf) |
| 1938 | { | 1938 | { |
| 1939 | Lisp_Object tail; | 1939 | Lisp_Object tail; |
| 1940 | Lisp_Object frame1 UNINIT; /* This line works around GCC bug 85563. */ | ||
| 1940 | eassume (CONSP (Vframe_list)); | 1941 | eassume (CONSP (Vframe_list)); |
| 1941 | 1942 | ||
| 1942 | /* Look for another visible frame on the same terminal. | 1943 | /* Look for another visible frame on the same terminal. |
diff --git a/src/menu.h b/src/menu.h index 104f6dc81d2..fa32a86d1c8 100644 --- a/src/menu.h +++ b/src/menu.h | |||
| @@ -30,7 +30,7 @@ enum { | |||
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | extern void init_menu_items (void); | 32 | extern void init_menu_items (void); |
| 33 | extern void finish_menu_items (void) ATTRIBUTE_CONST; | 33 | extern void finish_menu_items (void); |
| 34 | extern void discard_menu_items (void); | 34 | extern void discard_menu_items (void); |
| 35 | extern void save_menu_items (void); | 35 | extern void save_menu_items (void); |
| 36 | extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object); | 36 | extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object); |
diff --git a/src/regex.c b/src/regex.c index a4e6441cce3..85e63feea10 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -212,7 +212,7 @@ | |||
| 212 | 212 | ||
| 213 | /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ | 213 | /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ |
| 214 | 214 | ||
| 215 | static void * | 215 | static ATTRIBUTE_MALLOC void * |
| 216 | xmalloc (size_t size) | 216 | xmalloc (size_t size) |
| 217 | { | 217 | { |
| 218 | void *val = malloc (size); | 218 | void *val = malloc (size); |
| @@ -4033,8 +4033,7 @@ analyze_first (re_char *p, re_char *pend, char *fastmap, | |||
| 4033 | }; | 4033 | }; |
| 4034 | /* Keep `p1' to allow the `on_failure_jump' we are jumping to | 4034 | /* Keep `p1' to allow the `on_failure_jump' we are jumping to |
| 4035 | to jump back to "just after here". */ | 4035 | to jump back to "just after here". */ |
| 4036 | /* Fallthrough */ | 4036 | FALLTHROUGH; |
| 4037 | |||
| 4038 | case on_failure_jump: | 4037 | case on_failure_jump: |
| 4039 | case on_failure_keep_string_jump: | 4038 | case on_failure_keep_string_jump: |
| 4040 | case on_failure_jump_nastyloop: | 4039 | case on_failure_jump_nastyloop: |
diff --git a/src/term.c b/src/term.c index 8be5fb319b0..08d483f4fa0 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2721,7 +2721,7 @@ typedef struct tty_menu_struct | |||
| 2721 | 2721 | ||
| 2722 | /* Create a brand new menu structure. */ | 2722 | /* Create a brand new menu structure. */ |
| 2723 | 2723 | ||
| 2724 | static tty_menu * | 2724 | static tty_menu * ATTRIBUTE_MALLOC |
| 2725 | tty_menu_create (void) | 2725 | tty_menu_create (void) |
| 2726 | { | 2726 | { |
| 2727 | return xzalloc (sizeof *tty_menu_create ()); | 2727 | return xzalloc (sizeof *tty_menu_create ()); |
diff --git a/src/tparam.h b/src/tparam.h index 3a3cb52c178..79c55b94d2a 100644 --- a/src/tparam.h +++ b/src/tparam.h | |||
| @@ -30,7 +30,7 @@ int tgetnum (const char *); | |||
| 30 | char *tgetstr (const char *, char **); | 30 | char *tgetstr (const char *, char **); |
| 31 | char *tgoto (const char *, int, int); | 31 | char *tgoto (const char *, int, int); |
| 32 | 32 | ||
| 33 | char *tparam (const char *, char *, int, int, int, int, int); | 33 | char *tparam (const char *, char *, int, int, int, int, int) ATTRIBUTE_MALLOC; |
| 34 | 34 | ||
| 35 | extern char PC; | 35 | extern char PC; |
| 36 | extern char *BC; | 36 | extern char *BC; |