News for hackers. Stuff that matters.
Re:Fuchsia is not Linux by knorker on Thursday April 12, 2018 @05:09AM (#16819166)
It's easier to get this right:

    {
      Resource foo(path);
      if … {
        return -ENOMEM
      }
      return 0;
    }
Than to get this right:

    {
      Resource* foo = acquire(path);
      if … {
        release(foo);
        return -ENOMEM
      }
      release(foo);
      return 0;
    }
Even if you do the goto-style:

    {
      Resource* foo = acquire(path);
      int rc = 0;
      if … {
        rc = -ENOMEM
        goto out;
      }
    out:
      release(foo);
      return rc;
    }

There are no comments on this comment yet.