Re: Cppcheck reports

2012-05-20 Thread Julien Nabet

On 18/05/2012 22:27, Carl Sorensen wrote:


On 5/18/12 1:42 PM, Marek Kleinma...@gregoriana.sk  wrote:




Hello

2012/5/17 Julien Nabetserval2...@yahoo.fr


I'm not top posting.

Hello,

I just git clone Lilypond project and launched cppcheck (git updated
today).
I thought it could interest you, here are some examples :
[lily/tuplet-bracket.cc:594] -  [lily/tuplet-bracket.cc:594]: (style) Same
expression on both sides of '-'
   592   if (!follow_beam)
   593 {
   594   points.push_back (Offset (x0 - x0, staff[dir]));
   595   points.push_back (Offset (x1 - x0, staff[dir]));
   596 }

[lily/tie-engraver.cc:240]: (performance) Prefer prefix ++/-- operators
for
non-primitive types
240   for (; it  heads_to_tie_.end (); it++)
241 report_unterminated_tie (*it);
(+ it's safer to use it != heads_to_tie_.end ())

[lily/paper-book.cc:346]: (performance) Possible inefficient checking for
'cols'
emptiness
   346   if (cols.size ())
   347 {
   348   Paper_column *col = dynamic_castPaper_column *
(cols.back ());
   349   col-set_property (symbol, permission);
   350   col-find_prebroken_piece (LEFT)-set_property (symbol,
permission);
   351 }

If you're interested, I can send you the full report (since there's no
possibility of attachment), just tell me where I can send it.

Julien.



This need some discussion before tracking an issue, I think - therefore
cc-ing devel...

I think that it would be worth creating an issue, and attaching the output
file from cppcheck, as long as the file is not too long.

At any rate, I'd like to see the output file.
I attached the file. As for the issue, I'm not sure having well 
understood your process.

Anyway if it can help.

To have the file report, just follow these very simple steps :
1) retrieve cppcheck
/git clone https://github.com/danmar/cppcheck.git/
2) go to cppcheck and compile
/cd cppcheck  make/
3) go to lilypond-git and launch cppcheck
/~/cppcheck/cppcheck/cppcheck --enable=all ./ 2./cppcheck_report.txt
/
(it launches cppcheck with all the checking rules + put the found 
elements in cppcheck_report.txt + you can follow the progress)


Regards,

Julien


cppcheck_report.txt.gz
Description: GNU Zip compressed data
___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Cppcheck reports patch for 2546

2012-05-20 Thread Julien Nabet

On 19/05/2012 00:36, Carl Sorensen wrote:

Thanks for the file, Julien.  I have split the warnings into various
issues.

See issues 2545, 2546, and 2548 through 2554 on the issue tracker.

http://code.google.com/p/lilypond/issues/detail?id=2545colspec=ID%20Type%2
0Status%20Stars%20Owner%20Patch%20Needs%20Summary

http://code.google.com/p/lilypond/issues/detail?id=2546colspec=ID%20Type%2
0Status%20Stars%20Owner%20Patch%20Needs%20Summary

etc.

Julien, if you want to fix any of these, I'd be happy to help you get
patches reviewed and pushed.

Here's instructions on uploading a patch for review:

http://lilypond.org/doc/v2.15/Documentation/contributor/commits-and-patches
#uploading-a-patch-for-review
Since I don't have a Google account to sign in to 
http://codereview.appspot.com/, I attached the patch for 2546.
Don't hesitate to tell me if it's ok or not. (I attached a link to why 
prefix is better).


Julien.

PS : about why it's better to use != instead of  for end iterator 
comparison, see http://forums.codeguru.com/archive/index.php/t-428940.html

Sorry, I would have preferred a more official link
From d14506cc2b98634be4fed45f142e0fb09bdff311 Mon Sep 17 00:00:00 2001
From: Julien Nabet serval2...@yahoo.fr
Date: Sat, 19 May 2012 07:33:17 +0200
Subject: [PATCH] Fix 2546: 	Prefix incrementers may be preferred for
 non-primitive types

