Suspicious code in kdelibs/kdebase revision 864329

Aaron J. Seigo aseigo at kde.org
Thu Sep 25 16:35:18 BST 2008


On Thursday 25 September 2008, Olivier Goffart wrote:
> Le jeudi 25 septembre 2008, Jason Stubbs a écrit :
> > On Thu, Sep 25, 2008 at 8:00 AM, Aaron J. Seigo <aseigo at kde.org> wrote:
> > > > - kdelibs/kdeui/widgets/ktoolbar.cpp:1056
> > > >
> > > > This loop is executed at most once. Not forever.
> > >
> > > false positive; not the most obvious bit of code, perhaps, but it's
> > > using the
> > > forever as a way to utilize break; statements as prettier gotos
> >
> > Personal preference, I guess, but I generally use do { } while (false);
> > for these cases to be explicit that it is not a real loop.
>
> Why not simply goto ?

both are possibilities; in this case having a well marked block with {} makes 
it, at least for me, more obvious what will happen: a break anywhere in it 
will exit that block. a goto is a bit less visually well defined, but then 
occasionally they are perfect...

imho, though, it's all a language problem. being able to define exit code to 
run, much as you get when you do a yield in ruby, would make 99% of these 
cases just GO AWAY =)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080925/b4929d2a/attachment.sig>


More information about the kde-core-devel mailing list