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
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])
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
/* 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;
#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);
}
#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");
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)
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)
{
/* Externally-visible name for numcompare. */
-int
+int _GL_ATTRIBUTE_PURE
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{
-int strintcmp (char const *, char const *);
+int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int);
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;
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
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)
return false;
}
-static bool
+static bool _GL_ATTRIBUTE_PURE
valid_options (const struct cp_options *co)
{
assert (co != NULL);
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
/* 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)
/* 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, '=');
/* 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;
/* 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;
/* Return true if V is a null-string or zero-number. */
-static bool
+static bool _GL_ATTRIBUTE_PURE
null (VALUE *v)
{
switch (v->type)
/* 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 == '-');
/* 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;
/* 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;
/* 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 == '/')
/* 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;
/* 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;
/* 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;
| 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 */
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 == '-');
}
}
-static tcflag_t *
+static tcflag_t * _GL_ATTRIBUTE_PURE
mode_type_flag (enum mode_type type, struct termios *mode)
{
switch (type)
{NULL, 0, 0}
};
-static speed_t
+static speed_t _GL_ATTRIBUTE_PURE
string_to_baud (const char *arg)
{
int i;
return (speed_t) -1;
}
-static unsigned long int
+static unsigned long int _GL_ATTRIBUTE_PURE
baud_to_value (speed_t speed)
{
int i;
/* 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
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));
/* 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;
/* 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;
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;
/* 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;
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;