diff options
author | Jim Meyering <meyering@redhat.com> | 2012-01-28 18:23:36 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-01-31 13:22:05 +0100 |
commit | 6835b68f981f53f9b91680e9acfb64cdfc6b870b (patch) | |
tree | f447c4e4ee83f4f50ab1866d9716e02737444921 /libidu/walker.c | |
parent | 7cc3d956e660c42c1597e4cc6521f94454f9a8b0 (diff) | |
download | idutils-6835b68f981f53f9b91680e9acfb64cdfc6b870b.tar.gz idutils-6835b68f981f53f9b91680e9acfb64cdfc6b870b.tar.bz2 idutils-6835b68f981f53f9b91680e9acfb64cdfc6b870b.zip |
build: add const and pure attributes, per gcc recommendation
* src/mkid.c (ceil_log_8, ceil_log_2): Add "const" attribute.
(token_hash_1, token_hash_2): Add "pure" attribute.
(token_hash_cmp, token_qsort_cmp): Likewise.
(count_vec_size, count_buf_size): Likewise.
* libidu/idu-hash.c (round_up_2): Add "const" attribute.
* libidu/scanners.h (get_language): Add "pure" attribute.
* libidu/idfile.h (token_flags): Likewise.
(token_count): Likewise.
(member_file_qsort_compare): Likewise.
(tree8_count_levels): Add "const" attribute.
* libidu/walker.c (symlink_ancestry): Add "pure" attribute.
(links_depth): Likewise.
(file_link_hash_1): Likewise.
(vector_length): Likewise.
(file_link_hash_compare): Likewise.
(string_in_vector): Likewise.
* src/lid.c (vector_cardinality, get_radix, dtoi, otoi): Likewise.
(is_regexp): Likewise.
(vector_length): Remove forward decl and move function definition
to precede first use.
Diffstat (limited to 'libidu/walker.c')
-rw-r--r-- | libidu/walker.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/libidu/walker.c b/libidu/walker.c index 02e3d65..e268f35 100644 --- a/libidu/walker.c +++ b/libidu/walker.c @@ -59,7 +59,6 @@ static struct file_link *make_link_from_string (char const *name, static int lang_wanted (char const *lang_name); static char **append_strings_to_vector (char **vector_0, char *string, char const *delimiter_class); -static int vector_length (char **vector); static int string_in_vector (char const *string, char **vector); static int same_as_dot (char const *cwd); static struct file_link const @@ -365,7 +364,7 @@ find_alias_link (struct file_link *flink, struct stat *stp) directory. PATH_MAX is considered an infinite distance (e.g., there are no symlinks between `flink' and the root). */ -static int +static int _GL_ATTRIBUTE_PURE symlink_ancestry (struct file_link *flink) { int ancestry = 0; @@ -506,6 +505,15 @@ exclude_languages (char *lang_names) langs_excluded = append_strings_to_vector (langs_excluded, lang_names, white_space); } +static int _GL_ATTRIBUTE_PURE +vector_length (char **vector) +{ + int length = 0; + while (*vector++) + length++; + return length; +} + static char ** append_strings_to_vector (char **vector_0, char *string, char const *delimiter_class) @@ -527,16 +535,7 @@ append_strings_to_vector (char **vector_0, char *string, return xnrealloc (vector_0, vector - vector_0, sizeof *vector_0); } -static int -vector_length (char **vector) -{ - int length = 0; - while (*vector++) - length++; - return length; -} - -static int +static int _GL_ATTRIBUTE_PURE string_in_vector (char const *string, char **vector) { while (*vector) @@ -1052,7 +1051,7 @@ member_file_qsort_compare (void const *x, void const *y) /****************************************************************************/ /* Hash stuff for `struct file_link'. */ -static unsigned long +static unsigned long _GL_ATTRIBUTE_PURE file_link_hash_1 (void const *key) { unsigned long result = 0; @@ -1063,7 +1062,7 @@ file_link_hash_1 (void const *key) return result; } -static unsigned long +static unsigned long _GL_ATTRIBUTE_PURE file_link_hash_2 (void const *key) { unsigned long result = 0; @@ -1074,7 +1073,7 @@ file_link_hash_2 (void const *key) return result; } -static int +static int _GL_ATTRIBUTE_PURE file_link_hash_compare (void const *x, void const *y) { int result; |