Add casts for signed/unsigned ints
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 19 Jan 2010 21:34:30 +0000 (22:34 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 19 Jan 2010 21:34:30 +0000 (22:34 +0100)
19 files changed:
client/admin.c
client/client.c
src/ber_int.c
src/cclqfile.c
src/cclxmlconfig.c
src/cqltransform.c
src/daemon.c
src/grs1disp.c
src/initopt.c
src/querytowrbuf.c
src/readconf.c
src/seshigh.c
src/zgdu.c
src/zoom-c.c
test/tsticonv.c
test/tstnmem.c
test/tstodr.c
test/tstxmlquery.c
ztest/ztest.c

index 972a83c..7812b65 100644 (file)
@@ -236,7 +236,7 @@ int cmd_adm_import(const char *arg)
                 
                 oct->len = oct->size = status.st_size;
                 oct->buf = (unsigned char *) odr_malloc (out, oct->size);
                 
                 oct->len = oct->size = status.st_size;
                 oct->buf = (unsigned char *) odr_malloc (out, oct->size);
-                if (fread(oct->buf, 1, oct->size, inf) != oct->size)
+                if (fread(oct->buf, 1, oct->size, inf) != (size_t) oct->size)
                 {
                     printf("Incomplete read of file %s\n", fname);
                 }
                 {
                     printf("Incomplete read of file %s\n", fname);
                 }
index a2e8b13..cb783b2 100644 (file)
@@ -1945,7 +1945,7 @@ static Z_External *create_external_itemRequest(void)
     return r;
 }
 
     return r;
 }
 
