grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3
@ 2013-12-04 11:58 Doron Tsur
  2013-12-04 11:58 ` [PATCH 2/3] "-Wall -Wextra -Werror" compilation patches - part 2/3 Doron Tsur
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Doron Tsur @ 2013-12-04 11:58 UTC (permalink / raw)
  To: grub-devel; +Cc: Doron Tsur, itaib

Tests: Ubuntu 13.10 compilation
.../configure --prefix=/usr --enable-mm-debug --enable-cache-stats EFI_ARCH=x86_64 --with-platform=efi --enable-boot-time CFLAGS="-Wall -Wextra -Werror" && make
Signed-off-by: Doron Tsur <doront@mellanox.com>
---
 grub-core/gnulib/argp-fmtstream.c         |    2 +-
 grub-core/gnulib/argp-help.c              |    6 +++---
 grub-core/gnulib/argp-parse.c             |    4 ++--
 grub-core/gnulib/vasnprintf.c             |   18 +++++++++++++-----
 grub-core/lib/libgcrypt/cipher/rijndael.c |    3 ++-
 5 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/grub-core/gnulib/argp-fmtstream.c b/grub-core/gnulib/argp-fmtstream.c
index 02406ff..19fab18 100644
--- a/grub-core/gnulib/argp-fmtstream.c
+++ b/grub-core/gnulib/argp-fmtstream.c
@@ -234,7 +234,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
       else
 	{
 	  size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
-	  if (display_width < (ssize_t) fs->rmargin)
+	  if (display_width < (size_t) fs->rmargin)
 	    {
 	      /* The buffer contains a full line that fits within the maximum
 		 line width.  Reset point and scan the next line.  */
diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
index 2914f47..e01d40c 100644
--- a/grub-core/gnulib/argp-help.c
+++ b/grub-core/gnulib/argp-help.c
@@ -599,8 +599,8 @@ hol_entry_long_iterate (const struct hol_entry *entry,
 \f
 /* Iterator that returns true for the first short option.  */
 static int
-until_short (const struct argp_option *opt, const struct argp_option *real,
-             const char *domain, void *cookie)
+until_short (const struct argp_option *opt, const struct argp_option *real __attribute__((unused)),
+             const char *domain __attribute__((unused)), void *cookie __attribute__((unused)))
 {
   return oshort (opt) ? opt->key : 0;
 }
@@ -1269,7 +1269,7 @@ optional for any corresponding short options.");
 static int
 add_argless_short_opt (const struct argp_option *opt,
                        const struct argp_option *real,
-                       const char *domain, void *cookie)
+                       const char *domain __attribute__((unused)), void *cookie)
 {
   char **snao_end = cookie;
   if (!(opt->arg || real->arg)
diff --git a/grub-core/gnulib/argp-parse.c b/grub-core/gnulib/argp-parse.c
index 67ea32c..93cce25 100644
--- a/grub-core/gnulib/argp-parse.c
+++ b/grub-core/gnulib/argp-parse.c
@@ -144,7 +144,7 @@ static const struct argp_option argp_version_options[] =
 };
 
 static error_t
-argp_version_parser (int key, char *arg, struct argp_state *state)
+argp_version_parser (int key, char *arg __attribute__((unused)), struct argp_state *state)
 {
   switch (key)
     {
@@ -714,7 +714,7 @@ parser_parse_arg (struct parser *parser, char *val)
 /* Call the user parsers to parse the option OPT, with argument VAL, at the
    current position, returning any error.  */
 static error_t
-parser_parse_opt (struct parser *parser, int opt, char *val)
+parser_parse_opt (struct parser *parser, int opt, char *val __attribute__((unused)))
 {
   /* The group key encoded in the high bits; 0 for short opts or
      group_number + 1 for long opts.  */
diff --git a/grub-core/gnulib/vasnprintf.c b/grub-core/gnulib/vasnprintf.c
index 8fdab32..f636389 100644
--- a/grub-core/gnulib/vasnprintf.c
+++ b/grub-core/gnulib/vasnprintf.c
@@ -1532,7 +1532,7 @@ is_borderline (const char *digits, size_t precision)
    of sprintf or SNPRINTF of a single conversion directive.  */
 static size_t
 MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
-                 arg_type type, int flags, size_t width, int has_precision,
+                 arg_type type, int flags __attribute__((unused)), size_t width, int has_precision,
                  size_t precision, int pad_ourselves)
 {
   size_t tmp_length;
@@ -2693,7 +2693,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                               errno = EILSEQ;
                               return NULL;
                             }
-                          if (precision < count)
+                          if (precision < (size_t)count)
                             break;
                           arg_end++;
                           characters += count;
@@ -4606,13 +4606,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 arg_type type = a.arg[dp->arg_index].type;
                 int flags = dp->flags;
 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
-                int has_width;
                 size_t width;
 #endif
 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
                 int has_precision;
                 size_t precision;
 #endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+                int has_width;
+#endif
+#endif
 #if NEED_PRINTF_UNBOUNDED_PRECISION
                 int prec_ourselves;
 #else
@@ -4636,7 +4640,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #endif
 
 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 has_width = 0;
+#endif
                 width = 0;
                 if (dp->width_start != dp->width_end)
                   {
@@ -4665,7 +4671,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                           width = xsum (xtimes (width, 10), *digitp++ - '0');
                         while (digitp != dp->width_end);
                       }
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                     has_width = 1;
+#endif
                   }
 #endif
 
@@ -5306,7 +5314,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #endif
 
 #if !USE_SNPRINTF
-                    if (count >= tmp_length)
+                    if ((size_t)count >= tmp_length)
                       /* tmp_length was incorrectly calculated - fix the
                          code above!  */
                       abort ();
@@ -5397,7 +5405,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 
 #if DCHAR_IS_TCHAR && !USE_SNPRINTF
                     /* Make room for the result.  */
-                    if (count > allocated - length)
+                    if ((size_t)count > allocated - length)
                       {
                         /* Need at least count elements.  But allocate
                            proportionally.  */
diff --git a/grub-core/lib/libgcrypt/cipher/rijndael.c b/grub-core/lib/libgcrypt/cipher/rijndael.c
index 4e8eb3a..b79f0ce 100644
--- a/grub-core/lib/libgcrypt/cipher/rijndael.c
+++ b/grub-core/lib/libgcrypt/cipher/rijndael.c
@@ -181,7 +181,8 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
   static int initialized = 0;
   static const char *selftest_failed=0;
   int rounds;
-  int i,j, r, t, rconpointer = 0;
+  int j, r, t, rconpointer = 0;
+  unsigned i = 0;
   int KC;
   union
   {
-- 
1.7.8.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] "-Wall -Wextra -Werror" compilation patches - part 2/3
  2013-12-04 11:58 [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Doron Tsur
@ 2013-12-04 11:58 ` Doron Tsur
  2013-12-04 11:58 ` [PATCH 3/3] "-Wall -Wextra -Werror" compilation patches - part 3/3 grub/grub-core/lib/libgcrypt-grub Doron Tsur
  2013-12-04 12:33 ` [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Vladimir 'φ-coder/phcoder' Serbinenko
  2 siblings, 0 replies; 4+ messages in thread
From: Doron Tsur @ 2013-12-04 11:58 UTC (permalink / raw)
  To: grub-devel; +Cc: Doron Tsur, itaib

Tests: Ubuntu 13.10 compilation
.../configure --prefix=/usr --enable-mm-debug --enable-cache-stats EFI_ARCH=x86_64 --with-platform=efi --enable-boot-time CFLAGS="-Wall -Wextra -Werror" && make
Signed-off-by: Doron Tsur <doront@mellanox.com>
---
 grub-core/Makefile.core.def       |    2 +-
 grub-core/gnulib/Makefile.am      |    2 +-
 grub-core/gnulib/argp-fmtstream.c |    2 +-
 grub-core/gnulib/argp-help.c      |    2 +-
 grub-core/gnulib/getopt_int.h     |    2 +-
 grub-core/gnulib/regcomp.c        |   33 +++++++++++++++++++--------------
 grub-core/gnulib/regex_internal.c |    8 +++++---
 grub-core/gnulib/regex_internal.h |   13 +++++++++----
 grub-core/gnulib/regexec.c        |   20 ++++++++++----------
 9 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 57abb49..85a1110 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -2220,7 +2220,7 @@ module = {
   common = lib/libgcrypt-grub/mpi/mpi-inline.c;
   common = lib/libgcrypt_wrap/mem.c;
 
-  cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare';
+  cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare -Wno-unused-but-set-variable';
   cppflags = '$(CPPFLAGS_GCRY)';
 };
 
diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am
index 3444397..22e67e6 100644
--- a/grub-core/gnulib/Makefile.am
+++ b/grub-core/gnulib/Makefile.am
@@ -39,7 +39,7 @@ DISTCLEANFILES =
 MAINTAINERCLEANFILES =
 
 AM_CPPFLAGS =
-AM_CFLAGS =
+AM_CFLAGS = -Wno-type-limits
 
 noinst_LIBRARIES += libgnu.a
 
diff --git a/grub-core/gnulib/argp-fmtstream.c b/grub-core/gnulib/argp-fmtstream.c
index 19fab18..9f4f632 100644
--- a/grub-core/gnulib/argp-fmtstream.c
+++ b/grub-core/gnulib/argp-fmtstream.c
@@ -120,7 +120,7 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
 \f
 
 /* Return the pointer to the first character that doesn't fit in l columns.  */
-static inline const ptrdiff_t
+static inline ptrdiff_t
 add_width (const char *ptr, const char *end, size_t l)
 {
   mbstate_t ps;
diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
index e01d40c..54d0664 100644
--- a/grub-core/gnulib/argp-help.c
+++ b/grub-core/gnulib/argp-help.c
@@ -466,7 +466,7 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
 
       assert (hol->entries && hol->short_options);
       if (SIZE_MAX <= UINT_MAX)
-        assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+        assert (hol->num_entries <= (SIZE_MAX / sizeof (struct hol_entry)) );
 
       /* Fill in the entries.  */
       so = hol->short_options;
diff --git a/grub-core/gnulib/getopt_int.h b/grub-core/gnulib/getopt_int.h
index a6e4b9e..51afb60 100644
--- a/grub-core/gnulib/getopt_int.h
+++ b/grub-core/gnulib/getopt_int.h
@@ -113,7 +113,7 @@ struct _getopt_data
 
 /* The initializer is necessary to set OPTIND and OPTERR to their
    default values and to clear the initialization flag.  */
-#define _GETOPT_DATA_INITIALIZER        { 1, 1 }
+#define _GETOPT_DATA_INITIALIZER        { .optind = 1, .opterr = 1 }
 
 extern int _getopt_internal_r (int ___argc, char **___argv,
                                const char *__shortopts,
diff --git a/grub-core/gnulib/regcomp.c b/grub-core/gnulib/regcomp.c
index 596e0cf..c1972b6 100644
--- a/grub-core/gnulib/regcomp.c
+++ b/grub-core/gnulib/regcomp.c
@@ -334,7 +334,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
 		*p++ = dfa->nodes[node].opr.c;
 	      memset (&state, '\0', sizeof (state));
 	      if (__mbrtowc (&wc, (const char *) buf, p - buf,
-			     &state) == p - buf
+			     &state) == ((size_t)(p - buf))
 		  && (__wcrtomb ((char *) buf, towlower (wc), &state)
 		      != (size_t) -1))
 		re_set_fastmap (fastmap, false, buf[0]);
@@ -540,7 +540,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 __attribute__((unused)),
 	  char *_Restrict_ errbuf, size_t errbuf_size)
 #endif
 {
@@ -928,7 +928,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
 		if (wch != WEOF)
 		  dfa->sb_char[i] |= (bitset_word_t) 1 << j;
 # ifndef _LIBC
-		if (isascii (ch) && wch != ch)
+		if (isascii (ch) && ((int)wch) != ch)
 		  dfa->map_notascii = 1;
 # endif
 	      }
@@ -1418,7 +1418,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 __attribute__((unused)), bin_tree_t *node)
 {
   switch (node->token.type)
     {
@@ -2716,9 +2716,9 @@ build_range_exp (const reg_syntax_t syntax,
 	      : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
 		 : 0));
     start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
-		? __btowc (start_ch) : start_elem->opr.wch);
+		? __btowc (start_ch) : (wint_t)(start_elem->opr.wch));
     end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
