-/* $NetBSD: scores.c,v 1.19 2010/02/03 15:34:39 roy Exp $ */
+/* $NetBSD: scores.c,v 1.20 2011/01/05 15:48:00 wiz Exp $ */
/*-
* Copyright (c) 1992, 1993
result = read(sd, &header, sizeof(header));
if (result < 0) {
warn("Score file %s: read", _PATH_SCOREFILE);
- close(sd);
- goto fail;
+ goto sdfail;
}
if (result != 0 && (size_t)result != sizeof(header)) {
warnx("Score file %s: read: unexpected EOF", _PATH_SCOREFILE);
if (lseek(sd, 0, SEEK_SET) < 0) {
/* ? */
warn("Score file %s: lseek", _PATH_SCOREFILE);
- goto fail;
+ goto sdfail;
}
if (ftruncate(sd, 0) == 0) {
result = 0;
} else {
- close(sd);
- goto fail;
+ goto sdfail;
}
}
} else {
warnx("Score file %s: Unknown endian tag %u",
_PATH_SCOREFILE, header.hsh_endiantag);
- goto fail;
+ goto sdfail;
}
if (header.hsh_version != HSH_VERSION) {
warnx("Score file %s: Unknown version code %u",
_PATH_SCOREFILE, header.hsh_version);
- goto fail;
+ goto sdfail;
}
if (readscores(sd, doflip) < 0) {
- goto fail;
+ goto sdfail;
}
} else {
/*
result = scorefile_probe(sd);
if (lseek(sd, 0, SEEK_SET) < 0) {
warn("Score file %s: lseek", _PATH_SCOREFILE);
- goto fail;
+ goto sdfail;
}
switch (result) {
case SCOREFILE_CURRENT:
result = readscores50(sd, 1 /* do flip */);
break;
default:
- goto fail;
+ goto sdfail;
}
if (result < 0) {
- goto fail;
+ goto sdfail;
}
}
}
return;
+sdfail:
+ close(sd);
fail:
if (fdp != NULL) {
*fdp = -1;