[Ffmpeg-devel] [PATCH] Allow choosing display and screen number for x11grab device

Måns Rullgård mru
Fri Dec 15 20:05:30 CET 2006


Rich Felker <dalias at aerifal.cx> writes:

> On Fri, Dec 15, 2006 at 03:11:16PM +0100, Michael Niedermayer wrote:
>> Hi
>> 
>> On Wed, Dec 13, 2006 at 10:58:59PM +0100, Panagiotis Issaris wrote:
>> > Hi,
>> > 
>> > On Wed, Dec 13, 2006 at 10:32:21PM +0100, Panagiotis Issaris wrote:
>> > >[...]
>> > > > ffmpeg -vd x11:0.1 -s 640x480 test.avi
>> > > Furthermore, I think there are some errorhandling problems,
>> > > which I did not want to fix in the same patch, as I wanted to
>> > > address separate issues in separate patches.
>> > This is an incremental patch with my first try to fix these error
>> > handling problems. I'm not sure if this is the correct way to
>> > handle errors as I am a Xlib-newbie. It seemed cleaner to me to
>> > release resources if things fail after some allocations
>> > succeeded. Furthermore, there's a lot of code duplication, which
>> > in Linux is avoided by using gotos :) I could also make a
>> > function that is called on every failure and does all the
>> > releasing using one "if (!...)"  condition per call.
>> 
>> i prefer a goto fail over the code duplication
>
> Indeed, goto is always the correct solution to this problem. Writing
> duplicate, huge-nested-conditional, or otherwise-nasty code for the
> sake of avoiding the goto keyword is severely misguided and should be
> the topic of its own "considered harmful" paper.

Some people have such a fear for the goto keyword that they'll things
like this:

do {
    do_something;
    if(some_error)
        break;
    do_some_more;
    if(another_error)
        break;
    and_so_on;
} while(0);

I guess one might call these folks hypocrites of sorts.  I've seen a
lot of such code in Broadcom drivers.  No wonder they're reluctant to
release source...

-- 
M?ns Rullg?rd
mru at inprovide.com




More information about the ffmpeg-devel mailing list