From: Adam Dickmeiss Date: Tue, 19 Jan 2010 21:34:30 +0000 (+0100) Subject: Add casts for signed/unsigned ints X-Git-Tag: v4.0.0~1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=ffe862e36b8b60b1197b223cec0b78482cbd7763;p=yaz-moved-to-github.git Add casts for signed/unsigned ints --- diff --git a/client/admin.c b/client/admin.c index 972a83c..7812b65 100644 --- a/client/admin.c +++ b/client/admin.c @@ -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); - 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); } diff --git a/client/client.c b/client/client.c index a2e8b13..cb783b2 100644 --- a/client/client.c +++ b/client/client.c @@ -1945,7 +1945,7 @@ static Z_External *create_external_itemRequest(void) 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; @@ -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 = - create_external_ILL_APDU(ILL_APDU_ILL_Request); + create_external_ILL_APDU(); } else if (!strcmp(type, "xml") || !strcmp(type, "3")) { diff --git a/src/ber_int.c b/src/ber_int.c index ca3ea10..786321e 100644 --- a/src/ber_int.c +++ b/src/ber_int.c @@ -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 len; - size_t i; + int i, len; 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) - 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]; diff --git a/src/cclqfile.c b/src/cclqfile.c index 79e85c2..7583610 100644 --- a/src/cclqfile.c +++ b/src/cclqfile.c @@ -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]; - int i = 0; + size_t i = 0; qlist[i++] = lead_str; @@ -239,7 +239,7 @@ void ccl_qual_buf(CCL_bibset bibset, const char *buf) while (1) { const char *cp2 = cp1; - int len; + size_t len; while (*cp2 && !strchr("\r\n", *cp2)) cp2++; len = cp2 - cp1; diff --git a/src/cclxmlconfig.c b/src/cclxmlconfig.c index 3d68ea7..7d205bb 100644 --- a/src/cclxmlconfig.c +++ b/src/cclxmlconfig.c @@ -15,7 +15,7 @@ #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) @@ -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")) { - 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; diff --git a/src/cqltransform.c b/src/cqltransform.c index 7173f01..de777d0 100644 --- a/src/cqltransform.c +++ b/src/cqltransform.c @@ -435,7 +435,7 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category, 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; diff --git a/src/daemon.c b/src/daemon.c index 0311bc8..a4d0fd4 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -49,7 +49,7 @@ static void write_pidfile(int pid_fd) 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); diff --git a/src/grs1disp.c b/src/grs1disp.c index 3f6b540..2f2c152 100644 --- a/src/grs1disp.c +++ b/src/grs1disp.c @@ -22,13 +22,14 @@ static void display_variant(WRBUF w, Z_Variant *v, int level) 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) - printf(",value=%s\n", v->triples[i]->value.internationalString); + wrbuf_printf(w, ",value=%s\n", + v->triples[i]->value.internationalString); 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) { - display_grs1 (wrbuf, r, 0); + display_grs1(wrbuf, r, 0); } /* diff --git a/src/initopt.c b/src/initopt.c index 994dec1..e4a2292 100644 --- a/src/initopt.c +++ b/src/initopt.c @@ -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]; - int i, j; + size_t i, j; if (*cp == ' ' || *cp == ',') { cp++; diff --git a/src/querytowrbuf.c b/src/querytowrbuf.c index 5adb6be..d507365 100644 --- a/src/querytowrbuf.c +++ b/src/querytowrbuf.c @@ -233,7 +233,7 @@ void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *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 "); diff --git a/src/readconf.c b/src/readconf.c index 6497ff6..688a433 100644 --- a/src/readconf.c +++ b/src/readconf.c @@ -37,7 +37,7 @@ int readconf_line(FILE *f, int *lineno, char *line, int len, if (!p) return 0; - for (argc = 0; *p ; argc++) + for (argc = 0; *p && argc < num ; argc++) { if (*p == '#') /* trailing comment */ break; diff --git a/src/seshigh.c b/src/seshigh.c index 9bf39ca..5393e4c 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -846,7 +846,7 @@ static int ccl2pqf(ODR odr, const Odr_oct *ccl, CCL_bibset bibset, 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) @@ -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; @@ -1185,7 +1185,7 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr) 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) @@ -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 - srw_bend_explain_default(assoc->backend, &rr); + srw_bend_explain_default(&rr); 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) @@ -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) @@ -1790,7 +1790,7 @@ static void process_http_request(association *assoc, request *req) } 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; @@ -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; } - 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; } @@ -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; } - 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; } @@ -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 ); - 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; } diff --git a/src/zgdu.c b/src/zgdu.c index 22c594c..d414406 100644 --- a/src/zgdu.c +++ b/src/zgdu.c @@ -12,7 +12,7 @@ #include #include -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)); diff --git a/src/zoom-c.c b/src/zoom-c.c index 0dd7110..cb6144e 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -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, ','); - int clen = strlen(record_charset); + size_t clen = strlen(record_charset); 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; - int i; + size_t i; Z_NamePlusRecord *npr; if (len) @@ -2093,7 +2093,7 @@ ZOOM_API(const char *) 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++) { @@ -2105,7 +2105,7 @@ ZOOM_API(const char *) } 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]; @@ -2924,7 +2924,7 @@ static void ZOOM_scanset_term_x(ZOOM_scanset scan, size_t pos, *disp_len = 0; *occ = 0; - if (pos >= noent || pos < 0) + if (pos >= noent) return; if (scan->scan_response) { diff --git a/test/tsticonv.c b/test/tsticonv.c index feb8868..352033a 100644 --- a/test/tsticonv.c +++ b/test/tsticonv.c @@ -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; - 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; diff --git a/test/tstnmem.c b/test/tstnmem.c index 7267744..80a2e56 100644 --- a/test/tstnmem.c +++ b/test/tstnmem.c @@ -28,13 +28,13 @@ void tst(void) { 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 - if (sizeof(long long) >= j) + if ((int) sizeof(long long) >= j) *(long long*) cp = 123L; #endif - if (sizeof(double) >= j) + if ((int) sizeof(double) >= j) *(double*) cp = 12.2; } diff --git a/test/tstodr.c b/test/tstodr.c index 56b7bb0..83d2d2c 100644 --- a/test/tstodr.c +++ b/test/tstodr.c @@ -105,13 +105,13 @@ void tst_MySequence3(ODR encode, ODR decode) Yc_MySequence *t; srand(123); - for (i = 0; i<1000; i++) + for (i = 0; i < 1000; i++) { int j; - for (j = 0; jterm->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';