From bd9d1a9e0d4273ba26f5efe542df0321ce0f4053 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 27 Oct 2006 11:06:45 +0000 Subject: [PATCH] Fixed several compilation warnings. (gcc 4.1.2, -O3 -g -Wall) --- NEWS | 4 ++++ bfile/bfile.c | 8 +------- bfile/mfile.c | 3 +-- include/rsm_or.h | 4 ++-- index/extract.c | 14 +++++++------- index/livcode.c | 11 ++++++----- index/main.c | 4 ++-- index/recindex.c | 21 +++++++++++---------- index/zebraapi.c | 4 ++-- index/zrpn.c | 8 ++++---- index/zserver.c | 13 +++++++------ isamb/isamb.c | 9 +++++---- isamc/isamc.c | 5 +++-- isamc/isamd.c | 6 +++--- isamc/merge-d.c | 19 +++++++++++-------- isams/isams.c | 5 +++-- util/flock.c | 6 +++--- 17 files changed, 75 insertions(+), 69 deletions(-) diff --git a/NEWS b/NEWS index a5fe851..3315c1a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Fixed several compilation warnings. (gcc 4.1.2, -O3 -g -Wall) + +Fixed bug #710: Duplicate keys for CDATA in xelm/melm rules. + --- 1.3.44 2006/10/23 Fixed bug #529: multiple simultaneous updates by extended services trashes diff --git a/bfile/bfile.c b/bfile/bfile.c index 0d90913..00c8690 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -1,4 +1,4 @@ -/* $Id: bfile.c,v 1.35.2.2 2006-10-04 09:07:19 adam Exp $ +/* $Id: bfile.c,v 1.35.2.3 2006-10-27 11:06:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -233,13 +233,7 @@ void bf_commitExec (BFiles bfs) void bf_commitClean (BFiles bfs, const char *spec) { - FILE *inf; - int block_size; - char path[256]; - MFile mf; - CFile cf; int mustDisable = 0; - int firstTime; if (!bfs->commit_area) { diff --git a/bfile/mfile.c b/bfile/mfile.c index 8bbce07..631acf7 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -1,4 +1,4 @@ -/* $Id: mfile.c,v 1.52.2.2 2006-10-04 09:07:19 adam Exp $ +/* $Id: mfile.c,v 1.52.2.3 2006-10-27 11:06:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -289,7 +289,6 @@ MFile_area mf_init(const char *name, const char *spec, const char *base) void mf_destroy(MFile_area ma) { mf_dir *dp; - meta_file *meta_f; if (!ma) return; diff --git a/include/rsm_or.h b/include/rsm_or.h index 3d64ef3..13792e0 100644 --- a/include/rsm_or.h +++ b/include/rsm_or.h @@ -1,4 +1,4 @@ -/* $Id: rsm_or.h,v 1.6.2.1 2006-08-14 10:38:56 adam Exp $ +/* $Id: rsm_or.h,v 1.6.2.2 2006-10-27 11:06:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -39,7 +39,7 @@ typedef struct rset_m_or_parms int (*cmp)(const void *p1, const void *p2); ISAMC isc; - ISAM_P *isam_positions; + ISAMC_P *isam_positions; RSET_TERM rset_term; int no_isam_positions; diff --git a/index/extract.c b/index/extract.c index 5af7668..7802416 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.157.2.4 2006-08-14 10:38:57 adam Exp $ +/* $Id: extract.c,v 1.157.2.5 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -1563,9 +1563,9 @@ static void extract_add_sort_string (RecWord *p, const char *string, { int set, use, slen; - off += key_SU_decode(&set, sk->buf + off); - off += key_SU_decode(&use, sk->buf + off); - off += key_SU_decode(&slen, sk->buf + off); + off += key_SU_decode(&set, (const unsigned char *) sk->buf + off); + off += key_SU_decode(&use, (const unsigned char *) sk->buf + off); + off += key_SU_decode(&slen, (const unsigned char *) sk->buf + off); off += slen; if (p->attrSet == set && p->attrUse == use) return; @@ -1742,9 +1742,9 @@ void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, { int set, use, slen; - off += key_SU_decode(&set, sk->buf + off); - off += key_SU_decode(&use, sk->buf + off); - off += key_SU_decode(&slen, sk->buf + off); + off += key_SU_decode(&set, (const unsigned char *) sk->buf + off); + off += key_SU_decode(&use, (const unsigned char *) sk->buf + off); + off += key_SU_decode(&slen, (const unsigned char *) sk->buf + off); sortIdx_type(sortIdx, use); if (cmd == 1) diff --git a/index/livcode.c b/index/livcode.c index 21b18d3..d6e30f1 100644 --- a/index/livcode.c +++ b/index/livcode.c @@ -11,7 +11,7 @@ rights reserved. Licensed under the Academic Free License version 1.1. http://opensource.org/licenses/academic.php -$Id: livcode.c,v 1.2 2004-08-04 08:35:23 adam Exp $ +$Id: livcode.c,v 1.1.2.1 2006-10-27 11:06:46 adam Exp $ */ @@ -291,8 +291,9 @@ Z_Operand *set_operand( Z_Operand *thisop, int newattr ) general->len = thisop->u.attributesPlusTerm->term->u.general->len ; general->size = thisop->u.attributesPlusTerm->term->u.general->size ; general->buf = malloc( general->size ) ; - strcpy( general->buf, - thisop->u.attributesPlusTerm->term->u.general->buf ) ; + strcpy( (char *) general->buf, + (const char *) + thisop->u.attributesPlusTerm->term->u.general->buf ) ; return operand ; } @@ -649,12 +650,12 @@ static void add (void *set_handle, int seqno, int term_index) * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. */ -static int calc (void *set_handle, zint sysno) +static int calc (void *set_handle, int sysno) { int i, lo, divisor, score = 0; struct rank_set_info *si = (struct rank_set_info *) set_handle; - logf (LOG_DEBUG, "livrank calc sysno=" ZINT_FORMAT, sysno); + logf (LOG_DEBUG, "livrank calc sysno=%d", sysno); if (!si->no_rank_entries) return -1; diff --git a/index/main.c b/index/main.c index de96989..408c3c9 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.112.2.6 2006-08-14 10:38:59 adam Exp $ +/* $Id: main.c,v 1.112.2.7 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995-2005 Index Data Aps @@ -44,7 +44,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif -#include +#include #include "zebraapi.h" char *prog; diff --git a/index/recindex.c b/index/recindex.c index 2610d5c..786eec1 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -1,4 +1,4 @@ -/* $Id: recindex.c,v 1.34.2.3 2006-08-14 10:38:59 adam Exp $ +/* $Id: recindex.c,v 1.34.2.4 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -309,7 +309,7 @@ Records rec_open (BFiles bfs, int rw, int compression_method) return p; } -static void rec_encode_unsigned (unsigned n, unsigned char *buf, int *len) +static void rec_encode_unsigned (unsigned n, char *buf, int *len) { (*len) = 0; while (n > 127) @@ -322,19 +322,20 @@ static void rec_encode_unsigned (unsigned n, unsigned char *buf, int *len) (*len)++; } -static void rec_decode_unsigned(unsigned *np, unsigned char *buf, int *len) +static void rec_decode_unsigned(unsigned *np, char *buf, int *len) { + unsigned char *cp = (unsigned char *) buf; unsigned n = 0; unsigned w = 1; (*len) = 0; - while (buf[*len] > 127) + while (cp[*len] > 127) { - n += w*(buf[*len] & 127); + n += w*(cp[*len] & 127); w = w << 7; (*len)++; } - n += w * buf[*len]; + n += w * cp[*len]; (*len)++; *np = n; } @@ -430,7 +431,7 @@ static void rec_write_multiple (Records p, int saveCount) *sysnop = -1; if (ref_count) { - int csize = 0; /* indicate compression "not performed yet" */ + unsigned int csize = 0; /* indicate compression "not performed yet" */ compression_method = p->compression_method; switch (compression_method) { @@ -581,7 +582,7 @@ static Record rec_get_int (Records p, int sysno) char *in_buf = 0; char *bz_buf = 0; #if HAVE_BZLIB_H - int bz_size; + unsigned int bz_size; #endif char compression_method; @@ -668,14 +669,14 @@ static Record rec_get_int (Records p, int sysno) nptr = in_buf; /* skip ref count */ while (nptr < in_buf + in_size) { - int this_sysno; + unsigned int this_sysno; int len; rec_decode_unsigned (&this_sysno, nptr, &len); nptr += len; for (i = 0; i < REC_NO_INFO; i++) { - int this_size; + unsigned int this_size; rec_decode_unsigned (&this_size, nptr, &len); nptr += len; diff --git a/index/zebraapi.c b/index/zebraapi.c index 9043248..424d254 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.120.2.18 2006-10-26 23:46:25 adam Exp $ +/* $Id: zebraapi.c,v 1.120.2.19 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -1104,7 +1104,7 @@ int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment) &sysno, 0, /* match */ 0, /* fname */ - oct->buf, oct->len, + (char *) oct->buf, oct->len, 0); } } diff --git a/index/zrpn.c b/index/zrpn.c index c57d115..58c051f 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.141.2.15 2006-08-14 10:39:01 adam Exp $ +/* $Id: zrpn.c,v 1.141.2.16 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995-2005 Index Data Aps @@ -231,7 +231,7 @@ static void add_isam_p(const char *name, const char *info, int set, use; char term_tmp[IT_MAX_WORD]; int su_code = 0; - int len = key_SU_decode(&su_code, name); + int len = key_SU_decode(&su_code, (const unsigned char *) name); term_untrans(p->zh, p->reg_type, term_tmp, name+len+1); yaz_log(LOG_LOG, "grep: %d %c %s", su_code, name[len], term_tmp); @@ -1264,7 +1264,7 @@ static int zapt_term_to_utf8 (ZebraHandle zh, Z_AttributesPlusTerm *zapt, case Z_Term_general: if (zh->iconv_to_utf8 != 0) { - char *inbuf = term->u.general->buf; + char *inbuf = (char *) term->u.general->buf; size_t inleft = term->u.general->len; char *outbuf = termz; size_t outleft = IT_MAX_WORD-1; @@ -2729,7 +2729,7 @@ void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, int j, j0 = -1; const char *mterm = NULL; const char *tst; - RSET rset; + RSET rset = 0; int lo = i + pos-1; /* offset in result list */ for (j = 0; j < ord_no; j++) diff --git a/index/zserver.c b/index/zserver.c index 754c53c..f208cbd 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.117.2.6 2006-08-14 10:39:01 adam Exp $ +/* $Id: zserver.c,v 1.117.2.7 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -622,9 +622,10 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) { int r = zebra_admin_exchange_record ( zh, - rec->u.octet_aligned->buf, + (const char *) rec->u.octet_aligned->buf, rec->u.octet_aligned->len, - opaque_recid->buf, opaque_recid->len, + (const char *) opaque_recid->buf, + opaque_recid->len, action); if (r) { @@ -644,7 +645,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) &sysno, 0, /* match */ 0, /* fname */ - rec->u.octet_aligned->buf, + (const char *) rec->u.octet_aligned->buf, rec->u.octet_aligned->len, 0); if (r) @@ -662,7 +663,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) &sysno, 0, /* match */ 0, /* fname */ - rec->u.octet_aligned->buf, + (const char *) rec->u.octet_aligned->buf, rec->u.octet_aligned->len, 1); if (r) @@ -680,7 +681,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) &sysno, 0, /* match */ 0, /* fname */ - rec->u.octet_aligned->buf, + (const char *) rec->u.octet_aligned->buf, rec->u.octet_aligned->len, 0); if (r) diff --git a/isamb/isamb.c b/isamb/isamb.c index 18d120d..8a0a584 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.47.2.6 2006-08-14 17:14:08 adam Exp $ +/* $Id: isamb.c,v 1.47.2.7 2006-10-27 11:06:46 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -234,8 +234,9 @@ static void flush_blocks (ISAMB b, int cat) } } -static int get_block (ISAMB b, ISAMC_P pos, char *userbuf, int wr) +static int get_block (ISAMB b, ISAMC_P pos, unsigned char *ub, int wr) { + char *userbuf = (char *) ub; int cat = pos&CAT_MASK; int off = ((pos/CAT_MAX) & (ISAMB_CACHE_ENTRY_SIZE / b->file[cat].head.block_size - 1)) @@ -351,7 +352,7 @@ static struct ISAMB_block *open_block (ISAMB b, ISAMC_P pos) abort(); } } - p->bytes = p->buf + ISAMB_DATA_OFFSET; + p->bytes = (char *) p->buf + ISAMB_DATA_OFFSET; p->leaf = p->buf[0]; p->size = (p->buf[1] + 256 * p->buf[2]) - ISAMB_DATA_OFFSET; if (p->size < 0) @@ -401,7 +402,7 @@ struct ISAMB_block *new_block (ISAMB b, int leaf, int cat) p->cat = cat; b->file[cat].head_dirty = 1; memset (p->buf, 0, b->file[cat].head.block_size); - p->bytes = p->buf + ISAMB_DATA_OFFSET; + p->bytes = (char *) p->buf + ISAMB_DATA_OFFSET; p->leaf = leaf; p->size = 0; p->dirty = 1; diff --git a/isamc/isamc.c b/isamc/isamc.c index e63e03e..f84c809 100644 --- a/isamc/isamc.c +++ b/isamc/isamc.c @@ -1,4 +1,4 @@ -/* $Id: isamc.c,v 1.24.2.1 2006-08-14 10:39:10 adam Exp $ +/* $Id: isamc.c,v 1.24.2.2 2006-10-27 11:06:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -488,7 +488,8 @@ ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P ipos) /* returns non-zero if item could be read; 0 otherwise */ int isc_pp_read (ISAMC_PP pp, void *buf) { - return isc_read_item (pp, (char **) &buf); + char *cp = buf; + return isc_read_item (pp, &cp); } /* read one item from file - decode and store it in *dst. diff --git a/isamc/isamd.c b/isamc/isamd.c index ac05647..5babb4d 100644 --- a/isamc/isamd.c +++ b/isamc/isamd.c @@ -1,4 +1,4 @@ -/* $Id: isamd.c,v 1.27.2.1 2006-08-14 10:39:10 adam Exp $ +/* $Id: isamd.c,v 1.27.2.2 2006-10-27 11:06:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -707,8 +707,8 @@ void isamd_buildlaterblock(ISAMD_PP pp){ /* returns non-zero if item could be read; 0 otherwise */ int isamd_pp_read (ISAMD_PP pp, void *buf) { - - return isamd_read_item (pp, (char **) &buf); + char *cp = buf; + return isamd_read_item (pp, &cp); /* note: isamd_read_item is in merge-d.c, because it is so */ /* convoluted with the merge process */ } diff --git a/isamc/merge-d.c b/isamc/merge-d.c index d029626..69aa1b7 100644 --- a/isamc/merge-d.c +++ b/isamc/merge-d.c @@ -1,4 +1,4 @@ -/* $Id: merge-d.c,v 1.30.2.1 2006-08-14 10:39:11 adam Exp $ +/* $Id: merge-d.c,v 1.30.2.2 2006-10-27 11:06:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -388,7 +388,7 @@ static void getDiffInfo(ISAMD_PP pp ) if (pp->is->method->debug > 5) logf(LOG_LOG,"isamd_getDiff[%d]:%d-%d %s", i,diffidx-sizeof(int),pp->diffinfo[i].maxidx, - hexdump((char *)&pp->diffbuf[diffidx-4],8,0) ); + hexdump((unsigned char *)&pp->diffbuf[diffidx-4],8,0) ); diffidx=pp->diffinfo[i].maxidx; if ( diffidx > pp->is->method->filecat[pp->cat].bsize ) return; /* whole block done */ @@ -450,7 +450,7 @@ static ISAMD_PP append_main_item(ISAMD_PP firstpp, assert ( (codelen<128) && (codelen>0)); if (pp->is->method->debug >7) logf(LOG_LOG,"isamd:build: coded %s nk=%d,ofs=%d-%d", - hexdump(codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1, + hexdump((unsigned char *) codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1, pp->offset, pp->offset+codelen); if (pp->offset + codelen > maxsize ) @@ -466,7 +466,7 @@ static ISAMD_PP append_main_item(ISAMD_PP firstpp, assert ( (codelen<128) && (codelen>0)); if (pp->is->method->debug >7) logf(LOG_LOG,"isamd:build: recoded into %s (nk=%d)", - hexdump(codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1); + hexdump((unsigned char *) codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1); } /* block full */ assert (pp->offset + codelen <= maxsize ); @@ -562,7 +562,7 @@ int isamd_read_item_merge ( if (pp->is->method->debug > 9) logf(LOG_LOG,"isamd_read_item: dif[%d] at %d-%d: %s", i,oldoffs, pp->diffinfo[i].diffidx, - hexdump(pp->buf+oldoffs, pp->diffinfo[i].diffidx-oldoffs,0)); + hexdump((unsigned char *) pp->buf+oldoffs, pp->diffinfo[i].diffidx-oldoffs,0)); if (pp->is->method->debug > 7) logf(LOG_LOG,"isamd_read_item: rd dif[%d] %d.%d (%x.%x)", i, @@ -862,7 +862,7 @@ static int append_diffs( char *i_item = (char *) &i_key; /* same as chars */ char *i_ptr=i_item; int i_more =1; - int i_mode; /* 0 for delete, 1 for insert */ + int i_mode = 1; /* 0 for delete, 1 for insert */ ISAMD_PP firstpp; char hexbuff[64]; @@ -929,7 +929,7 @@ static int append_diffs( assert ( (codelen<128) && (codelen>0)); if (is->method->debug >7) logf(LOG_LOG,"isamd_appd: coded %d: %s (nk=%d) (ix=%d)", - codelen, hexdump(codebuff, codelen,hexbuff), + codelen, hexdump((unsigned char *) codebuff, codelen,hexbuff), firstpp->numKeys,diffidx); if (diffidx + codelen > maxsize ) @@ -1100,7 +1100,10 @@ int isamd_append (ISAMD is, char *dictentry, int dictlen, ISAMD_I data) /* * $Log: merge-d.c,v $ - * Revision 1.30.2.1 2006-08-14 10:39:11 adam + * Revision 1.30.2.2 2006-10-27 11:06:47 adam + * Fixed several compilation warnings. (gcc 4.1.2, -O3 -g -Wall) + * + * Revision 1.30.2.1 2006/08/14 10:39:11 adam * Update copyright year + FSF address * * Revision 1.30 2003/03/05 16:41:10 adam diff --git a/isams/isams.c b/isams/isams.c index ce30444..28e4c43 100644 --- a/isams/isams.c +++ b/isams/isams.c @@ -1,4 +1,4 @@ -/* $Id: isams.c,v 1.5.2.1 2006-08-14 10:39:15 adam Exp $ +/* $Id: isams.c,v 1.5.2.2 2006-10-27 11:06:48 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -224,7 +224,8 @@ int isams_pp_num (ISAMS_PP pp) int isams_pp_read (ISAMS_PP pp, void *buf) { - return isams_read_item (pp, (char **) &buf); + char *buf_cp = buf; + return isams_read_item (pp, &buf_cp); } int isams_read_item (ISAMS_PP pp, char **dst) diff --git a/util/flock.c b/util/flock.c index 01c702f..cc3444b 100644 --- a/util/flock.c +++ b/util/flock.c @@ -1,4 +1,4 @@ -/* $Id: flock.c,v 1.4.2.4 2006-10-23 11:37:11 adam Exp $ +/* $Id: flock.c,v 1.4.2.5 2006-10-27 11:06:48 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -250,7 +250,7 @@ static int unixLock(int fd, int type, int cmd) int zebra_lock_w(ZebraLockHandle h) { - int r; + int r = 0; int do_lock = 0; logf(log_level, "zebra_lock_w fd=%d p=%p fname=%s begin", h->p->fd, h, h->p->fname); @@ -287,7 +287,7 @@ int zebra_lock_w(ZebraLockHandle h) int zebra_lock_r(ZebraLockHandle h) { - int r; + int r = 0; int do_lock = 0; logf(log_level, "zebra_lock_r fd=%d p=%p fname=%s begin", -- 1.7.10.4