summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-04-24 19:06:39 +0200
committerJim Meyering <meyering@redhat.com>2011-07-02 12:35:06 +0200
commit84d048002e423dc85ae99bbb3372cd48dc1bfe72 (patch)
treef790fcb7ed23c571dd9eb4dc637a35b30978e376 /src
parent76d8e9abe18c3e3ed6dc37338b75140e06555cd5 (diff)
downloadcoreutils-84d048002e423dc85ae99bbb3372cd48dc1bfe72.tar.xz
maint: use "const" and "pure" function attributes where possible
* configure.ac (WARN_CFLAGS): Add -Wsuggest-attribute=const, -Wsuggest-attribute=pure and -Wsuggest-attribute=noreturn. (GNULIB_WARN_CFLAGS): But do not add them here... yet. * src/chown-core.h (chopt_free, uid_to_name): Add function attribute(s). * src/copy.c (is_ancestor, valid_options): Likewise. * src/copy.h (chown_failure_ok): Likewise. * src/dd.c (operand_matches, operand_is): Likewise. * src/df.c (selected_fstype, excluded_fstype): Likewise. * src/expr.c (null looks_like_integer): Likewise. * src/md5sum.c (hex_digits): Likewise. * src/od.c (get_lcm): Likewise. * src/pathchk.c (component_start, component_len): Likewise. * src/pinky.c (count_ampersands): Likewise. * src/pr.c (cols_ready_to_print): Likewise. * src/ptx.c (search_table): Likewise. * src/sort.c (find_unit_order): Likewise. * src/stty.c (mode_type_flag, string_to_baud, baud_to_value): Likewise. * src/system.h (gcd, lcm): Likewise. * src/tr.c (is_char_class_member, look_up_char_class): Likewise. (star_digits_closebracket): Likewise. * src/uniq.c (find_field): Likewise. * src/wc.c (compute_number_width): Likewise. * lib/xfts.h (cycle_warning_required): Likewise. * gl/lib/randint.h (randint_get_source): Likewise. * gl/lib/randperm.c (ceil_lg): Likewise. * gl/lib/randperm.h (randperm_bound): Likewise. * lib/strnumcmp.h (strintcmp): Likewise.
Diffstat (limited to 'src')
-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
18 files changed, 29 insertions, 29 deletions
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;