-	      ? __btowc (end_ch) : end_elem->opr.wch);
+	      ? __btowc (end_ch) : (wint_t)(end_elem->opr.wch));
     if (start_wc == WEOF || end_wc == WEOF)
       return REG_ECOLLATE;
     else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
@@ -2762,7 +2762,7 @@ build_range_exp (const reg_syntax_t syntax,
     /* Build the table for single byte characters.  */
     for (wc = 0; wc < SBC_MAX; ++wc)
       {
-	if (start_wc <= wc && wc <= end_wc)
+	if (start_wc <= ((wint_t)wc) && ((wint_t)wc) <= end_wc)
 	  bitset_set (sbcset, wc);
       }
   }
@@ -2797,8 +2797,8 @@ build_range_exp (const reg_syntax_t syntax,
 static reg_errcode_t
 internal_function
 # ifdef RE_ENABLE_I18N
-build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
-			Idx *coll_sym_alloc, const unsigned char *name)
+build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset __attribute__((unused)),
+			Idx *coll_sym_alloc __attribute__((unused)), const unsigned char *name)
 # else /* not RE_ENABLE_I18N */
 build_collating_symbol (bitset_t sbcset, const unsigned char *name)
 # endif /* not RE_ENABLE_I18N */
@@ -3366,7 +3366,7 @@ 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 __attribute__((unused)),
 		       reg_syntax_t syntax, bool accept_hyphen)
 {
 #ifdef RE_ENABLE_I18N
@@ -3451,10 +3451,15 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
      EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
      is a pointer argument since we may update it.  */
 
+#ifdef _LIBC
+#define build_equiv_class_ATTRIBUTE_UNUSED
+#else
+#define build_equiv_class_ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
 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 build_equiv_class_ATTRIBUTE_UNUSED,
+		   Idx *equiv_class_alloc build_equiv_class_ATTRIBUTE_UNUSED, const unsigned char *name)
 #else /* not RE_ENABLE_I18N */
 build_equiv_class (bitset_t sbcset, const unsigned char *name)
 #endif /* not RE_ENABLE_I18N */
