int func()
{
int r = 1;

//無駄な初期化はしない
char *p1;
int fd2;
FILE *fp3;

p1 = malloc(); if(p1 == NULL) goto malloc_failure;
fd2 = open(); if(fd2 == -1) goto open_failure;
fp3 = fopen(); if(fp3 == NULL) goto fopen_failure;
r = 0; // 成功

//フラグの類は極力使わない
fclose(fp3);
fopen_failure:

close(fd2);
open_failure:

free(p1);
malloc_failure:

return r;
}