summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--gl/lib/randint.h3
-rw-r--r--gl/lib/randperm.c2
-rw-r--r--gl/lib/randperm.h2
-rw-r--r--gl/lib/tempname.c.diff2
-rw-r--r--lib/strnumcmp-in.h4
-rw-r--r--lib/strnumcmp.c2
-rw-r--r--lib/strnumcmp.h2
-rw-r--r--lib/xfts.h3
-rw-r--r--src/chown-core.h4
-rw-r--r--src/copy.c4
-rw-r--r--src/copy.h2
-rw-r--r--src/dd.c4
-rw-r--r--src/df.c4
-rw-r--r--src/expr.c4
-rw-r--r--src/md5sum.c2
-rw-r--r--src/od.c2
-rw-r--r--src/pathchk.c4
-rw-r--r--src/pinky.c2
-rw-r--r--src/pr.c2
-rw-r--r--src/ptx.c2
-rw-r--r--src/sort.c2
-rw-r--r--src/stty.c6
-rw-r--r--src/system.h4
-rw-r--r--src/tr.c6
-rw-r--r--src/uniq.c2
-rw-r--r--src/wc.c2
27 files changed, 46 insertions, 38 deletions
diff --git a/configure.ac b/configure.ac
index b6a10072c..41b2f0099 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,9 @@ if test "$gl_gcc_warnings" = yes; then
done
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+ gl_WARN_ADD([-Wsuggest-attribute=const])
+ gl_WARN_ADD([-Wsuggest-attribute=pure])
+ gl_WARN_ADD([-Wsuggest-attribute=noreturn])
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
@@ -124,6 +127,9 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wunused-macros"
nw="$nw -Wmissing-prototypes"
nw="$nw -Wold-style-definition"
+ # FIXME: remove/reenable the following two, once gnulib is adjusted.
+ nw="$nw -Wsuggest-attribute=const"
+ nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
diff --git a/gl/lib/randint.h b/gl/lib/randint.h
index edd6b1933..80c9a0e5f 100644
--- a/gl/lib/randint.h
+++ b/gl/lib/randint.h
@@ -34,7 +34,8 @@ struct randint_source;
struct randint_source *randint_new (struct randread_source *);
struct randint_source *randint_all_new (char const *, size_t);
-struct randread_source *randint_get_source (struct randint_source const *);
+struct randread_source *randint_get_source (struct randint_source const *)
+ _GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax);
/* Consume random data from *S to generate a random number in the range
diff --git a/gl/lib/randperm.c b/gl/lib/randperm.c
index 26181b8a6..362316e23 100644
--- a/gl/lib/randperm.c
+++ b/gl/lib/randperm.c
@@ -30,7 +30,7 @@
/* Return the ceiling of the log base 2 of N. If N is zero, return
an unspecified value. */
-static size_t
+static size_t _GL_ATTRIBUTE_CONST
ceil_lg (size_t n)
{
size_t b = 0;
diff --git a/gl/lib/randperm.h b/gl/lib/randperm.h
index 79bbf9fe6..0a0837aa6 100644
--- a/gl/lib/randperm.h
+++ b/gl/lib/randperm.h
@@ -1,4 +1,4 @@
#include "randint.h"
#include <stddef.h>
-size_t randperm_bound (size_t, size_t);
+size_t randperm_bound (size_t, size_t) _GL_ATTRIBUTE_CONST;
size_t *randperm_new (struct randint_source *, size_t, size_t);
diff --git a/gl/lib/tempname.c.diff b/gl/lib/tempname.c.diff
index 1bf111963..fcacf53db 100644
--- a/gl/lib/tempname.c.diff
+++ b/gl/lib/tempname.c.diff
@@ -22,7 +22,7 @@ index 2da5afe..562955a 100644
}
#endif /* _LIBC */
-+static inline bool
++static inline bool _GL_ATTRIBUTE_PURE
+check_x_suffix (char const *s, size_t len)
+{
+ return len <= strspn (s, "X");
diff --git a/lib/strnumcmp-in.h b/lib/strnumcmp-in.h
index dccbca539..7e963bc16 100644
--- a/lib/strnumcmp-in.h
+++ b/lib/strnumcmp-in.h
@@ -71,7 +71,7 @@
if digit return -1, else 0
return 0 */
-static inline int
+static inline int _GL_ATTRIBUTE_PURE
fraccompare (char const *a, char const *b, char decimal_point)
{
if (*a == decimal_point && *b == decimal_point)
@@ -111,7 +111,7 @@ fraccompare (char const *a, char const *b, char decimal_point)
causes comparisons to act as if there is no decimal point
character, and likewise for THOUSANDS_SEP. */
-static inline int
+static inline int _GL_ATTRIBUTE_PURE
numcompare (char const *a, char const *b,
int decimal_point, int thousands_sep)
{
diff --git a/lib/strnumcmp.c b/lib/strnumcmp.c
index f130b5836..2dfc28c9e 100644
--- a/lib/strnumcmp.c
+++ b/lib/strnumcmp.c
@@ -23,7 +23,7 @@
/* Externally-visible name for numcompare. */
-int
+int _GL_ATTRIBUTE_PURE
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{
diff --git a/lib/strnumcmp.h b/lib/strnumcmp.h
index 91ad3519b..4deef82bd 100644
--- a/lib/strnumcmp.h
+++ b/lib/strnumcmp.h
@@ -1,2 +1,2 @@
-int strintcmp (char const *, char const *);
+int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int);
diff --git a/lib/xfts.h b/lib/xfts.h
index fc3ba9010..f903f4804 100644
--- a/lib/xfts.h
+++ b/lib/xfts.h
@@ -6,4 +6,5 @@ xfts_open (char * const *, int options,
int (*) (const FTSENT **, const FTSENT **));
bool
-cycle_warning_required (FTS const *fts, FTSENT const *ent);
+cycle_warning_required (FTS const *fts, FTSENT const *ent)
+ _GL_ATTRIBUTE_PURE;
diff --git a/src/chown-core.h b/src/chown-core.h
index 3acb5e9e2..e7b3741ec 100644
--- a/src/chown-core.h
+++ b/src/chown-core.h
@@ -68,13 +68,13 @@ struct Chown_option
void
chopt_init (struct Chown_option *);
-void
+void _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST
chopt_free (struct Chown_option *);
char *
gid_to_name (gid_t);
-char *
+char * _GL_ATTRIBUTE_PURE
uid_to_name (uid_t);
bool
diff --git a/src/copy.c b/src/copy.c
index 1025fe139..c17b94211 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -468,7 +468,7 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
performance hit that's probably noticeable only on trees deeper
than a few hundred levels. See use of active_dir_map in remove.c */
-static bool
+static bool _GL_ATTRIBUTE_PURE
is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
{
while (ancestors != 0)
@@ -2535,7 +2535,7 @@ un_backup:
return false;
}
-static bool
+static bool _GL_ATTRIBUTE_PURE
valid_options (const struct cp_options *co)
{
assert (co != NULL);
diff --git a/src/copy.h b/src/copy.h
index 5014ea9ae..7332c7c7f 100644
--- a/src/copy.h
+++ b/src/copy.h
@@ -282,7 +282,7 @@ void dest_info_init (struct cp_options *);
void src_info_init (struct cp_options *);
void cp_options_default (struct cp_options *);
-bool chown_failure_ok (struct cp_options const *);
+bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
mode_t cached_umask (void);
#endif
diff --git a/src/dd.c b/src/dd.c
index 45aa9b970..3799d75d8 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1028,7 +1028,7 @@ write_output (void)
/* Return true if STR is of the form "PATTERN" or "PATTERNDELIM...". */
-static bool
+static bool _GL_ATTRIBUTE_PURE
operand_matches (char const *str, char const *pattern, char delim)
{
while (*pattern)
@@ -1108,7 +1108,7 @@ parse_integer (const char *str, bool *invalid)
/* OPERAND is of the form "X=...". Return true if X is NAME. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
operand_is (char const *operand, char const *name)
{
return operand_matches (operand, name, '=');
diff --git a/src/df.c b/src/df.c
index 1b27675bf..982d60742 100644
--- a/src/df.c
+++ b/src/df.c
@@ -321,7 +321,7 @@ get_header (void)
/* Is FSTYPE a type of file system that should be listed? */
-static bool
+static bool _GL_ATTRIBUTE_PURE
selected_fstype (const char *fstype)
{
const struct fs_type_list *fsp;
@@ -336,7 +336,7 @@ selected_fstype (const char *fstype)
/* Is FSTYPE a type of file system that should be omitted? */
-static bool
+static bool _GL_ATTRIBUTE_PURE
excluded_fstype (const char *fstype)
{
const struct fs_type_list *fsp;
diff --git a/src/expr.c b/src/expr.c
index 2331f64fe..1f535070b 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -393,7 +393,7 @@ printv (VALUE *v)
/* Return true if V is a null-string or zero-number. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
null (VALUE *v)
{
switch (v->type)
@@ -424,7 +424,7 @@ null (VALUE *v)
/* Return true if CP takes the form of an integer. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
looks_like_integer (char const *cp)
{
cp += (*cp == '-');
diff --git a/src/md5sum.c b/src/md5sum.c
index 6f6e6373d..9bbdc605f 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -355,7 +355,7 @@ split_3 (char *s, size_t s_len,
/* Return true if S is a NUL-terminated string of DIGEST_HEX_BYTES hex digits.
Otherwise, return false. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
hex_digits (unsigned char const *s)
{
unsigned int i;
diff --git a/src/od.c b/src/od.c
index 8604a8dcd..9ddd51971 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1257,7 +1257,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
/* Return the least common multiple of the sizes associated
with the format specs. */
-static int
+static int _GL_ATTRIBUTE_PURE
get_lcm (void)
{
size_t i;
diff --git a/src/pathchk.c b/src/pathchk.c
index 7f4e5dfcf..814652834 100644
--- a/src/pathchk.c
+++ b/src/pathchk.c
@@ -211,7 +211,7 @@ portable_chars_only (char const *file, size_t filelen)
/* Return the address of the start of the next file name component in F. */
-static char *
+static char * _GL_ATTRIBUTE_PURE
component_start (char *f)
{
while (*f == '/')
@@ -221,7 +221,7 @@ component_start (char *f)
/* Return the size of the file name component F. F must be nonempty. */
-static size_t
+static size_t _GL_ATTRIBUTE_PURE
component_len (char const *f)
{
size_t len;
diff --git a/src/pinky.c b/src/pinky.c
index 5e279e97c..00107b731 100644
--- a/src/pinky.c
+++ b/src/pinky.c
@@ -82,7 +82,7 @@ static struct option const longopts[] =
/* Count and return the number of ampersands in STR. */
-static size_t
+static size_t _GL_ATTRIBUTE_PURE
count_ampersands (const char *str)
{
size_t count = 0;
diff --git a/src/pr.c b/src/pr.c
index 3995c37ce..771418c45 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -773,7 +773,7 @@ static struct option const long_options[] =
/* Return the number of columns that have either an open file or
stored lines. */
-static int
+static int _GL_ATTRIBUTE_PURE
cols_ready_to_print (void)
{
COLUMN *q;
diff --git a/src/ptx.c b/src/ptx.c
index 7ac6e8f63..ff5e43315 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -595,7 +595,7 @@ compare_occurs (const void *void_first, const void *void_second)
| Return !0 if WORD appears in TABLE. Uses a binary search. |
`------------------------------------------------------------*/
-static int
+static int _GL_ATTRIBUTE_PURE
search_table (WORD *word, WORD_TABLE *table)
{
int lowest; /* current lowest possible index */
diff --git a/src/sort.c b/src/sort.c
index 084addf49..3d3119d90 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1846,7 +1846,7 @@ static char const unit_order[UCHAR_LIM] =
separators and a decimal point, but it may not contain leading blanks.
Negative numbers get negative orders; zero numbers have a zero order. */
-static int
+static int _GL_ATTRIBUTE_PURE
find_unit_order (char const *number)
{
bool minus_sign = (*number == '-');
diff --git a/src/stty.c b/src/stty.c
index 6d54eced2..5f5211b5e 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -1428,7 +1428,7 @@ screen_columns (void)
}
}
-static tcflag_t *
+static tcflag_t * _GL_ATTRIBUTE_PURE
mode_type_flag (enum mode_type type, struct termios *mode)
{
switch (type)
@@ -1789,7 +1789,7 @@ static struct speed_map const speeds[] =
{NULL, 0, 0}
};
-static speed_t
+static speed_t _GL_ATTRIBUTE_PURE
string_to_baud (const char *arg)
{
int i;
@@ -1800,7 +1800,7 @@ string_to_baud (const char *arg)
return (speed_t) -1;
}
-static unsigned long int
+static unsigned long int _GL_ATTRIBUTE_PURE
baud_to_value (speed_t speed)
{
int i;
diff --git a/src/system.h b/src/system.h
index d250d94f8..107dbd5a6 100644
--- a/src/system.h
+++ b/src/system.h
@@ -439,7 +439,7 @@ enum
/* Compute the greatest common divisor of U and V using Euclid's
algorithm. U and V must be nonzero. */
-static inline size_t
+static inline size_t _GL_ATTRIBUTE_CONST
gcd (size_t u, size_t v)
{
do
@@ -457,7 +457,7 @@ gcd (size_t u, size_t v)
nonzero. There is no overflow checking, so callers should not
specify outlandish sizes. */
-static inline size_t
+static inline size_t _GL_ATTRIBUTE_CONST
lcm (size_t u, size_t v)
{
return u * (v / gcd (u, v));
diff --git a/src/tr.c b/src/tr.c
index f7593d316..dfa37d014 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -364,7 +364,7 @@ is_equiv_class_member (unsigned char equiv_class, unsigned char c)
/* Return true if the character C is a member of the
character class CHAR_CLASS. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
is_char_class_member (enum Char_class char_class, unsigned char c)
{
int result;
@@ -542,7 +542,7 @@ unquote (char const *s, struct E_string *es)
/* If CLASS_STR is a valid character class string, return its index
in the global char_class_name array. Otherwise, return CC_NO_CLASS. */
-static enum Char_class
+static enum Char_class _GL_ATTRIBUTE_PURE
look_up_char_class (char const *class_str, size_t len)
{
enum Char_class i;
@@ -844,7 +844,7 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx,
expression `\*[0-9]*\]', false otherwise. The string does not
match if any of its characters are escaped. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
star_digits_closebracket (const struct E_string *es, size_t idx)
{
size_t i;
diff --git a/src/uniq.c b/src/uniq.c
index b35938a19..db717b1c7 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -206,7 +206,7 @@ size_opt (char const *opt, char const *msgid)
/* Given a linebuffer LINE,
return a pointer to the beginning of the line's field to be compared. */
-static char *
+static char * _GL_ATTRIBUTE_PURE
find_field (struct linebuffer const *line)
{
size_t count;
diff --git a/src/wc.c b/src/wc.c
index d5a0afc23..c4b5a9138 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -556,7 +556,7 @@ get_input_fstatus (int nfiles, char *const *file)
recorded in FSTATUS. Optimize the same special case that
get_input_fstatus optimizes. */
-static int
+static int _GL_ATTRIBUTE_PURE
compute_number_width (int nfiles, struct fstatus const *fstatus)
{
int width = 1;