diff options
author | Jim Meyering <meyering@redhat.com> | 2010-01-06 12:06:14 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-02-03 21:52:30 +0100 |
commit | 26ad4e6d148f4d56ebb80417711c8a67082d43d7 (patch) | |
tree | 8fb79f6a0701eb72526acc7bc6e77ca2cd8e374f | |
parent | 222bdcb32ecd45e6be7850515ef3fde0b682c88f (diff) | |
download | grep-26ad4e6d148f4d56ebb80417711c8a67082d43d7.tar.gz |
build: avoid warnings in gnulib-supplied regex files
Now that we enable more warnings in lib/, we choose
to avoid some via patches applied by bootstrap, using
files in the gl/ hierarchy. Other, less-important
warnings are avoided simply by turning off the
-Wold-style-definition option and using a slightly
relaxed set of warnings $(GNULIB_WARN_CFLAGS) in lib/.
* gl/lib/regcomp.c.diff: Avoid warnings.
* gl/lib/regex_internal.c.diff: Likewise.
* gl/lib/regex_internal.h.diff: Likewise.
* gl/lib/regexec.c.diff: Likewise.
* configure.ac (GNULIB_PORTCHECK): Disable only -Wold-style-definition.
* lib/Makefile.am (AM_CFLAGS): Use $(GNULIB_WARN_CFLAGS) rather
than the slightly more strict $(WARN_CFLAGS).
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | gl/lib/regcomp.c.diff | 63 | ||||
-rw-r--r-- | gl/lib/regex_internal.c.diff | 25 | ||||
-rw-r--r-- | gl/lib/regex_internal.h.diff | 14 | ||||
-rw-r--r-- | gl/lib/regexec.c.diff | 45 | ||||
-rw-r--r-- | lib/Makefile.am | 2 |
6 files changed, 151 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 1521f7e8..5949f0ea 100644 --- a/configure.ac +++ b/configure.ac @@ -129,9 +129,9 @@ if test "$gl_gcc_warnings" = yes; then # We use a slightly smaller set of warning options for lib/. # Remove the following and save the result in GNULIB_WARN_CFLAGS. nw= - nw="$nw -Wuninitialized" - nw="$nw -Wunused-macros" - nw="$nw -Wmissing-prototypes" + #nw="$nw -Wuninitialized" + #nw="$nw -Wunused-macros" + #nw="$nw -Wmissing-prototypes" nw="$nw -Wold-style-definition" gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw]) AC_SUBST([GNULIB_WARN_CFLAGS]) diff --git a/gl/lib/regcomp.c.diff b/gl/lib/regcomp.c.diff new file mode 100644 index 00000000..63fc1875 --- /dev/null +++ b/gl/lib/regcomp.c.diff @@ -0,0 +1,63 @@ +diff --git a/lib/regcomp.c b/lib/regcomp.c +index d5968bd..4926676 100644 +--- a/lib/regcomp.c ++++ b/lib/regcomp.c +@@ -541,7 +541,7 @@ regerror (errcode, preg, errbuf, errbuf_size) + size_t errbuf_size; + #else /* size_t might promote */ + size_t +-regerror (int errcode, const regex_t *_Restrict_ preg, ++regerror (int errcode, const regex_t *_Restrict_ preg _UNUSED_PARAMETER_, + char *_Restrict_ errbuf, size_t errbuf_size) + #endif + { +@@ -1383,7 +1383,7 @@ calc_first (void *extra, bin_tree_t *node) + + /* Pass 2: compute NEXT on the tree. Preorder visit. */ + static reg_errcode_t +-calc_next (void *extra, bin_tree_t *node) ++calc_next (void *extra _UNUSED_PARAMETER_, bin_tree_t *node) + { + switch (node->token.type) + { +@@ -2744,7 +2744,8 @@ static reg_errcode_t + internal_function + build_collating_symbol (bitset_t sbcset, + # ifdef RE_ENABLE_I18N +- re_charset_t *mbcset, Idx *coll_sym_alloc, ++ re_charset_t *mbcset _UNUSED_PARAMETER_, ++ Idx *coll_sym_alloc _UNUSED_PARAMETER_, + # endif + const unsigned char *name) + { +@@ -3323,7 +3324,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, + + static reg_errcode_t + parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, +- re_token_t *token, int token_len, re_dfa_t *dfa, ++ re_token_t *token, int token_len, ++ re_dfa_t *dfa _UNUSED_PARAMETER_, + reg_syntax_t syntax, bool accept_hyphen) + { + #ifdef RE_ENABLE_I18N +@@ -3410,8 +3412,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, + + static reg_errcode_t + #ifdef RE_ENABLE_I18N +-build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, +- Idx *equiv_class_alloc, const unsigned char *name) ++build_equiv_class (bitset_t sbcset, re_charset_t *mbcset _UNUSED_PARAMETER_, ++ Idx *equiv_class_alloc _UNUSED_PARAMETER_, ++ const unsigned char *name) + #else /* not RE_ENABLE_I18N */ + build_equiv_class (bitset_t sbcset, const unsigned char *name) + #endif /* not RE_ENABLE_I18N */ +@@ -3816,7 +3819,7 @@ free_token (re_token_t *node) + and its children. */ + + static reg_errcode_t +-free_tree (void *extra, bin_tree_t *node) ++free_tree (void *extra _UNUSED_PARAMETER_, bin_tree_t *node) + { + free_token (&node->token); + return REG_NOERROR; diff --git a/gl/lib/regex_internal.c.diff b/gl/lib/regex_internal.c.diff new file mode 100644 index 00000000..2cede3c0 --- /dev/null +++ b/gl/lib/regex_internal.c.diff @@ -0,0 +1,25 @@ +diff --git a/lib/regex_internal.c b/lib/regex_internal.c +index 904b88e..61c8d9d 100644 +--- a/lib/regex_internal.c ++++ b/lib/regex_internal.c +@@ -18,6 +18,8 @@ + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + ++#include "verify.h" ++#include "intprops.h" + static void re_string_construct_common (const char *str, Idx len, + re_string_t *pstr, + RE_TRANSLATE_TYPE trans, bool icase, +@@ -1390,7 +1392,10 @@ static void + internal_function + re_node_set_remove_at (re_node_set *set, Idx idx) + { +- if (idx < 0 || idx >= set->nelem) ++ verify (! TYPE_SIGNED (Idx)); ++ /* if (idx < 0) ++ return; */ ++ if (idx >= set->nelem) + return; + --set->nelem; + for (; idx < set->nelem; idx++) diff --git a/gl/lib/regex_internal.h.diff b/gl/lib/regex_internal.h.diff new file mode 100644 index 00000000..d1506a6f --- /dev/null +++ b/gl/lib/regex_internal.h.diff @@ -0,0 +1,14 @@ +diff --git i/lib/regex_internal.h w/lib/regex_internal.h +index 859832f..3c7fe06 100644 +--- i/lib/regex_internal.h ++++ w/lib/regex_internal.h +@@ -826,7 +826,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx) + + static int + internal_function __attribute ((pure)) +-re_string_elem_size_at (const re_string_t *pstr, Idx idx) ++re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_, ++ Idx idx _UNUSED_PARAMETER_) + { + # ifdef _LIBC + const unsigned char *p, *extra; diff --git a/gl/lib/regexec.c.diff b/gl/lib/regexec.c.diff new file mode 100644 index 00000000..d9b6d1cd --- /dev/null +++ b/gl/lib/regexec.c.diff @@ -0,0 +1,45 @@ +diff --git a/lib/regexec.c b/lib/regexec.c +index 21a8166..7762437 100644 +--- a/lib/regexec.c ++++ b/lib/regexec.c +@@ -18,6 +18,8 @@ + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + ++#include "verify.h" ++#include "intprops.h" + static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, + Idx n) internal_function; + static void match_ctx_clean (re_match_context_t *mctx) internal_function; +@@ -378,8 +380,11 @@ re_search_2_stub (struct re_pattern_buffer *bufp, + Idx len = length1 + length2; + char *s = NULL; + +- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) +- return -2; ++ verify (! TYPE_SIGNED (Idx)); ++ if (BE (len < length1, 0)) ++ return -2; ++ /* if (BE (length1 < 0 || length2 < 0 || stop < 0, 0)) ++ return -2; */ + + /* Concatenate the strings. */ + if (length2 > 0) +@@ -431,11 +436,14 @@ re_search_stub (struct re_pattern_buffer *bufp, + Idx last_start = start + range; + + /* Check for out-of-range. */ +- if (BE (start < 0 || start > length, 0)) +- return -1; ++ verify (! TYPE_SIGNED (Idx)); ++ /* if (BE (start < 0, 0)) ++ return -1; */ ++ if (BE (start > length, 0)) ++ return -1; + if (BE (length < last_start || (0 <= range && last_start < start), 0)) + last_start = length; +- else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) ++ else if (BE (/* last_start < 0 || */ (range < 0 && start <= last_start), 0)) + last_start = 0; + + __libc_lock_lock (dfa->lock); diff --git a/lib/Makefile.am b/lib/Makefile.am index 7b34222b..c3760d6c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,7 +18,7 @@ include gnulib.mk INCLUDES = -I.. -I$(srcdir) -AM_CFLAGS += $(WARN_CFLAGS) $(WERROR_CFLAGS) +AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) libgreputils_a_SOURCES += \ savedir.c savedir.h |