summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-04-28 16:49:24 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-04-28 16:56:48 -0700
commit8c3215e7a47e3caaa005bf573765ed63e0739b89 (patch)
tree0b90cacdef1a62ff888e92d0742b715ee69705ce /lib-src
parent2b9ab8c8fba849da8bf2aa45e65b122bb937a6b3 (diff)
downloademacs-8c3215e7a47e3caaa005bf573765ed63e0739b89.tar.gz
emacs-8c3215e7a47e3caaa005bf573765ed63e0739b89.tar.bz2
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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ebrowse.c2
-rw-r--r--lib-src/emacsclient.c25
-rw-r--r--lib-src/etags.c2
-rw-r--r--lib-src/make-docfile.c2
-rw-r--r--lib-src/movemail.c2
5 files changed, 18 insertions, 15 deletions
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)
/* Like malloc but print an error and exit if not enough memory is
available. */
-static void *
+static void * ATTRIBUTE_MALLOC
xmalloc (size_t nbytes)
{
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[] =
/* Like malloc but get fatal error if memory is exhausted. */
-static void *
+static void * ATTRIBUTE_MALLOC
xmalloc (size_t size)
{
void *result = malloc (size);
@@ -219,7 +219,7 @@ xrealloc (void *ptr, size_t size)
}
/* Like strdup but get a fatal error if memory is exhausted. */
-char *xstrdup (const char *);
+char *xstrdup (const char *) ATTRIBUTE_MALLOC;
char *
xstrdup (const char *s)
@@ -261,7 +261,7 @@ get_current_dir_name (void)
#endif
)
{
- buf = (char *) xmalloc (strlen (pwd) + 1);
+ buf = xmalloc (strlen (pwd) + 1);
strcpy (buf, pwd);
}
else
@@ -312,12 +312,15 @@ w32_get_resource (HKEY predefined, const char *key, LPDWORD type)
if (RegOpenKeyEx (predefined, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS)
+ if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData)
+ == ERROR_SUCCESS)
{
- result = (char *) xmalloc (cbData);
+ result = xmalloc (cbData);
- if ((RegQueryValueEx (hrootkey, key, NULL, type, (LPBYTE)result, &cbData) != ERROR_SUCCESS)
- || (*result == 0))
+ if ((RegQueryValueEx (hrootkey, key, NULL, type, (LPBYTE) result,
+ &cbData)
+ != ERROR_SUCCESS)
+ || *result == 0)
{
free (result);
result = NULL;
@@ -369,7 +372,7 @@ w32_getenv (const char *envvar)
if ((size = ExpandEnvironmentStrings (value, NULL, 0)))
{
- char *buffer = (char *) xmalloc (size);
+ char *buffer = xmalloc (size);
if (ExpandEnvironmentStrings (value, buffer, size))
{
/* Found and expanded. */
@@ -700,7 +703,7 @@ fail (void)
{
size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *);
size_t new_argv_size = extra_args_size;
- char **new_argv = NULL;
+ char **new_argv = xmalloc (new_argv_size);
char *s = xstrdup (alternate_editor);
unsigned toks = 0;
@@ -833,7 +836,7 @@ send_to_emacs (HSOCKET s, const char *data)
static void
quote_argument (HSOCKET s, const char *str)
{
- char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
+ char *copy = xmalloc (strlen (str) * 2 + 1);
const char *p;
char *q;
@@ -1843,7 +1846,7 @@ main (int argc, char **argv)
careful to expand <relpath> with the default directory
corresponding to <drive>. */
{
- char *filename = (char *) xmalloc (MAX_PATH);
+ char *filename = xmalloc (MAX_PATH);
DWORD size;
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)
}
/* Like malloc but get fatal error if memory is exhausted. */
-static void *
+static void * ATTRIBUTE_MALLOC
xmalloc (size_t size)
{
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)
/* Like malloc but get fatal error if memory is exhausted. */
-static void *
+static void * ATTRIBUTE_MALLOC
xmalloc (ptrdiff_t size)
{
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 *);
|| (!defined DISABLE_DIRECT_ACCESS && !defined MAIL_USE_SYSTEM_LOCK))
/* Like malloc but get fatal error if memory is exhausted. */
-static void *
+static void * ATTRIBUTE_MALLOC
xmalloc (size_t size)
{
void *result = malloc (size);