-static Z_External *create_external_ILL_APDU(int which)
+static Z_External *create_external_ILL_APDU(void)
 {
     struct ill_get_ctl ctl;
     ILL_APDU *ill_apdu;
 {
     struct ill_get_ctl ctl;
     ILL_APDU *ill_apdu;
@@ -2047,7 +2047,7 @@ static Z_External *create_ItemOrderExternal(const char *type, int itemno,
     {
         printf("using ILL-request\n");
         r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
     {
         printf("using ILL-request\n");
         r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
-            create_external_ILL_APDU(ILL_APDU_ILL_Request);
+            create_external_ILL_APDU();
     }
     else if (!strcmp(type, "xml") || !strcmp(type, "3"))
     {
     }
     else if (!strcmp(type, "xml") || !strcmp(type, "3"))
     {
index ca3ea10..786321e 100644 (file)
@@ -88,8 +88,7 @@ int ber_encinteger(ODR o, Odr_int val)
 int ber_decinteger(const unsigned char *buf, Odr_int *val, int max)
 {
     unsigned long long uval = 0;
 int ber_decinteger(const unsigned char *buf, Odr_int *val, int max)
 {
     unsigned long long uval = 0;
-    int len;
-    size_t i;
+    int i, len;
     int res;
     const unsigned char *b = buf;
 
     int res;
     const unsigned char *b = buf;
 
@@ -102,7 +101,7 @@ int ber_decinteger(const unsigned char *buf, Odr_int *val, int max)
     b += res;
 
     if (*b & 0x80)
     b += res;
 
     if (*b & 0x80)
-        for (i = 0; i < sizeof(uval) - len; i++)
+        for (i = 0; i < (int) sizeof(uval) - len; i++)
             uval = (uval << 8) + 0xFF;
     for (i = 0; i < len; i++)
         uval = (uval << 8) + b[i];
             uval = (uval << 8) + 0xFF;
     for (i = 0; i < len; i++)
         uval = (uval << 8) + b[i];
index 79e85c2..7583610 100644 (file)
@@ -79,7 +79,7 @@ int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
             /* lead is first of a list of qualifier aliaeses */
             /* qualifier alias: q1 q2 ... */
             char *qlist[10];
             /* lead is first of a list of qualifier aliaeses */
             /* qualifier alias: q1 q2 ... */
             char *qlist[10];
-            int i = 0;
+            size_t i = 0;
 
             qlist[i++] = lead_str;
 
 
             qlist[i++] = lead_str;
 
@@ -239,7 +239,7 @@ void ccl_qual_buf(CCL_bibset bibset, const char *buf)
     while (1)
     {
         const char *cp2 = cp1;
     while (1)
     {
         const char *cp2 = cp1;
-        int len;
+        size_t len;
         while (*cp2 && !strchr("\r\n", *cp2))
             cp2++;
         len = cp2 - cp1;
         while (*cp2 && !strchr("\r\n", *cp2))
             cp2++;
         len = cp2 - cp1;
index 3d68ea7..7d205bb 100644 (file)
@@ -15,7 +15,7 @@
 
 #if YAZ_HAVE_XML2
 
 
 #if YAZ_HAVE_XML2
 
-static int ccl_xml_config_attr(CCL_bibset bibset, const char *default_set,
+static int ccl_xml_config_attr(const char *default_set,
                                WRBUF wrbuf,
                                const xmlNode *ptr,
                                const char **addinfo)
                                WRBUF wrbuf,
                                const xmlNode *ptr,
                                const char **addinfo)
@@ -89,7 +89,7 @@ static int ccl_xml_config_qual(CCL_bibset bibset, const char *default_set,
         {
             if (!xmlStrcmp(a_ptr->name, BAD_CAST "attr"))
             {
         {
             if (!xmlStrcmp(a_ptr->name, BAD_CAST "attr"))
             {
-                int r = ccl_xml_config_attr(bibset, default_set, wrbuf,
+                int r = ccl_xml_config_attr(default_set, wrbuf,
                                             a_ptr, addinfo);
                 if (r)
                     return r;
                                             a_ptr, addinfo);
                 if (r)
                     return r;
index 7173f01..de777d0 100644 (file)
@@ -435,7 +435,7 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category,
             int i;
             while (*cp1 && *cp1 != ' ')
                 cp1++;
             int i;
             while (*cp1 && *cp1 != ' ')
                 cp1++;
-            if (cp1 - cp0 >= sizeof(buf))
+            if (cp1 - cp0 >= (ptrdiff_t) sizeof(buf))
                 break;
             memcpy(buf, cp0, cp1 - cp0);
             buf[cp1-cp0] = 0;
                 break;
             memcpy(buf, cp0, cp1 - cp0);
             buf[cp1-cp0] = 0;
index 0311bc8..a4d0fd4 100644 (file)
@@ -49,7 +49,7 @@ static void write_pidfile(int pid_fd)
             yaz_log(YLOG_FATAL|YLOG_ERRNO, "ftruncate");
             exit(1);
         }
             yaz_log(YLOG_FATAL|YLOG_ERRNO, "ftruncate");
             exit(1);
         }
-        if (write(pid_fd, buf, strlen(buf)) != strlen(buf))
+        if (write(pid_fd, buf, strlen(buf)) != (int) strlen(buf))
         {
             yaz_log(YLOG_FATAL|YLOG_ERRNO, "write");
             exit(1);
         {
             yaz_log(YLOG_FATAL|YLOG_ERRNO, "write");
             exit(1);
index 3f6b540..2f2c152 100644 (file)
@@ -22,13 +22,14 @@ static void display_variant(WRBUF w, Z_Variant *v, int level)
 
     for (i = 0; i < v->num_triples; i++)
     {
 
     for (i = 0; i < v->num_triples; i++)
     {
-        printf("%*sclass=" ODR_INT_PRINTF ",type=" ODR_INT_PRINTF,
-               level * 4, "", *v->triples[i]->zclass,
-               *v->triples[i]->type);
+        wrbuf_printf(w, "%*sclass=" ODR_INT_PRINTF ",type=" ODR_INT_PRINTF,
+                     level * 4, "", *v->triples[i]->zclass,
+                     *v->triples[i]->type);
         if (v->triples[i]->which == Z_Triple_internationalString)
         if (v->triples[i]->which == Z_Triple_internationalString)
-            printf(",value=%s\n", v->triples[i]->value.internationalString);
+            wrbuf_printf(w, ",value=%s\n",
+                         v->triples[i]->value.internationalString);
         else
         else
-            printf("\n");
+            wrbuf_printf(w, "\n");
     }
 }
 
     }
 }
 
@@ -122,7 +123,7 @@ static void display_grs1(WRBUF w, Z_GenericRecord *r, int level)
 
 void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags)
 {
 
 void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags)
 {
-    display_grs1 (wrbuf, r, 0);
+    display_grs1(wrbuf, r, 0);
 }
 
 /*
 }
 
 /*
index 994dec1..e4a2292 100644 (file)
@@ -50,7 +50,7 @@ int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
     while (*cp)
     {
         char this_opt[42];
     while (*cp)
     {
         char this_opt[42];
-        int i, j;
+        size_t i, j;
         if (*cp == ' ' || *cp == ',')
         {
             cp++;
         if (*cp == ' ' || *cp == ',')
         {
             cp++;
index 5adb6be..d507365 100644 (file)
@@ -233,7 +233,7 @@ void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt,
     yaz_apt_to_wrbuf(b, zapt);
 }
 
     yaz_apt_to_wrbuf(b, zapt);
 }
 
-void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags)
+void wrbuf_diags(WRBUF b, int num_diagnostics, Z_DiagRec **diags)
 {
     /* we only dump the first diag - that keeps the log cleaner. */
     wrbuf_printf(b," ERROR ");
 {
     /* we only dump the first diag - that keeps the log cleaner. */
     wrbuf_printf(b," ERROR ");
index 6497ff6..688a433 100644 (file)
@@ -37,7 +37,7 @@ int readconf_line(FILE *f, int *lineno, char *line, int len,
     if (!p)
         return 0;
     
     if (!p)
         return 0;
     
-    for (argc = 0; *p ; argc++)
+    for (argc = 0; *p && argc < num ; argc++)
     {
         if (*p == '#')  /* trailing comment */
             break;
     {
         if (*p == '#')  /* trailing comment */
             break;
index 9bf39ca..5393e4c 100644 (file)
@@ -846,7 +846,7 @@ static int ccl2pqf(ODR odr, const Odr_oct *ccl, CCL_bibset bibset,
     return 0;
 }
 
     return 0;
 }
 
-static void srw_bend_search(association *assoc, request *req,
+static void srw_bend_search(association *assoc,
                             Z_SRW_PDU *sr,
                             Z_SRW_PDU *res,
                             int *http_code)
                             Z_SRW_PDU *sr,
                             Z_SRW_PDU *res,
                             int *http_code)
@@ -1149,7 +1149,7 @@ static void srw_bend_search(association *assoc, request *req,
     }
 }
 
     }
 }
 
-static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
+static char *srw_bend_explain_default(bend_explain_rr *rr)
 {
 #if YAZ_HAVE_XML2
     xmlNodePtr ptr = (xmlNode *) rr->server_node_ptr;
 {
 #if YAZ_HAVE_XML2
     xmlNodePtr ptr = (xmlNode *) rr->server_node_ptr;
@@ -1185,7 +1185,7 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
     return 0;
 }
 
     return 0;
 }
 
-static void srw_bend_explain(association *assoc, request *req,
+static void srw_bend_explain(association *assoc,
                              Z_SRW_PDU *sr,
                              Z_SRW_explainResponse *srw_res,
                              int *http_code)
                              Z_SRW_PDU *sr,
                              Z_SRW_explainResponse *srw_res,
                              int *http_code)
@@ -1211,7 +1211,7 @@ static void srw_bend_explain(association *assoc, request *req,
         if (assoc->init->bend_explain)
             (*assoc->init->bend_explain)(assoc->backend, &rr);
         else
         if (assoc->init->bend_explain)
             (*assoc->init->bend_explain)(assoc->backend, &rr);
         else
-            srw_bend_explain_default(assoc->backend, &rr);
+            srw_bend_explain_default(&rr);
 
         if (rr.explain_buf)
         {
 
         if (rr.explain_buf)
         {
@@ -1233,7 +1233,7 @@ static void srw_bend_explain(association *assoc, request *req,
     }
 }
 
     }
 }
 
-static void srw_bend_scan(association *assoc, request *req,
+static void srw_bend_scan(association *assoc,
                           Z_SRW_PDU *sr,
                           Z_SRW_scanResponse *srw_res,
                           int *http_code)
                           Z_SRW_PDU *sr,
                           Z_SRW_scanResponse *srw_res,
                           int *http_code)
@@ -1421,7 +1421,7 @@ static void srw_bend_scan(association *assoc, request *req,
 
 }
 
 
 }
 
-static void srw_bend_update(association *assoc, request *req,
+static void srw_bend_update(association *assoc,
                            Z_SRW_PDU *sr,
                            Z_SRW_updateResponse *srw_res,
                            int *http_code)
                            Z_SRW_PDU *sr,
                            Z_SRW_updateResponse *srw_res,
                            int *http_code)
@@ -1790,7 +1790,7 @@ static void process_http_request(association *assoc, request *req)
             }
             else
             {
             }
             else
             {
-                srw_bend_search(assoc, req, sr, res, &http_code);
+                srw_bend_search(assoc, sr, res, &http_code);
             }
             if (http_code == 200)
                 soap_package->u.generic->p = res;
             }
             if (http_code == 200)
                 soap_package->u.generic->p = res;
@@ -1805,8 +1805,7 @@ static void process_http_request(association *assoc, request *req)
                 res->u.explain_response->diagnostics = diagnostic;
                 res->u.explain_response->num_diagnostics = num_diagnostic;
             }
                 res->u.explain_response->diagnostics = diagnostic;
                 res->u.explain_response->num_diagnostics = num_diagnostic;
             }
-            srw_bend_explain(assoc, req, sr,
-                             res->u.explain_response, &http_code);
+            srw_bend_explain(assoc, sr, res->u.explain_response, &http_code);
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
@@ -1820,8 +1819,7 @@ static void process_http_request(association *assoc, request *req)
                 res->u.scan_response->diagnostics = diagnostic;
                 res->u.scan_response->num_diagnostics = num_diagnostic;
             }
                 res->u.scan_response->diagnostics = diagnostic;
                 res->u.scan_response->num_diagnostics = num_diagnostic;
             }
-            srw_bend_scan(assoc, req, sr,
-                          res->u.scan_response, &http_code);
+            srw_bend_scan(assoc, sr, res->u.scan_response, &http_code);
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
@@ -1836,8 +1834,7 @@ static void process_http_request(association *assoc, request *req)
                 res->u.update_response->num_diagnostics = num_diagnostic;
             }
             yaz_log(YLOG_DEBUG, "num_diag = %d", res->u.update_response->num_diagnostics );
                 res->u.update_response->num_diagnostics = num_diagnostic;
             }
             yaz_log(YLOG_DEBUG, "num_diag = %d", res->u.update_response->num_diagnostics );
-            srw_bend_update(assoc, req, sr,
-                            res->u.update_response, &http_code);
+            srw_bend_update(assoc, sr, res->u.update_response, &http_code);
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
index 22c594c..d414406 100644 (file)
@@ -12,7 +12,7 @@
 #include <yaz/odr.h>
 #include <yaz/zgdu.h>
 
 #include <yaz/odr.h>
 #include <yaz/zgdu.h>
 
-int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
+int z_GDU(ODR o, Z_GDU **p, int opt, const char *name)
 {
     if (o->direction == ODR_DECODE) {
         *p = (Z_GDU *) odr_malloc(o, sizeof(**p));
 {
     if (o->direction == ODR_DECODE) {
         *p = (Z_GDU *) odr_malloc(o, sizeof(**p));
index 0dd7110..cb6144e 100644 (file)
@@ -1848,7 +1848,7 @@ static yaz_iconv_t iconv_create_charset(const char *record_charset)
     {
         /* Use "from,to" or just "from" */
         const char *cp = strchr(record_charset, ',');
     {
         /* Use "from,to" or just "from" */
         const char *cp = strchr(record_charset, ',');
-        int clen = strlen(record_charset);
+        size_t clen = strlen(record_charset);
         if (cp && cp[1])
         {
             strncpy( to, cp+1, sizeof(to)-1);
         if (cp && cp[1])
         {
             strncpy( to, cp+1, sizeof(to)-1);
@@ -2065,7 +2065,7 @@ ZOOM_API(const char *)
     char charset[40];
     char xpath[512];
     const char *cp;
     char charset[40];
     char xpath[512];
     const char *cp;
-    int i;
+    size_t i;
     Z_NamePlusRecord *npr;
     
     if (len)
     Z_NamePlusRecord *npr;
     
     if (len)
@@ -2093,7 +2093,7 @@ ZOOM_API(const char *)
             i++;
         if (!strncmp(type_spec+i, "charset=", 8))
         {
             i++;
         if (!strncmp(type_spec+i, "charset=", 8))
         {
-            int j = 0;
+            size_t j = 0;
             i = i + 8; /* skip charset= */
             for (j = 0; type_spec[i]  && j < sizeof(charset)-1; i++, j++)
             {
             i = i + 8; /* skip charset= */
             for (j = 0; type_spec[i]  && j < sizeof(charset)-1; i++, j++)
             {
@@ -2105,7 +2105,7 @@ ZOOM_API(const char *)
         }
         else if (!strncmp(type_spec+i, "xpath=", 6))
         {
         }
         else if (!strncmp(type_spec+i, "xpath=", 6))
         {
-            int j = 0; 
+            size_t j = 0; 
             i = i + 6;
             for (j = 0; type_spec[i] && j < sizeof(xpath)-1; i++, j++)
                 xpath[j] = cp[i];
             i = i + 6;
             for (j = 0; type_spec[i] && j < sizeof(xpath)-1; i++, j++)
                 xpath[j] = cp[i];
@@ -2924,7 +2924,7 @@ static void ZOOM_scanset_term_x(ZOOM_scanset scan, size_t pos,
     *disp_len = 0;
 
     *occ = 0;
     *disp_len = 0;
 
     *occ = 0;
-    if (pos >= noent || pos < 0)
+    if (pos >= noent)
         return;
     if (scan->scan_response)
     {
         return;
     if (scan->scan_response)
     {
index feb8868..352033a 100644 (file)
@@ -96,7 +96,7 @@ static int tst_convert_x(yaz_iconv_t cd, const char *buf, const char *cmpbuf,
     size_t inbytesleft = strlen(buf);
     const char *inp = buf;
     int rounds = 0;
     size_t inbytesleft = strlen(buf);
     const char *inp = buf;
     int rounds = 0;
-    for (rounds = 0; inbytesleft && rounds < sizeof(outbuf); rounds++)
+    for (rounds = 0; inbytesleft && rounds < (int) sizeof(outbuf); rounds++)
     {
         size_t outbytesleft = sizeof(outbuf);
         char *outp = outbuf;
     {
         size_t outbytesleft = sizeof(outbuf);
         char *outp = outbuf;
index 7267744..80a2e56 100644 (file)
@@ -28,13 +28,13 @@ void tst(void)
     {
         cp = (char *) nmem_malloc(n, j);
         YAZ_CHECK(cp);
     {
         cp = (char *) nmem_malloc(n, j);
         YAZ_CHECK(cp);
-        if (sizeof(long) >= j)
+        if ((int) sizeof(long) >= j)
             *(long*) cp = 123L;
 #if HAVE_LONG_LONG
             *(long*) cp = 123L;
 #if HAVE_LONG_LONG
-        if (sizeof(long long) >= j)
+        if ((int) sizeof(long long) >= j)
             *(long long*) cp = 123L;
 #endif
             *(long long*) cp = 123L;
 #endif
-        if (sizeof(double) >= j)
+        if ((int) sizeof(double) >= j)
             *(double*) cp = 12.2;
     }
     
             *(double*) cp = 12.2;
     }
     
index 56b7bb0..83d2d2c 100644 (file)
@@ -105,13 +105,13 @@ void tst_MySequence3(ODR encode, ODR decode)
     Yc_MySequence *t;
 
     srand(123);
     Yc_MySequence *t;
 
     srand(123);
-    for (i = 0; i<1000; i++)
+    for (i = 0; i < 1000; i++)
     {
         int j;
     {
         int j;
-        for (j = 0; j<sizeof(buf); j++)
+        for (j = 0; j < (int) sizeof(buf); j++)
             buf[j] = rand();
 
             buf[j] = rand();
 
-        for (j = 1; j<sizeof(buf); j++)
+        for (j = 1; j < (int) sizeof(buf); j++)
         {
             odr_setbuf(decode, buf, j, 0);
             yc_MySequence(decode, &t, 0, 0);
         {
             odr_setbuf(decode, buf, j, 0);
             yc_MySequence(decode, &t, 0, 0);
index c1828e2..c1e9034 100644 (file)
@@ -59,7 +59,7 @@ enum pqf2xml_status pqf2xml_text(const char *pqf, const char *expect_xml,
 
             xmlDocDumpMemory(doc, (xmlChar **) &buf_out, &len_out);
             
 
             xmlDocDumpMemory(doc, (xmlChar **) &buf_out, &len_out);
             
-            if (len_out == strlen(expect_xml)
+            if (len_out == (int) strlen(expect_xml)
                 && memcmp(buf_out, expect_xml, len_out) == 0)
             {
                 Z_Query *query2 = 0;
                 && memcmp(buf_out, expect_xml, len_out) == 0)
             {
                 Z_Query *query2 = 0;
index d58d724..7d2f90b 100644 (file)
@@ -721,7 +721,7 @@ int ztest_scan(void *handle, bend_scan_rr *q)
             return 0;
         }
         len = q->term->term->u.general->len;
             return 0;
         }
         len = q->term->term->u.general->len;
-        if (len >= sizeof(term))
+        if (len >= (int ) sizeof(term))
             len = sizeof(term)-1;
         memcpy(term, q->term->term->u.general->buf, len);
         term[len] = '\0';
             len = sizeof(term)-1;
         memcpy(term, q->term->term->u.general->buf, len);
         term[len] = '\0';