[Nice] New SDP parsing API

Youness Alaoui youness.alaoui at collabora.co.uk
Tue Feb 5 10:50:43 PST 2013

On 02/05/2013 03:47 AM, Olivier Crête wrote:
> Hi,
> On Tue, 2013-02-05 at 11:28 +0530, Rohan Garg wrote:
>> I notice that you use goto quite liberally elsewhere, but isn't usage
>> of goto generally frowned upon? ( I haven't looked the rest of the
>> code thoroughly enough to say if it can be converted to not use goto
>> ).
> Using goto is ok if you use it right, for example, in C, it's quite
> popular to exit in case of errors, since we have no exceptions.
Yeah Rohan, it can be refactored like you said. But that "find_component/goto
done" part was copy/pasted from elsewhere, and pretty much all functions work
the same, with the "done" or "end" label at the end to do the unlock/return.
I prefer keeping consistency with the other functions than refactoring that one.
And I can't refactor everything otherwise you get :
if (cond1) {
  if (cond2) {
     do stuff
     if (!error) {
        bla bla bla
        if (foo != NULL) {
And it makes the code much less readable that way. Also, in some use cases, it's
not even possible to do it that way (like inside a block, you need to free some
memory, and you have a bunch of error handling if/else, and you have to
copy/paste the same code in a bunch of places).

Like Olivier said, using goto in C is very common when it comes to error
handling and is usually the prefered way... only avoid goto statements if it's
for stuff like :
  do stuff
  if (i < x)
    goto loop;

There are better constructs for that :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20130205/62b49538/attachment.pgp>

More information about the nice mailing list