See http://en.allexperts.com/q/C-1040/Increment-operators.htm for some explanation
---
 lily/dot-column.cc |2 +-
 lily/dot-configuration.cc  |   10 +-
 lily/note-spacing-engraver.cc  |2 +-
 lily/skyline.cc|   14 +++---
 lily/tie-engraver.cc   |4 ++--
 lily/tie-formatting-problem.cc |2 +-
 lily/tie-performer.cc  |2 +-
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lily/dot-column.cc b/lily/dot-column.cc
index 1aa0b72..81b8124 100644
--- a/lily/dot-column.cc
+++ b/lily/dot-column.cc
@@ -194,7 +194,7 @@ Dot_column::calc_positioning_done (SCM smob)
   problem.register_configuration (cfg);
 
   for (Dot_configuration::const_iterator i (cfg.begin ());
-   i != cfg.end (); i++)
+   i != cfg.end (); ++i)
 {
   /*
 Junkme?
diff --git a/lily/dot-configuration.cc b/lily/dot-configuration.cc
index 940420c..d6c04c5 100644
--- a/lily/dot-configuration.cc
+++ b/lily/dot-configuration.cc
@@ -27,7 +27,7 @@ Dot_configuration::badness () const
 {
   int t = 0;
   for (Dot_configuration::const_iterator i (begin ());
-   i != end (); i++)
+   i != end (); ++i)
 {
   int p = i-first;
   int demerit = sqr (p - i-second.pos_) * 2;
@@ -50,7 +50,7 @@ Dot_configuration::print () const
 {
   printf (dotconf { );
   for (Dot_configuration::const_iterator i (begin ());
-   i != end (); i++)
+   i != end (); ++i)
 printf (%d, , i-first);
   printf (}\n);
 }
@@ -71,7 +71,7 @@ Dot_configuration::shifted (int k, Direction d) const
   if (d  0)
 {
   for (Dot_configuration::const_iterator i (begin ());
-   i != end (); i++)
+   i != end (); ++i)
 {
   int p = i-first;
   if (p == k)
@@ -98,7 +98,7 @@ Dot_configuration::shifted (int k, Direction d) const
   Dot_configuration::const_iterator i (end ());
   do
 {
-  i--;
+  --i;
 
   int p = i-first;
   if (p == k)
@@ -157,7 +157,7 @@ Dot_configuration::x_offset () const
 {
   Real off = 0.0;
   for (Dot_configuration::const_iterator i (begin ());
-   i != end (); i++)
+   i != end (); ++i)
 off = max (off, problem_-head_skyline_.height ((*i).first));
 
   return off;
diff --git a/lily/note-spacing-engraver.cc b/lily/note-spacing-engraver.cc
index 8cb1b35..c1d2405 100644
--- a/lily/note-spacing-engraver.cc
+++ b/lily/note-spacing-engraver.cc
@@ -51,7 +51,7 @@ void
 Note_spacing_engraver::derived_mark () const
 {
   for (Last_spacing_map::const_iterator i = last_spacings_.begin ();
-   i != last_spacings_.end (); i++)
+   i != last_spacings_.end (); ++i)
 scm_gc_mark (i-first-self_scm ());
 }
 
diff --git a/lily/skyline.cc b/lily/skyline.cc
index 0250fc0..2a3a369 100644
--- a/lily/skyline.cc
+++ b/lily/skyline.cc
@@ -62,7 +62,7 @@
 static void
 print_buildings (listBuilding const b)
 {
-  for (listBuilding::const_iterator i = b.begin (); i != b.end (); i++)
+  for (listBuilding::const_iterator i = b.begin (); i != b.end (); ++i)
 i-print ();
 }
 
@@ -375,7 +375,7 @@ Skyline::Skyline (Skyline const src)
 
   /* doesn't a list's copy constructor do this? -- jneem */
   for (listBuilding::const_iterator i = src.buildings_.begin ();
-   i != src.buildings_.end (); i++)
+   i != src.buildings_.end (); ++i)
 {
   buildings_.push_back (Building ((*i)));
 }
