+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.
#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
#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
# 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))
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),
# 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))
# 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. */
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;
}
#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))
/* 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;
-# 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,
#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