News for hackers. Stuff that matters.
Re:Dangerous Embedded C Coding Standard Rules (2011) by nitrogen on Monday December 30, 2013 @04:24PM (#6987065)
The approach I use, and that used many places in the Linux kernel, is to use goto for error handling:

  if(failure_1) {
      goto error;
  }
  if(failure_2) {
      goto error;
  }
  
  // Do stuff
  return 0;
  
  error:
  if(f != NULL) {
      fclose(f);
  }
  if(s != NULL) {
      free(s);
  }
  return -1;

There are no comments on this comment yet.