From bfe768e3b0cf959ed9982a7b6ff6dc9e906820f4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 5 Dec 2014 11:41:04 +0100 Subject: [PATCH] avoid of fix warnings issued by Visual Studio YAZ-803 Add some type casts and in other cases change integer type. --- client/client.c | 6 +++--- src/ber_int.c | 2 +- src/cclfind.c | 4 ++-- src/cql.y | 4 ++++ src/iconv_encode_danmarc.c | 4 ++-- src/iconv_encode_marc8.c | 2 +- src/iso5428.c | 2 +- src/seshigh.c | 5 +++-- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/client/client.c b/client/client.c index 898234b..7386faa 100644 --- a/client/client.c +++ b/client/client.c @@ -545,7 +545,7 @@ static void render_diag(Z_DiagnosticFormat *diag) Z_DefaultDiagFormat *dd = ds->u.defaultDiagRec; /* ### should check `dd->diagnosticSetId' */ printf("code=" ODR_INT_PRINTF " (%s)", *dd->condition, - diagbib1_str(*dd->condition)); + diagbib1_str((int) *dd->condition)); /* Both types of addinfo are the same, so use type-pun */ if (dd->u.v2Addinfo != 0) printf(",\n\taddinfo='%s'", dd->u.v2Addinfo); @@ -1203,7 +1203,7 @@ static void display_diagrecs(Z_DiagRec **pp, int num) printf("Unknown diagset: %s\n", diag_name); } printf(" [" ODR_INT_PRINTF "] %s", - *r->condition, diagbib1_str(*r->condition)); + *r->condition, diagbib1_str((int) *r->condition)); switch (r->which) { case Z_DefaultDiagFormat_v2Addinfo: @@ -3478,7 +3478,7 @@ static void process_Z3950_scanResponse(Z_ScanResponse *res) num_entries = res->entries->num_entries; for (i = 0; i < num_entries; i++) { - int pos_term = res->positionOfTerm ? *res->positionOfTerm : -1; + Odr_int pos_term = res->positionOfTerm ? *res->positionOfTerm : -1; if (entries[i]->which == Z_Entry_termInfo) { printf("%c ", i + 1 == pos_term ? '*' : ' '); diff --git a/src/ber_int.c b/src/ber_int.c index 4d126db..40dbb0c 100644 --- a/src/ber_int.c +++ b/src/ber_int.c @@ -66,7 +66,7 @@ int ber_encinteger(ODR o, Odr_int val) size_t i; for (i = sizeof(uval); i > 0; ) { - tmp[--i] = uval; + tmp[--i] = (unsigned char ) uval; /* only want lower 8 bits */ uval >>= 8; } for (i = 0; i < sizeof(uval)-1; i++) diff --git a/src/cclfind.c b/src/cclfind.c index 52ea57c..c86015f 100644 --- a/src/cclfind.c +++ b/src/cclfind.c @@ -231,7 +231,7 @@ static size_t cmp_operator(const char **aliases, const char *input) #define CCL_CHARS "#?\\" static int has_ccl_masking(const char *src_str, - int src_len, + size_t src_len, const char **truncation_aliases, const char **mask_aliases) { @@ -331,7 +331,7 @@ static int append_term(CCL_parser cclp, const char *src_str, size_t src_len, static struct ccl_rpn_node *ccl_term_one_use(CCL_parser cclp, struct ccl_rpn_attr *attr_use, ccl_qualifier_t *qa, - int no, int term_len, + size_t no, int term_len, const char **truncation_aliases, const char **mask_aliases, int is_phrase, diff --git a/src/cql.y b/src/cql.y index cf85690..ed5735d 100644 --- a/src/cql.y +++ b/src/cql.y @@ -16,6 +16,10 @@ #endif #include #include +/* avoid that bison stuff defines malloc/free - already in stdlib.h */ +#ifdef _MSC_VER +#define _STDLIB_H 1 +#endif #include #include #include diff --git a/src/iconv_encode_danmarc.c b/src/iconv_encode_danmarc.c index bc7d62a..200e2f5 100644 --- a/src/iconv_encode_danmarc.c +++ b/src/iconv_encode_danmarc.c @@ -34,7 +34,7 @@ static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en, } *outp++ = '@'; (*outbytesleft)--; - *outp++ = x; + *outp++ = (unsigned char) x; (*outbytesleft)--; } else if (x <= 255) @@ -44,7 +44,7 @@ static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en, yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t)(-1); } - *outp++ = x; + *outp++ = (unsigned char) x; (*outbytesleft)--; } else diff --git a/src/iconv_encode_marc8.c b/src/iconv_encode_marc8.c index ac18e79..aed43c2 100644 --- a/src/iconv_encode_marc8.c +++ b/src/iconv_encode_marc8.c @@ -322,7 +322,7 @@ static size_t yaz_write_marc8_2(yaz_iconv_t cd, struct encoder_data *w, yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t) (-1); } - *(*outbuf)++ = y; + *(*outbuf)++ = (char) y; (*outbytesleft)--; } else diff --git a/src/iso5428.c b/src/iso5428.c index 3df6b5d..8d7b3c2 100644 --- a/src/iso5428.c +++ b/src/iso5428.c @@ -356,7 +356,7 @@ static size_t write_iso_5428_1984(yaz_iconv_t cd, yaz_iconv_encoder_t en, yaz_iconv_set_errno(cd, YAZ_ICONV_EILSEQ); return (size_t) -1; } - out[k++] = x; + out[k++] = (unsigned char ) x; break; } *outbytesleft -= k; diff --git a/src/seshigh.c b/src/seshigh.c index 6e18d01..52ced9b 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2498,7 +2498,8 @@ static Z_Records *pack_records(association *a, char *setname, Odr_int start, Z_ReferenceId *referenceId, Odr_oid *oid, int *errcode) { - int recno, dumped_records = 0; + int recno; + Odr_int dumped_records = 0; int toget = odr_int_to_int(*num); Z_Records *records = (Z_Records *) odr_malloc(a->encode, sizeof(*records)); @@ -2591,7 +2592,7 @@ static Z_Records *pack_records(association *a, char *setname, Odr_int start, else this_length = odr_total(a->encode) - total_length - dumped_records; yaz_log(log_requestdetail, " fetched record, len=" ODR_INT_PRINTF - " total=" ODR_INT_PRINTF " dumped=%d", + " total=" ODR_INT_PRINTF " dumped=" ODR_INT_PRINTF, this_length, total_length, dumped_records); if (a->preferredMessageSize > 0 && this_length + total_length > a->preferredMessageSize) -- 1.7.10.4