As a result of the comment from Dan I revoke all previous patches I did sent 
today, and have created a new batch of patches.

Those patches do are smaller, and do not include the to-int() conversions I had 
in my previous patches, because further investigation learned that in all cases 
it would be solved by an other design of the underlaying code.

Jaap de Wolff
> -----Oorspronkelijk bericht-----
> Van: lilyp...@de-wolff.org <lilyp...@de-wolff.org>
> Verzonden: Sunday, May 10, 2020 4:58 PM
> Aan: 'Dan Eble' <d...@faithful.be>
> CC: 'lilypond-devel@gnu.org' <lilypond-devel@gnu.org>
> Onderwerp: RE: Another patch
> 
> Dan,
> 
> As you already did see, I did not a simple cast, but instead my solution is 
> raising
> an error in those cases where a simple cast would change the value tested.
> However, I will follow your suggestion, and break the patch in parts.
> I also will pay attention to your particular example, as I think this is the 
> only
> case of the now solved warnings where the int in a next function is casted to 
> a
> smaller type.
> 
> Jaap de Wolff
> 
> > -----Oorspronkelijk bericht-----
> > Van: Dan Eble <d...@faithful.be>
> > Verzonden: Sunday, May 10, 2020 4:31 PM
> > Aan: lilyp...@de-wolff.org
> > CC: lilypond-devel@gnu.org
> > Onderwerp: Re: Another patch
> >
> > On May 10, 2020, at 08:11, lilyp...@de-wolff.org wrote:
> > >
> > > I did replace all implicit casts to an int by a inline function,
> > > checking if the value is valid, and then casting  to int.
> > >
> > > Together with my previous patch now all but one compiler warnings
> > > are solved.
> >
> > Jaap,
> >
> > I love the fact that you are taking the initiative to work on these.
> > I haven't reviewed them thoroughly, but my first comment is a note of
> > caution.  A couple of warnings, like the printf one, are just simple
> > oversights; however, many of the warnings that remain in LilyPond are the
> tip of an iceberg.
> >
> > There was a discussion on the developer list about simply casting to
> > silence warnings, but more developers were in favor of leaving the
> > warnings in until someone is motivated to fix them properly.
> >
> > I commend you that your work is not just simply casting, but in at
> > least some cases, it still doesn't appear to be going to the depth
> > these issues deserve.  For example, the number of tracks in a MIDI
> > file is a 16-bit number[1], so clipping to INT_MAX isn't quite right.
> > (I've got an old branch where I've fixed the header generation to use
> > uint16_t, but it's still missing code to warn properly when the number
> > of tracks needs to be clipped.  I'll try to rebase that to save you
> > the work.)
> >
> > I encourage you to sort the simple and obvious fixes (like the printf
> > one) into one commit, and the other cases into their own commits.  It
> > will limit the consequences if we later have to revert a change
> > because of a subtle bug that escaped regression testing.
> >
> > Regards,
> > —
> > Dan
> >
> > [1]
> > http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat
> > .ht
> > ml#BM2_1
>From 45c708607bf0fc689d4dcf8d47fad6ed220e3819 Mon Sep 17 00:00:00 2001
From: Jaap de Wolff <lilyp...@de-wolff.org>
Date: Sun, 10 May 2020 17:09:00 +0200
Subject: [PATCH 1/5] Modify obvious incorrect types

---
 lily/figured-bass-engraver.cc | 2 +-
 lily/font-select.cc           | 4 ++--
 lily/lookup.cc                | 6 +++---
 lily/slur-scoring.cc          | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc
