From 5d2484328c438d0e3c8565b6531383e866fbac4e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 14 Nov 2006 12:03:48 +0000 Subject: [PATCH] Use assert rather than abort --- dict/insert.c | 7 +++---- isamb/isamb.c | 12 ++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/dict/insert.c b/dict/insert.c index 54d4faf..bdc1857 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -1,4 +1,4 @@ -/* $Id: insert.c,v 1.28 2006-08-29 13:39:18 adam Exp $ +/* $Id: insert.c,v 1.29 2006-11-14 12:04:38 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -105,8 +105,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) } } } - if (best_no < 0) /* we didn't find any tail string entry at all! */ - return -1; + assert(best_no >= 0); /* we didn't find any tail string entry at all! */ j = best_indxp - (short*) p; subptr = new_page (dict, ptr, &subp); @@ -344,7 +343,7 @@ static int dict_ins (Dict dict, const Dict_char *str, if (split_page (dict, ptr, p)) { yaz_log (YLOG_FATAL, "Unable to split page %d\n", ptr); - abort (); + assert(0); } return dict_ins (dict, str-1, ptr, userlen, userinfo); } diff --git a/isamb/isamb.c b/isamb/isamb.c index 8e464ba..0578ff7 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.85 2006-11-14 08:12:08 adam Exp $ +/* $Id: isamb.c,v 1.86 2006-11-14 12:03:48 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -462,11 +462,11 @@ static struct ISAMB_block *open_block(ISAMB b, ISAM_P pos) if (!cache_block (b, pos, p->buf, 0)) { yaz_log(b->log_io, "bf_read: open_block"); - if (!bf_read(b->file[cat].bf, pos/CAT_MAX, 0, 0, p->buf)) + if (bf_read(b->file[cat].bf, pos/CAT_MAX, 0, 0, p->buf) != 1) { yaz_log(YLOG_FATAL, "isamb: read fail for pos=%ld block=%ld", (long) pos, (long) pos/CAT_MAX); - abort(); + zebra_exit("isamb:open_block"); } } p->bytes = (char *)p->buf + offset; @@ -512,7 +512,7 @@ struct ISAMB_block *new_block (ISAMB b, int leaf, int cat) { yaz_log(YLOG_FATAL, "isamb: read fail for pos=%ld block=%ld", (long) p->pos/CAT_MAX, (long) p->pos/CAT_MAX); - abort (); + zebra_exit("isamb:new_block"); } } yaz_log(b->log_freelist, "got block " ZINT_FORMAT " from freelist %d:" ZINT_FORMAT, p->pos, @@ -889,7 +889,7 @@ int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, if (!*lookahead_mode) { yaz_log(YLOG_WARN, "isamb: Inconsistent register (1)"); - assert (*lookahead_mode); + assert(*lookahead_mode); } } else @@ -1007,7 +1007,7 @@ int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, { /* this is append. So a delete is bad */ yaz_log(YLOG_WARN, "isamb: Inconsistent register (2)"); - abort(); + assert(*lookahead_mode); } else if (!half1 && dst > tail_cut) { -- 1.7.10.4