From 895199a83be1cfdda270fc6b16dfaee8bca36509 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Fri, 5 Jul 2002 14:42:49 +0000 Subject: [PATCH] validate_prefix_locations Add the actual value of the prefix, and the error returned by the system to the paniclog file entry. --- src/files.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/files.c b/src/files.c index dea30c7de..17d381c67 100644 --- a/src/files.c +++ b/src/files.c @@ -167,9 +167,8 @@ char *reasonbuf; FILE *fp; const char *filename; int prefcnt, failcount = 0; - char failbuf[BUFSZ]; + char panicbuf1[BUFSZ], panicbuf2[BUFSZ]; - failbuf[0] = '\0'; if (reasonbuf) reasonbuf[0] = '\0'; for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) { /* don't test writing to configdir or datadir; they're readonly */ @@ -179,20 +178,20 @@ char *reasonbuf; fclose(fp); (void) unlink(filename); } else { - if (failcount) { - Strcat(failbuf,", "); - if (reasonbuf) Strcat(reasonbuf,", "); + if (reasonbuf) { + if (failcount) Strcat(reasonbuf,", "); + Strcat(reasonbuf, fqn_prefix_names[prefcnt]); } - /* the paniclog entry gets the value of errno */ - Sprintf(eos(failbuf), "%s:%d", fqn_prefix_names[prefcnt], errno); - if (reasonbuf) Strcat(reasonbuf, fqn_prefix_names[prefcnt]); + /* the paniclog entry gets the value of errno as well */ + Sprintf(panicbuf1,"Invalid %s", fqn_prefix_names[prefcnt]); + Sprintf(panicbuf2,"\"%s\" (errno=%d)", fqn_prefix[prefcnt], errno); + paniclog(panicbuf1, panicbuf2); failcount++; } } - if (failcount) { - paniclog("Invalid locations", failbuf); + if (failcount) return 0; - } + else #endif return 1; }