From: Daniel Colascione Date: Mon, 26 Feb 2018 06:22:40 +0000 (-0800) Subject: Improve error message when attempting to load failed dump file X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=aacc1390f21ddb003c9d6a786597e89284bafec3;p=emacs.git Improve error message when attempting to load failed dump file --- diff --git a/src/emacs.c b/src/emacs.c index 415981096c3..0ed3f905bbe 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -714,6 +714,8 @@ dump_error_to_string (enum pdumper_load_result result) return "could not open file"; case PDUMPER_LOAD_BAD_FILE_TYPE: return "not a dump file"; + case PDUMPER_LOAD_FAILED_DUMP: + return "dump file is result of failed dump attempt"; case PDUMPER_LOAD_VERSION_MISMATCH: return "not built for this Emacs executable"; default: diff --git a/src/pdumper.c b/src/pdumper.c index 80ed9a8183f..400177223a4 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5145,9 +5145,18 @@ pdumper_load (const char *dump_filename) sizeof (*header)) < sizeof (*header)) goto out; - err = PDUMPER_LOAD_BAD_FILE_TYPE; if (memcmp (header->magic, dump_magic, sizeof (dump_magic)) != 0) - goto out; + { + if (header->magic[0] == '!' && + ((header->magic[0] = dump_magic[0]), + memcmp (header->magic, dump_magic, sizeof (dump_magic)) == 0)) + { + err = PDUMPER_LOAD_FAILED_DUMP; + goto out; + } + err = PDUMPER_LOAD_BAD_FILE_TYPE; + goto out; + } err = PDUMPER_LOAD_VERSION_MISMATCH; verify (sizeof (header->fingerprint) == sizeof (fingerprint)); diff --git a/src/pdumper.h b/src/pdumper.h index c40761944d8..48d34dc0bf1 100644 --- a/src/pdumper.h +++ b/src/pdumper.h @@ -125,6 +125,7 @@ enum pdumper_load_result PDUMPER_NOT_LOADED /* Not returned: useful for callers */, PDUMPER_LOAD_FILE_NOT_FOUND, PDUMPER_LOAD_BAD_FILE_TYPE, + PDUMPER_LOAD_FAILED_DUMP, PDUMPER_LOAD_OOM, PDUMPER_LOAD_VERSION_MISMATCH, PDUMPER_LOAD_ERROR,