changeset 39311:ba9784884ffe

maint: port more modules to GCC 8 * lib/dirname.h (base_name): * lib/exclude.h (new_exclude): * lib/xstrndup.h (xstrndup): Add malloc attribute. * lib/readutmp.c: Pacify GCC 8 about safe use of strncpy. * lib/sig-handler.h (get_handler) [SA_SIGINFO]: Simplify. This pacifies GCC 8. * m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_ATTRIBUTE_MALLOC here. All other definitions removed.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 03 May 2018 17:38:50 -0700
parents 82d8d8ba57c1
children 82f26115dbb8
files ChangeLog lib/dfa.h lib/dirname.h lib/eealloc.h lib/exclude.h lib/pagealign_alloc.h lib/readutmp.c lib/sig-handler.h lib/xalloc.h lib/xstrndup.h m4/gnulib-common.m4
diffstat 11 files changed, 31 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 03 23:09:42 2018 +0200
+++ b/ChangeLog	Thu May 03 17:38:50 2018 -0700
@@ -1,3 +1,16 @@
+2018-05-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	maint: port more modules to GCC 8
+	* lib/dirname.h (base_name):
+	* lib/exclude.h (new_exclude):
+	* lib/xstrndup.h (xstrndup):
+	Add malloc attribute.
+	* lib/readutmp.c: Pacify GCC 8 about safe use of strncpy.
+	* lib/sig-handler.h (get_handler) [SA_SIGINFO]: Simplify.
+	This pacifies GCC 8.
+	* m4/gnulib-common.m4 (gl_COMMON_BODY):
+	Define _GL_ATTRIBUTE_MALLOC here.  All other definitions removed.
+
 2018-05-03  Bruno Haible  <bruno@clisp.org>
 
 	Simplify code. Drop support for Borland C++ on Windows.
--- a/lib/dfa.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/dfa.h	Thu May 03 17:38:50 2018 -0700
@@ -22,12 +22,6 @@
 #include <stdbool.h>
 #include <stddef.h>
 
-#if 3 <= __GNUC__
-# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#else
-# define _GL_ATTRIBUTE_MALLOC
-#endif
-
 struct localeinfo; /* See localeinfo.h.  */
 
 /* Element of a list of strings, at least one of which is known to
--- a/lib/dirname.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/dirname.h	Thu May 03 17:38:50 2018 -0700
@@ -36,7 +36,7 @@
 #endif
 
 # if GNULIB_DIRNAME
-char *base_name (char const *file);
+char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC;
 char *dir_name (char const *file);
 # endif
 
--- a/lib/eealloc.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/eealloc.h	Thu May 03 17:38:50 2018 -0700
@@ -39,12 +39,6 @@
 # define EEALLOC_INLINE _GL_INLINE
 #endif
 
-#if __GNUC__ >= 3
-# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#else
-# define _GL_ATTRIBUTE_MALLOC
-#endif
-
 #if ! defined __clang__ && \
     (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
--- a/lib/exclude.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/exclude.h	Thu May 03 17:38:50 2018 -0700
@@ -48,7 +48,7 @@
 
 bool fnmatch_pattern_has_wildcards (const char *, int) _GL_ATTRIBUTE_PURE;
 
-struct exclude *new_exclude (void);
+struct exclude *new_exclude (void) _GL_ATTRIBUTE_MALLOC;
 void free_exclude (struct exclude *);
 void add_exclude (struct exclude *, char const *, int);
 int add_exclude_file (void (*) (struct exclude *, char const *, int),
--- a/lib/pagealign_alloc.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/pagealign_alloc.h	Thu May 03 17:38:50 2018 -0700
@@ -20,12 +20,6 @@
 
 # include <stddef.h>
 
-#if __GNUC__ >= 3
-# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#else
-# define _GL_ATTRIBUTE_MALLOC
-#endif
-
 #if ! defined __clang__ && \
     (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
--- a/lib/readutmp.c	Thu May 03 23:09:42 2018 +0200
+++ b/lib/readutmp.c	Thu May 03 17:38:50 2018 -0700
@@ -38,6 +38,10 @@
 # include "unlocked-io.h"
 #endif
 
+#if 8 <= __GNUC__
+# pragma GCC diagnostic ignored "-Wsizeof-pointer-memaccess"
+#endif
+
 /* Copy UT->ut_name into storage obtained from malloc.  Then remove any
    trailing spaces from the copy, NUL terminate it, and return the copy.  */
 
--- a/lib/sig-handler.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/sig-handler.h	Thu May 03 17:38:50 2018 -0700
@@ -37,15 +37,12 @@
 SIG_HANDLER_INLINE sa_handler_t _GL_ATTRIBUTE_PURE
 get_handler (struct sigaction const *a)
 {
-#ifdef SA_SIGINFO
   /* POSIX says that special values like SIG_IGN can only occur when
      action.sa_flags does not contain SA_SIGINFO.  But in Linux 2.4,
      for example, sa_sigaction and sa_handler are aliases and a signal
-     is ignored if sa_sigaction (after casting) equals SIG_IGN.  So
-     use (and cast) sa_sigaction in that case.  */
-  if (a->sa_flags & SA_SIGINFO)
-    return (sa_handler_t) a->sa_sigaction;
-#endif
+     is ignored if sa_sigaction (after casting) equals SIG_IGN.  In
+     this case, this implementation relies on the fact that the two
+     are aliases, and simply returns sa_handler.  */
   return a->sa_handler;
 }
 
--- a/lib/xalloc.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/xalloc.h	Thu May 03 17:38:50 2018 -0700
@@ -36,12 +36,6 @@
 #endif
 
 
-#if __GNUC__ >= 3
-# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#else
-# define _GL_ATTRIBUTE_MALLOC
-#endif
-
 #if ! defined __clang__ && \
     (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
--- a/lib/xstrndup.h	Thu May 03 23:09:42 2018 +0200
+++ b/lib/xstrndup.h	Thu May 03 17:38:50 2018 -0700
@@ -20,4 +20,4 @@
 /* Return a newly allocated copy of at most N bytes of STRING.
    In other words, return a copy of the initial segment of length N of
    STRING.  */
-extern char *xstrndup (const char *string, size_t n);
+extern char *xstrndup (const char *string, size_t n) _GL_ATTRIBUTE_MALLOC;
--- a/m4/gnulib-common.m4	Thu May 03 23:09:42 2018 +0200
+++ b/m4/gnulib-common.m4	Thu May 03 17:38:50 2018 -0700
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 38
+# gnulib-common.m4 serial 39
 dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -72,6 +72,13 @@
 #else
 # define _GL_ATTRIBUTE_CONST /* empty */
 #endif
+
+/* The __malloc__ attribute was added in gcc 3.  */
+#if 3 <= __GNUC__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC /* empty */
+#endif
 ])
   dnl Preparation for running test programs:
   dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not