An idiom that I learned in the Go community is to align the happy path. An
example in C below:
happy path not aligned
intprocess_file(constchar*filename){Â Â FILE* f =fopen(filename,"r");Â Â if(f !=NULL){Â Â Â Â char buffer[100];Â Â Â Â if(fgets(buffer,sizeof(buffer), f)!=NULL){Â Â Â Â Â Â // process buffer
      fclose(f);      return0;// success
    }else{      fclose(f);      return-2;// error: unable to read
    }  }else{    return-1;// error: unable to open
  }}
happy path aligned
intprocess_file(constchar*filename){Â Â FILE* f =fopen(filename,"r");Â Â if(f ==NULL)Â Â Â Â return-1;// error: unable to open
  char buffer[100];  if(fgets(buffer,sizeof(buffer), f)==NULL){    fclose(f);    return-2;// error: unable to read
  }  // process buffer
  fclose(f);  return0;// success
}
In the first example, it is more difficult to follow the logic due to nested if
statements. In the second example, it is easy to scan down through the code
aligned to the left and sequentially see what it is supposed to do.