lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix uninitialized variables when Source_file::get_counts returns ear


From: Carl Sorensen
Subject: Re: Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) (issue 4940047)
Date: Tue, 23 Aug 2011 12:34:37 -0600

On 8/23/11 12:21 PM, "address@hidden" <address@hidden> wrote:

> LGTM
> 
> Maybe we should have some GOP rules for C++ about this?
> "Only have multiple exit points from routines if you absolutely have to.

Multiple exit points is a standard idiom of the LilyPond code.  Basically,
the idiom is "If this routine doesn't apply for some reason, leave now",
instead of "If this routine doesn't apply, skip to the end" or "If this
routine applies, do the body".

As imbedded as this idiom is in our code, I don't think it would be wise to
change it.

> Make sure any output parameters are declared and initialized at the top
> of a routine so that however a routine exits, they are left in a defined
> state"

IIRC, we used to have a statement that said to declare variables as close as
possible to where they are used.  I generally agree with that.

However, I think a simple statement that says "variables should be
initialized when they are declared" would be clearly welcome.  And fixes to
the code to ensure this would also be welcome.

Thanks,

Carl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]