Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11309)

Issue 4940047: Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 8 months ago by Reinhold
Modified:
12 years, 7 months ago
Reviewers:
carl.d.sorensen, reinhold, Ian Hulin (gmail), c_sorensen, dan, Graham Percival, hanwenn
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) Most code that called get_counts simply is like: int line, chr, col, offset = 0; source_file_->get_counts (end_, &line, &chr, &col, &offset); Now, unfortunately get_counts returns early sometimes (if we don't have a position), so only line_number would be initialized to 0, all other variables would stay uninitialized. And most code simply passed them on to other guile functions to handle. This patch moved the initialization of all arguments to the very beginning of get_counts and thus never returns uninizialized variables. This shuts up several valgrind warnings in our regtests.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -4 lines) Patch
M lily/source-file.cc View 2 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 10
Reinhold
Please review to get rid of some uninitialized variables.
12 years, 8 months ago (2011-08-23 11:14:06 UTC) #1
Carl
LGTM. Thanks! Carl
12 years, 8 months ago (2011-08-23 12:03:14 UTC) #2
Graham Percival
On Tue, Aug 23, 2011 at 11:14:06AM +0000, reinhold.kainhofer@gmail.com wrote: > Fix uninitialized variables when ...
12 years, 8 months ago (2011-08-23 17:27:47 UTC) #3
Ian Hulin (gmail)
LGTM Maybe we should have some GOP rules for C++ about this? "Only have multiple ...
12 years, 8 months ago (2011-08-23 18:21:00 UTC) #4
Graham Percival
On Tue, Aug 23, 2011 at 06:21:00PM +0000, ianhulin44@gmail.com wrote: > Maybe we should have ...
12 years, 8 months ago (2011-08-23 18:29:05 UTC) #5
c_sorensen
On 8/23/11 12:21 PM, "ianhulin44@gmail.com" <ianhulin44@gmail.com> wrote: > LGTM > > Maybe we should have ...
12 years, 8 months ago (2011-08-23 18:34:49 UTC) #6
Ian Hulin (gmail)
Hi Graham, Carl, On Tue 23 Aug 2011 19:34:37 BST, Carl Sorensen wrote: > On ...
12 years, 7 months ago (2011-08-24 08:49:31 UTC) #7
reinhold_kainhofer.com
Am Wednesday, 24. August 2011, 10:49:30 schrieben Sie: > Hi Graham, Carl, > > On ...
12 years, 7 months ago (2011-08-24 09:10:37 UTC) #8
dan_faithful.be
On 2011-08-24, at 05:10 , Reinhold Kainhofer wrote: > Am Wednesday, 24. August 2011, 10:49:30 ...
12 years, 7 months ago (2011-08-24 13:01:59 UTC) #9
hanwenn
12 years, 7 months ago (2011-08-24 13:31:23 UTC) #10
On Tue, Aug 23, 2011 at 3:21 PM,  <ianhulin44@gmail.com> wrote:
> LGTM
>
> Maybe we should have some GOP rules for C++ about this?

Can we not? Professionally, I work with an enormous style guide, and
having a lot of style prescribed needlessly complicates code reviews,
because it makes people hammer on unimportant syntactical details.

We could adopt the following GOP rule about writing functions:

 Use your brain when you write and arrange a function.


-- 
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b