From: Ian Jackson Date: Sun, 9 Jan 2011 13:31:01 +0000 (+0000) Subject: realtime: persist: header check failures tell us which item did not match X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=9a33d313d74554309832a4d7e7b7fe0fa08b221a;p=trains.git realtime: persist: header check failures tell us which item did not match --- diff --git a/hostside/persist.c b/hostside/persist.c index e70eb23..9dd90b8 100644 --- a/hostside/persist.c +++ b/hostside/persist.c @@ -346,11 +346,13 @@ static void phi_load(void *object, size_t sz, int *offset) { *offset += sz; } -static void phi_check(const void *expected, size_t sz, int *offset) { +static void phi_check(const void *expected, size_t sz, + int *offset, const char *what) { Byte actual[sz]; phi_load(actual, sz, offset); - if (memcmp(actual, expected, sz)) die("header magic check failed"); + if (memcmp(actual, expected, sz)) + die("header magic check failed, in `%s'", what); } static void persist_mapread(void) { @@ -360,7 +362,7 @@ static void persist_mapread(void) { r= fstat(0, &stab); if (r) diee("could not fstat persist data file"); if (!(stab.st_mode & 0111)) die("persist data file is not executable"); -#define PHI_CHECK(x) phi_check(&(x), sizeof(x), &offset); +#define PHI_CHECK(x) phi_check(&(x), sizeof(x), &offset, STR(x)); #define PHI_LOAD(x) phi_load(&(x), sizeof(x), &offset); DO_PERSIST_HEADER_ITEMS(PHI_CHECK, PHI_LOAD, PHI_LOAD)