avoid of fix warnings issued by Visual Studio YAZ-803
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 5 Dec 2014 10:41:04 +0000 (11:41 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 5 Dec 2014 10:41:04 +0000 (11:41 +0100)
Add some type casts and in other cases change integer type.

client/client.c
src/ber_int.c
src/cclfind.c
src/cql.y
src/iconv_encode_danmarc.c
src/iconv_encode_marc8.c
src/iso5428.c
src/seshigh.c

index 898234b..7386faa 100644 (file)
@@ -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 ? '*' : ' ');
index 4d126db..40dbb0c 100644 (file)
@@ -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++)
index 52ea57c..c86015f 100644 (file)
@@ -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,
index cf85690..ed5735d 100644 (file)
--- a/src/cql.y
+++ b/src/cql.y
 #endif
 #include <stdio.h>
 #include <stdlib.h>
+/* avoid that bison stuff defines malloc/free - already in stdlib.h */
+#ifdef _MSC_VER
+#define _STDLIB_H 1
+#endif
 #include <string.h>
 #include <yaz/yaz-iconv.h>
 #include <yaz/xmalloc.h>
index bc7d62a..200e2f5 100644 (file)
@@ -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
index ac18e79..aed43c2 100644 (file)
@@ -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
index 3df6b5d..8d7b3c2 100644 (file)
@@ -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;
index 6e18d01..52ced9b 100644 (file)
@@ -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)