index f42852e81d..30ccae96b9 100644
--- a/lily/figured-bass-engraver.cc
+++ b/lily/figured-bass-engraver.cc
@@ -347,7 +347,7 @@ Figured_bass_engraver::process_music ()
 
   if (use_extenders)
     {
-      vector<int> junk_continuations;
+      vector<vsize> junk_continuations;
       for (vsize i = 0; i < groups_.size (); i++)
         {
           Figure_group &group = groups_[i];
diff --git a/lily/font-select.cc b/lily/font-select.cc
index 85456a22c0..1c9a290dd2 100644
--- a/lily/font-select.cc
+++ b/lily/font-select.cc
@@ -30,10 +30,10 @@ Font_metric *
 get_font_by_design_size (Output_def *layout, Real requested,
                          SCM font_vector)
 {
-  int n = scm_c_vector_length (font_vector);
+  size_t n = scm_c_vector_length (font_vector);
   Real size = 1e6;
   Real last_size = -1e6;
-  int i = 0;
+  size_t i = 0;
 
   SCM pango_description_string = SCM_EOL;
   SCM last_pango_description_string = SCM_EOL;
diff --git a/lily/lookup.cc b/lily/lookup.cc
index e52ad83a40..80995f882b 100644
--- a/lily/lookup.cc
+++ b/lily/lookup.cc
@@ -312,9 +312,9 @@ Lookup::round_filled_polygon (vector<Offset> const &points,
 
       for (vsize i = 0; i < points.size (); i++)
         {
-          int i0 = i;
-          int i1 = (i + 1) % points.size ();
-          int i2 = (i + 2) % points.size ();
+          vsize i0 = i;
+          vsize i1 = (i + 1) % points.size ();
+          vsize i2 = (i + 2) % points.size ();
           Offset p0 = points[i0];
           Offset p1 = points[i1];
           Offset p2 = points[i2];
diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc
index 7a718f7987..ee4cb2fa3a 100644
--- a/lily/slur-scoring.cc
+++ b/lily/slur-scoring.cc
@@ -387,7 +387,7 @@ Slur::calc_control_points (SCM smob)
   if (debug_slurs)
     {
       string total = best->card ();
-      total += to_string (" TOTAL=%.2f idx=%d", best->score (), best->index_);
+      total += to_string (" TOTAL=%.2f idx=%ld", best->score (), best->index_);
       set_property (me, "annotation", ly_string2scm (total));
     }
 #endif
-- 
2.20.1

>From f5266b22a5a510da829c122e64ae786accc691e8 Mon Sep 17 00:00:00 2001
From: Jaap de Wolff <lilyp...@de-wolff.org>
Date: Sun, 10 May 2020 17:19:41 +0200
Subject: [PATCH 2/5] do not use depcrecated %error-verbose (bison 2013)

---
 lily/parser.yy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lily/parser.yy b/lily/parser.yy
index 7ad352ca4e..75cdb5bd8a 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -52,7 +52,7 @@
 %parse-param {Lily_parser *parser}
 %parse-param {SCM *retval}
 %lex-param {Lily_parser *parser}
-%error-verbose
+%define parse.error verbose
 %debug
 
 /* We use SCMs to do strings, because it saves us the trouble of
-- 
2.20.1

>From f32587ef92f74ef87b0218eacdb362010cb8b63c Mon Sep 17 00:00:00 2001
From: Jaap de Wolff <lilyp...@de-wolff.org>
Date: Sun, 10 May 2020 17:32:02 +0200
Subject: [PATCH 3/5] Solve Issue 5963

---
 lily/source-file.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lily/source-file.cc b/lily/source-file.cc
index c5e8c12d46..abee8cf10c 100644
--- a/lily/source-file.cc
+++ b/lily/source-file.cc
@@ -29,7 +29,9 @@
 #include "lily-imports.hh"
 
 #if GCC_MAJOR < 4
+#ifndef _GLIBCXX_HAVE_MBSTATE_T
 #define _GLIBCXX_HAVE_MBSTATE_T
+#endif
 #include <wchar.h>
 #endif /* GCC_MAJOR < 4 */
 #include <cstdio>
-- 
2.20.1

>From 2ca22cc6bb52f3f5ff7df407e57992e482723685 Mon Sep 17 00:00:00 2001
From: Jaap de Wolff <lilyp...@de-wolff.org>
Date: Sun, 10 May 2020 17:34:11 +0200
Subject: [PATCH 4/5] Valid declaration of unused arguments

---
 lily/include/overlay-string-port.hh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lily/include/overlay-string-port.hh 
b/lily/include/overlay-string-port.hh
index 07503434f3..6da3c32cf3 100644
--- a/lily/include/overlay-string-port.hh
+++ b/lily/include/overlay-string-port.hh
@@ -114,7 +114,7 @@ public:
       return scm_return_first_int (*pt->read_pos, port);
   }
 
-  static guile_off_t seek_scm (SCM port, guile_off_t offset, int whence)
+  static guile_off_t seek_scm (SCM port, guile_off_t /* offset */, int whence)
   {
     assert (whence == SEEK_CUR);
     scm_t_port *pt = SCM_PTAB_ENTRY (port);
-- 
2.20.1

>From 7ad32213cd65296c47a7ea69c2a6d172e72aa38c Mon Sep 17 00:00:00 2001
From: Jaap de Wolff <lilyp...@de-wolff.org>
Date: Sun, 10 May 2020 21:26:52 +0200
Subject: [PATCH 5/5] ignore conversion warning in lexer.cc

---
 lily/lexer.ll | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lily/lexer.ll b/lily/lexer.ll
index 9f274f1a80..cfcb3df677 100644
--- a/lily/lexer.ll
+++ b/lily/lexer.ll
@@ -84,6 +84,11 @@ RH 7 fix (?)
 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
 #endif
 
+// generated code for yyFlexLexer::LexerInput 
+// contains a std::streamsize to int conversion
+// ignore warning
+#pragma GCC diagnostic ignored "-Wconversion"
+
 void strip_trailing_white (string&);
 void strip_leading_white (string&);
 string lyric_fudge (string s);
-- 
2.20.1

Reply via email to