@@ -3760,7 +3765,7 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
 	      || num == REG_ERROR)
 	     ? REG_ERROR
 	     : num == REG_MISSING
-	     ? c - '0'
+	     ? (Idx)(c - '0')
 	     : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
     }
   return num;
@@ -3860,7 +3865,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 __attribute__((unused)), bin_tree_t *node)
 {
   free_token (&node->token);
   return REG_NOERROR;
diff --git a/grub-core/gnulib/regex_internal.c b/grub-core/gnulib/regex_internal.c
index 899b0ae..2b03dfd 100644
--- a/grub-core/gnulib/regex_internal.c
+++ b/grub-core/gnulib/regex_internal.c
@@ -224,7 +224,8 @@ build_wcs_buffer (re_string_t *pstr)
       /* Apply the translation if we need.  */
       if (BE (pstr->trans != NULL, 0))
 	{
-	  int i, ch;
+	  int ch;
+	  Idx i;
 
 	  for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
 	    {
@@ -367,7 +368,8 @@ build_wcs_upper_buffer (re_string_t *pstr)
 	prev_st = pstr->cur_state;
 	if (BE (pstr->trans != NULL, 0))
 	  {
-	    int i, ch;
+	    int ch;
+	    Idx i;
 
 	    for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
 	      {
@@ -751,7 +753,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
 			  memset (&cur_state, 0, sizeof (cur_state));
 			  mbclen = __mbrtowc (&wc2, (const char *) pp, mlen,
 					      &cur_state);
-			  if (raw + offset - p <= mbclen
+			  if ( ( ((size_t)(raw + offset - p)) <= mbclen)
 			      && mbclen < (size_t) -2)
 			    {
 			      memset (&pstr->cur_state, '\0',
diff --git a/grub-core/gnulib/regex_internal.h b/grub-core/gnulib/regex_internal.h
index c467b29..121f56c 100644
--- a/grub-core/gnulib/regex_internal.h
+++ b/grub-core/gnulib/regex_internal.h
@@ -399,7 +399,7 @@ struct re_string_t
   unsigned char offsets_needed;
   unsigned char newline_anchor;
   unsigned char word_ops_used;
-  int mb_cur_max;
+  Idx mb_cur_max;
 };
 typedef struct re_string_t re_string_t;
 
@@ -624,7 +624,7 @@ typedef struct
   Idx nbkref_ents;
   Idx abkref_ents;
   struct re_backref_cache_entry *bkref_ents;
-  int max_mb_elem_len;
+  Idx max_mb_elem_len;
   Idx nsub_tops;
   Idx asub_tops;
   re_sub_match_top_t **sub_tops;
@@ -691,7 +691,7 @@ struct re_dfa_t
   unsigned int is_utf8 : 1;
   unsigned int map_notascii : 1;
   unsigned int word_ops_used : 1;
-  int mb_cur_max;
+  Idx mb_cur_max;
   bitset_t word_char;
   reg_syntax_t syntax;
   Idx *subexp_map;
@@ -825,9 +825,14 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
 }
 
 # ifndef NOT_IN_libc
+#  ifdef _LIBC
+#define re_string_elem_size_at_ATTRIBUTE_UNUSED
+#else
+#define re_string_elem_size_at_ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
 static int
 internal_function __attribute__ ((pure, unused))
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+re_string_elem_size_at (const re_string_t *pstr re_string_elem_size_at_ATTRIBUTE_UNUSED, Idx idx re_string_elem_size_at_ATTRIBUTE_UNUSED)
 {
 #  ifdef _LIBC
   const unsigned char *p, *extra;
diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c
index f632cd4..6d997c5 100644
--- a/grub-core/gnulib/regexec.c
+++ b/grub-core/gnulib/regexec.c
@@ -490,7 +490,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
     {
       if (ret_len)
 	{
-	  assert (pmatch[0].rm_so == start);
+	  assert (((Idx)(pmatch[0].rm_so)) == start);
 	  rval = pmatch[0].rm_eo - start;
 	}
       else
@@ -928,11 +928,11 @@ re_search_internal (const regex_t *preg,
 	    if (BE (mctx.input.offsets_needed != 0, 0))
 	      {
 		pmatch[reg_idx].rm_so =
-		  (pmatch[reg_idx].rm_so == mctx.input.valid_len
+		  (((Idx)(pmatch[reg_idx].rm_so)) == mctx.input.valid_len
 		   ? mctx.input.valid_raw_len
 		   : mctx.input.offsets[pmatch[reg_idx].rm_so]);
 		pmatch[reg_idx].rm_eo =
-		  (pmatch[reg_idx].rm_eo == mctx.input.valid_len
+		  (((Idx)(pmatch[reg_idx].rm_eo)) == mctx.input.valid_len
 		   ? mctx.input.valid_raw_len
 		   : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
 	      }
@@ -1472,11 +1472,11 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
     }
   memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
 
-  for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
+  for (idx = (Idx)(pmatch[0].rm_so); idx <= (Idx)(pmatch[0].rm_eo) ;)
     {
       update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
 
-      if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
+      if (idx == (Idx)(pmatch[0].rm_eo) && cur_node == mctx->last_node)
 	{
 	  Idx reg_idx;
 	  if (fs)
@@ -1575,7 +1575,7 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
       if (reg_num < nmatch)
 	{
 	  /* We are at the last node of this sub expression.  */
-	  if (pmatch[reg_num].rm_so < cur_idx)
+	  if (((Idx)(pmatch[reg_num].rm_so)) < cur_idx)
 	    {
 	      pmatch[reg_num].rm_eo = cur_idx;
 	      /* This is a non-empty match or we are not inside an optional
@@ -1629,7 +1629,7 @@ internal_function
 sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
 {
   reg_errcode_t err;
-  int null_cnt = 0;
+  Idx null_cnt = 0;
   Idx str_idx = sctx->last_str_idx;
   re_node_set cur_dest;
 
@@ -2568,7 +2568,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
 
       /* The node can accepts 'naccepted' bytes.  */
       dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
-      mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
+      mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < (Idx)naccepted) ? (Idx)naccepted
 			       : mctx->max_mb_elem_len);
       err = clean_state_log_if_needed (mctx, dest_idx);
       if (BE (err != REG_NOERROR, 0))
@@ -3831,7 +3831,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
       if (str_idx + char_len > input->len)
 	return 0;
 
-      for (i = 1; i < char_len; ++i)
+      for (i = 1; i < ((Idx)char_len); ++i)
 	{
 	  d = re_string_byte_at (input, str_idx + i);
 	  if (d < 0x80 || d > 0xbf)
@@ -4140,7 +4140,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
 
   /* Double the lengths of the buffers, but allocate at least MIN_LEN.  */
   ret = re_string_realloc_buffers (pstr,
-				   MAX (min_len,
+				   MAX ((Idx)min_len,
 					MIN (pstr->len, pstr->bufs_len * 2)));
   if (BE (ret != REG_NOERROR, 0))
     return ret;
-- 
1.7.8.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] "-Wall -Wextra -Werror" compilation patches - part 3/3 grub/grub-core/lib/libgcrypt-grub
  2013-12-04 11:58 [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Doron Tsur
  2013-12-04 11:58 ` [PATCH 2/3] "-Wall -Wextra -Werror" compilation patches - part 2/3 Doron Tsur
@ 2013-12-04 11:58 ` Doron Tsur
  2013-12-04 12:33 ` [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Vladimir 'φ-coder/phcoder' Serbinenko
  2 siblings, 0 replies; 4+ messages in thread
From: Doron Tsur @ 2013-12-04 11:58 UTC (permalink / raw)
  To: grub-devel; +Cc: Doron Tsur, itaib

Tests: Ubuntu 13.10 compilation
.../configure --prefix=/usr --enable-mm-debug --enable-cache-stats EFI_ARCH=x86_64 --with-platform=efi --enable-boot-time CFLAGS="-Wall -Wextra -Werror" && make
---
 conf/Makefile.common |    2 +-
 util/import_gcry.py  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/conf/Makefile.common b/conf/Makefile.common
index 8a71f13..9b898d2 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -79,7 +79,7 @@ CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/g
 CFLAGS_POSIX = -fno-builtin
 CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap
 
-CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX)
+CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX) -Wno-empty-body
 CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap $(CPPFLAGS_POSIX) -D_GCRYPT_IN_LIBGCRYPT=1 -I$(top_srcdir)/include/grub/gcrypt
 
 CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime
diff --git a/util/import_gcry.py b/util/import_gcry.py
index 1319a8c..9e00b8b 100644
--- a/util/import_gcry.py
+++ b/util/import_gcry.py
@@ -473,7 +473,7 @@ for cipher_file in cipher_files:
                 conf.write ("  cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare';\n")
             elif modname == "gcry_rijndael" or modname == "gcry_md4" or modname == "gcry_md5" or modname == "gcry_rmd160" or modname == "gcry_sha1" or modname == "gcry_sha256" or modname == "gcry_sha512" or modname == "gcry_tiger":
                 # Alignment checked by hand
-                conf.write ("  cflags = '$(CFLAGS_GCRY) -Wno-cast-align';\n");
+                conf.write ("  cflags = '$(CFLAGS_GCRY) -Wno-cast-align -fno-strict-aliasing';\n");
             else:
                 conf.write ("  cflags = '$(CFLAGS_GCRY)';\n");
             conf.write ("  cppflags = '$(CPPFLAGS_GCRY)';\n");
-- 
1.7.8.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3
  2013-12-04 11:58 [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Doron Tsur
  2013-12-04 11:58 ` [PATCH 2/3] "-Wall -Wextra -Werror" compilation patches - part 2/3 Doron Tsur
  2013-12-04 11:58 ` [PATCH 3/3] "-Wall -Wextra -Werror" compilation patches - part 3/3 grub/grub-core/lib/libgcrypt-grub Doron Tsur
@ 2013-12-04 12:33 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-04 12:33 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 8296 bytes --]

On 04.12.2013 12:58, Doron Tsur wrote:
> Tests: Ubuntu 13.10 compilation
> .../configure --prefix=/usr --enable-mm-debug --enable-cache-stats EFI_ARCH=x86_64 --with-platform=efi --enable-boot-time CFLAGS="-Wall -Wextra -Werror" && make
All of your patches are for external projects (gnulib and libgcrypt). I
suggect contacting them directly. We can backport patches from them but
we don't usually have local patches for their trees.
> Signed-off-by: Doron Tsur <doront@mellanox.com>
> ---
>  grub-core/gnulib/argp-fmtstream.c         |    2 +-
>  grub-core/gnulib/argp-help.c              |    6 +++---
>  grub-core/gnulib/argp-parse.c             |    4 ++--
>  grub-core/gnulib/vasnprintf.c             |   18 +++++++++++++-----
>  grub-core/lib/libgcrypt/cipher/rijndael.c |    3 ++-
>  5 files changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/grub-core/gnulib/argp-fmtstream.c b/grub-core/gnulib/argp-fmtstream.c
> index 02406ff..19fab18 100644
> --- a/grub-core/gnulib/argp-fmtstream.c
> +++ b/grub-core/gnulib/argp-fmtstream.c
> @@ -234,7 +234,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
>        else
>  	{
>  	  size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
> -	  if (display_width < (ssize_t) fs->rmargin)
> +	  if (display_width < (size_t) fs->rmargin)
>  	    {
>  	      /* The buffer contains a full line that fits within the maximum
>  		 line width.  Reset point and scan the next line.  */
> diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
> index 2914f47..e01d40c 100644
> --- a/grub-core/gnulib/argp-help.c
> +++ b/grub-core/gnulib/argp-help.c
> @@ -599,8 +599,8 @@ hol_entry_long_iterate (const struct hol_entry *entry,
>  \f
>  /* Iterator that returns true for the first short option.  */
>  static int
> -until_short (const struct argp_option *opt, const struct argp_option *real,
> -             const char *domain, void *cookie)
> +until_short (const struct argp_option *opt, const struct argp_option *real __attribute__((unused)),
> +             const char *domain __attribute__((unused)), void *cookie __attribute__((unused)))
>  {
>    return oshort (opt) ? opt->key : 0;
>  }
> @@ -1269,7 +1269,7 @@ optional for any corresponding short options.");
>  static int
>  add_argless_short_opt (const struct argp_option *opt,
>                         const struct argp_option *real,
> -                       const char *domain, void *cookie)
> +                       const char *domain __attribute__((unused)), void *cookie)
>  {
>    char **snao_end = cookie;
>    if (!(opt->arg || real->arg)
> diff --git a/grub-core/gnulib/argp-parse.c b/grub-core/gnulib/argp-parse.c
> index 67ea32c..93cce25 100644
> --- a/grub-core/gnulib/argp-parse.c
> +++ b/grub-core/gnulib/argp-parse.c
> @@ -144,7 +144,7 @@ static const struct argp_option argp_version_options[] =
>  };
>  
>  static error_t
> -argp_version_parser (int key, char *arg, struct argp_state *state)
> +argp_version_parser (int key, char *arg __attribute__((unused)), struct argp_state *state)
>  {
>    switch (key)
>      {
> @@ -714,7 +714,7 @@ parser_parse_arg (struct parser *parser, char *val)
>  /* Call the user parsers to parse the option OPT, with argument VAL, at the
>     current position, returning any error.  */
>  static error_t
> -parser_parse_opt (struct parser *parser, int opt, char *val)
> +parser_parse_opt (struct parser *parser, int opt, char *val __attribute__((unused)))
>  {
>    /* The group key encoded in the high bits; 0 for short opts or
>       group_number + 1 for long opts.  */
> diff --git a/grub-core/gnulib/vasnprintf.c b/grub-core/gnulib/vasnprintf.c
> index 8fdab32..f636389 100644
> --- a/grub-core/gnulib/vasnprintf.c
> +++ b/grub-core/gnulib/vasnprintf.c
> @@ -1532,7 +1532,7 @@ is_borderline (const char *digits, size_t precision)
>     of sprintf or SNPRINTF of a single conversion directive.  */
>  static size_t
>  MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
> -                 arg_type type, int flags, size_t width, int has_precision,
> +                 arg_type type, int flags __attribute__((unused)), size_t width, int has_precision,
>                   size_t precision, int pad_ourselves)
>  {
>    size_t tmp_length;
> @@ -2693,7 +2693,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>                                errno = EILSEQ;
>                                return NULL;
>                              }
> -                          if (precision < count)
> +                          if (precision < (size_t)count)
>                              break;
>                            arg_end++;
>                            characters += count;
> @@ -4606,13 +4606,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>                  arg_type type = a.arg[dp->arg_index].type;
>                  int flags = dp->flags;
>  #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
> -                int has_width;
>                  size_t width;
>  #endif
>  #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
>                  int has_precision;
>                  size_t precision;
>  #endif
> +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
> +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
> +                int has_width;
> +#endif
> +#endif
>  #if NEED_PRINTF_UNBOUNDED_PRECISION
>                  int prec_ourselves;
>  #else
> @@ -4636,7 +4640,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>  #endif
>  
>  #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
> +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
>                  has_width = 0;
> +#endif
>                  width = 0;
>                  if (dp->width_start != dp->width_end)
>                    {
> @@ -4665,7 +4671,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>                            width = xsum (xtimes (width, 10), *digitp++ - '0');
>                          while (digitp != dp->width_end);
>                        }
> +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
>                      has_width = 1;
> +#endif
>                    }
>  #endif
>  
> @@ -5306,7 +5314,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>  #endif
>  
>  #if !USE_SNPRINTF
> -                    if (count >= tmp_length)
> +                    if ((size_t)count >= tmp_length)
>                        /* tmp_length was incorrectly calculated - fix the
>                           code above!  */
>                        abort ();
> @@ -5397,7 +5405,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
>  
>  #if DCHAR_IS_TCHAR && !USE_SNPRINTF
>                      /* Make room for the result.  */
> -                    if (count > allocated - length)
> +                    if ((size_t)count > allocated - length)
>                        {
>                          /* Need at least count elements.  But allocate
>                             proportionally.  */
> diff --git a/grub-core/lib/libgcrypt/cipher/rijndael.c b/grub-core/lib/libgcrypt/cipher/rijndael.c
> index 4e8eb3a..b79f0ce 100644
> --- a/grub-core/lib/libgcrypt/cipher/rijndael.c
> +++ b/grub-core/lib/libgcrypt/cipher/rijndael.c
> @@ -181,7 +181,8 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
>    static int initialized = 0;
>    static const char *selftest_failed=0;
>    int rounds;
> -  int i,j, r, t, rconpointer = 0;
> +  int j, r, t, rconpointer = 0;
> +  unsigned i = 0;
>    int KC;
>    union
>    {
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-04 12:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-04 11:58 [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Doron Tsur
2013-12-04 11:58 ` [PATCH 2/3] "-Wall -Wextra -Werror" compilation patches - part 2/3 Doron Tsur
2013-12-04 11:58 ` [PATCH 3/3] "-Wall -Wextra -Werror" compilation patches - part 3/3 grub/grub-core/lib/libgcrypt-grub Doron Tsur
2013-12-04 12:33 ` [PATCH 1/3] "-Wall -Wextra -Werror" compilation patches - part 1/3 Vladimir 'φ-coder/phcoder' Serbinenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).