@@ -492,7 +492,7 @@ void
 Skyline::raise (Real r)
 {
   listBuilding::iterator end = buildings_.end ();
-  for (listBuilding::iterator i = buildings_.begin (); i != end; i++)
+  for (listBuilding::iterator i = 

Re: Cppcheck reports patch for 2546

2012-05-20 Thread Graham Percival
On Sat, May 19, 2012 at 08:30:50AM +0200, Julien Nabet wrote:
 Since I don't have a Google account to sign in to
 http://codereview.appspot.com/, I attached the patch for 2546.
 Don't hesitate to tell me if it's ok or not. (I attached a link to
 why prefix is better).

Unfortunately we do not accept patches outside of the process
discussed here:
http://lilypond.org/doc/v2.15/Documentation/contributor/summary-for-experienced-developers

Hopefully somebody will offer to shepherd your patch through the
process.

- Graham

___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Cppcheck reports

2012-05-18 Thread Marek Klein
Hello

2012/5/17 Julien Nabet serval2...@yahoo.fr

 
  I'm not top posting.
 Hello,

 I just git clone Lilypond project and launched cppcheck (git updated
 today).
 I thought it could interest you, here are some examples :
 [lily/tuplet-bracket.cc:594] - [lily/tuplet-bracket.cc:594]: (style) Same
 expression on both sides of '-'
592   if (!follow_beam)
593 {
594   points.push_back (Offset (x0 - x0, staff[dir]));
595   points.push_back (Offset (x1 - x0, staff[dir]));
596 }

 [lily/tie-engraver.cc:240]: (performance) Prefer prefix ++/-- operators for
 non-primitive types
  240   for (; it  heads_to_tie_.end (); it++)
  241 report_unterminated_tie (*it);
 (+ it's safer to use it != heads_to_tie_.end ())

 [lily/paper-book.cc:346]: (performance) Possible inefficient checking for
 'cols'
 emptiness
346   if (cols.size ())
347 {
348   Paper_column *col = dynamic_castPaper_column *
 (cols.back ());
349   col-set_property (symbol, permission);
350   col-find_prebroken_piece (LEFT)-set_property (symbol,
 permission);
351 }

 If you're interested, I can send you the full report (since there's no
 possibility of attachment), just tell me where I can send it.

 Julien.


This need some discussion before tracking an issue, I think - therefore
cc-ing devel...

Marek Klein,
bug squad member
___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Cppcheck reports

2012-05-18 Thread Carl Sorensen


On 5/18/12 1:42 PM, Marek Klein ma...@gregoriana.sk wrote:




Hello

2012/5/17 Julien Nabet serval2...@yahoo.fr


 I'm not top posting.
Hello,

I just git clone Lilypond project and launched cppcheck (git updated
today).
I thought it could interest you, here are some examples :
[lily/tuplet-bracket.cc:594] - [lily/tuplet-bracket.cc:594]: (style) Same
expression on both sides of '-'
   592   if (!follow_beam)
   593 {
   594   points.push_back (Offset (x0 - x0, staff[dir]));
   595   points.push_back (Offset (x1 - x0, staff[dir]));
   596 }

[lily/tie-engraver.cc:240]: (performance) Prefer prefix ++/-- operators
for
non-primitive types
 240   for (; it  heads_to_tie_.end (); it++)
 241 report_unterminated_tie (*it);
(+ it's safer to use it != heads_to_tie_.end ())

[lily/paper-book.cc:346]: (performance) Possible inefficient checking for
'cols'
emptiness
   346   if (cols.size ())
   347 {
   348   Paper_column *col = dynamic_castPaper_column *
(cols.back ());
   349   col-set_property (symbol, permission);
   350   col-find_prebroken_piece (LEFT)-set_property (symbol,
permission);
   351 }

If you're interested, I can send you the full report (since there's no
possibility of attachment), just tell me where I can send it.

Julien.



This need some discussion before tracking an issue, I think - therefore
cc-ing devel...

I think that it would be worth creating an issue, and attaching the output
file from cppcheck, as long as the file is not too long.

At any rate, I'd like to see the output file.

Thanks,

Carl


___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Cppcheck reports

2012-05-18 Thread Carl Sorensen
Thanks for the file, Julien.  I have split the warnings into various
issues.

See issues 2545, 2546, and 2548 through 2554 on the issue tracker.

http://code.google.com/p/lilypond/issues/detail?id=2545colspec=ID%20Type%2
0Status%20Stars%20Owner%20Patch%20Needs%20Summary

http://code.google.com/p/lilypond/issues/detail?id=2546colspec=ID%20Type%2
0Status%20Stars%20Owner%20Patch%20Needs%20Summary

etc.

Julien, if you want to fix any of these, I'd be happy to help you get
patches reviewed and pushed.

Here's instructions on uploading a patch for review:

http://lilypond.org/doc/v2.15/Documentation/contributor/commits-and-patches
#uploading-a-patch-for-review



Thanks,

Carl


___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel