From 35770ed49f4d22a577f5ab8b27a97ca8bd2207aa Mon Sep 17 00:00:00 2001 From: tlatorre Date: Tue, 15 Jan 2019 02:01:36 -0600 Subject: fix a bug with getting the first MCTK bank --- src/fit.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/fit.c') diff --git a/src/fit.c b/src/fit.c index 64a2a5a..26a5bdf 100644 --- a/src/fit.c +++ b/src/fit.c @@ -6071,14 +6071,26 @@ int main(int argc, char **argv) goto err; } - rv = zebra_get_bank(f,&b,mctk.orig); + if (mctk.orig == mctk.up - KMCVX_MCTK) { + /* This is the first MCTK bank. */ + unpack_mctk(mctk.data, &bmctk); + } else { + /* For some reason SNOMAN sometimes links to the second MCTK + * from the MCGN bank. */ + rv = zebra_get_bank(f,&b,mctk.orig); - if (rv) { - fprintf(stderr, "error getting MCTK bank: %s\n", zebra_err); - goto err; - } + if (b.idh != MCTK_RECORD) { + fprintf(stderr, "error following origin link from MCTK bank!\n"); + goto err; + } + + if (rv) { + fprintf(stderr, "error getting MCTK bank: %s\n", zebra_err); + goto err; + } - unpack_mctk(b.data, &bmctk); + unpack_mctk(b.data, &bmctk); + } if (mctk.up == 0) { fprintf(stderr, "MCVX link is zero!\n"); @@ -6199,7 +6211,7 @@ int main(int argc, char **argv) /* Note the origin link for the first EV bank points back to the * structural link location in the MAST bank. These links are super * confusing! */ - if ((b.orig == f->first_bank-KMAST_EV) || skip_second_event) break; + if ((b.orig == f->first_bank - KMAST_EV) || skip_second_event) break; rv = zebra_get_bank(f,&b,b.orig); -- cgit