News for hackers. Stuff that matters.
Re:Get to No as fast as possible by scott_s on Thursday June 17, 2010 @01:07PM (#1439553)
But the coding styles in the Linux kernel usually maintain a single exit point from the function. The format they generally have is:

  syscall(params)
  {
    if (easy check on params fails)
      goto done;

    allocate data for work
    if (further check on params and data fails)
      goto cleanup;

    perform real work

  cleanup:
    deallocate data
  done:
    set return value
  }
There's often still a single exit, but it does use gotos to implement simple exceptions. The only times when there are multiple exits is before any data has been allocated and there's no cleanup to be done.

There are no comments on this comment yet.