]> Savannah Git Hosting - gnulib.git/commitdiff
maint: port more modules to GCC 8
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 May 2018 00:38:50 +0000 (17:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 May 2018 00:40:16 +0000 (17:40 -0700)
* 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.

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

index 712f62b53c0306996d7222c7a8b0927219d6a80f..33365241ceea939ea6db757909d85d75cff7637e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 4cf033176ae5a410a02993c8776df5a70dcca854..fea815d244053a78e0115fdcaf9e6680f005fe5c 100644 (file)
--- a/lib/dfa.h
+++ b/lib/dfa.h
 #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
index 69aeb8682da46329a5affb03476a1f47840b3dd6..8b5111168d7018858a9b0f416a1c66b832d42080 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
 #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
 
index 9ef4c237a3519350340b00e9fd13e10f8433888a..648830d2ee47b00f742a3f5ba66840d6a235a7eb 100644 (file)
@@ -39,12 +39,6 @@ _GL_INLINE_HEADER_BEGIN
 # 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))
index 7e4dac1347fda625a479ee6050de2898dd03c028..cac872f295f32549dbfa44f1012bcab658444fdc 100644 (file)
@@ -48,7 +48,7 @@ struct exclude;
 
 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),
index 15afafc66f52d5129f3ec20e80d9545417e6ccee..27164ef413bd37d4cf4a783fa93d4d2b0c95745a 100644 (file)
 
 # 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))
index a54bf6ceec74f74774c2cf84a34eb055db03791f..1454faab2fd86630073c61a1a0e5957cfb6c4e6a 100644 (file)
 # 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.  */
 
index ce28a2accca0e44e237a50670e2ef66259f0f9c8..9ea339453f313c966a82105ffb912f556f6e53d2 100644 (file)
@@ -37,15 +37,12 @@ typedef void (*sa_handler_t) (int);
 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;
 }
 
index 2a51b840db8e6754815d8fbb52f58cb38c167f20..c419a2de6c1d574e7e810875ad44e0e63e0a326b 100644 (file)
@@ -36,12 +36,6 @@ extern "C" {
 #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))
index 0a4420d3bc8c9e0734e012600e3e708643d1c537..54b0967f15d8dda5adbcee3ce96cc890782c2493 100644 (file)
@@ -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;
index de65f6b82e87c472dcc3c7bae685df6e02c56513..736e421016c4a162949dc9418e3a325db3693fbd 100644 (file)
@@ -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 @@ AC_DEFUN([gl_COMMON_BODY], [
 #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