general question..

Chris Ahrendt celticht32 at
Mon Jul 21 21:48:13 CDT 2008

Stefan Dösinger wrote:
> Can you give some examples of such code? Nobody here is a goto-maniac, but
> in all cases I know the goto is used for a good reason. Most of the time it
> is used for error path to avoid ugly if() nesting and/or code duplication
> when freeing partially allocated objects
>> -----Original Message-----
>> From: wine-patches-bounces at [mailto:wine-patches-
>> bounces at] On Behalf Of Chris Ahrendt
>> Sent: Monday, July 21, 2008 8:42 PM
>> To: wine-patches at
>> Subject: general question..
>> As I have been going through trying to debug the everquest2 issues on
>> my
>> machine I have run into a few places where I think the code should be
>> changed a little ( this alot of times is where there is a GOTO in the
>> code). My question is in the case where I do find these goto's and I
>> rewrite the code  should I submit the changes here for approval?
>> I have been doing some code reviews and found a few places where
>> there are goto's that don't need to be there. I guess I am old school
>> and really dislike code with goto's (they make debugging and
>> maintenance
>> a nightmare (I used to maintain 20 year old cobol code  along time ago
>> =) )
>> Chris
Sure =)

Well here is my list so far :

device.c - filled with goto's if you need the routines I can supply 
them... they can be moved to a routine and called...

context.c - This case its just a return with noting else.. why do a goto 
why not just do the return?

directx.c  - same... this can be moved to a routine and simplified..
this is in routine WineD3D_CreateFakeGLContext which I was tracing down 
some stuff...

pixelshader.c - why not make this into a routine?

provider.c - same

These are just the ones I have run accross so far..

In the case of code dupes instead of using a goto like the 
createfakeGLContext why not make the

     wined3d_fake_gl_context_hdc = NULL;
     wined3d_fake_gl_context_hwnd = NULL;
     if(glCtx) pwglDeleteContext(glCtx);
     return FALSE;

into a routine and then do a

return fakeContextFail(glCtx);

Then of course above createfakeGLContext define

Not saying Goto's are completely bad.. in some cases they are good for 
avoiding some tricky situations but alot of times they are not... just 
my $.02 not trying to start a flame war guys just trying to help =)


More information about the wine-devel mailing list