From bb948dc12e1bdefa5d82c1796eff90c06baca42e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Thu, 28 May 2015 14:59:08 +0200 Subject: [PATCH] Add explicit casts to silence compiler warnings clang complais when converting (char *) to (unsigned char *), so tell it it's fine. Signed-off-by: Robert C. Helling --- cochran.c | 4 ++-- libdivecomputer.c | 2 +- ostctools.c | 6 +++--- parse-xml.c | 18 +++++++++--------- planner.c | 4 ++-- uemis.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cochran.c b/cochran.c index fe65ee2..267fe2b 100644 --- a/cochran.c +++ b/cochran.c @@ -200,7 +200,7 @@ static void cochran_parse_header(const unsigned char *decode, unsigned mod, /* Do the "null decode" using a one-byte decode array of '\0' */ /* Copies in plaintext, will be overwritten later */ - partial_decode(0, 0x0102, "", 0, 1, in, size, buf); + partial_decode(0, 0x0102, (const unsigned char *)"", 0, 1, in, size, buf); /* * The header scrambling is different form the dive @@ -778,7 +778,7 @@ int try_to_open_cochran(const char *filename, struct memblock *mem) if (mem->size < 0x40000) return 0; - offsets = (int *) mem->buffer; + offsets = (unsigned int *) mem->buffer; dive1 = offsets[0]; dive2 = offsets[1]; diff --git a/libdivecomputer.c b/libdivecomputer.c index f07023f..ccf0255 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -409,7 +409,7 @@ static uint32_t calculate_diveid(const unsigned char *fingerprint, unsigned int #ifdef DC_FIELD_STRING static uint32_t calculate_string_hash(const char *str) { - return calculate_diveid(str, strlen(str)); + return calculate_diveid((const unsigned char *)str, strlen(str)); } static void parse_string_field(struct dive *dive, dc_field_string_t *str) diff --git a/ostctools.c b/ostctools.c index 68b7da0..9e72453 100644 --- a/ostctools.c +++ b/ostctools.c @@ -67,8 +67,8 @@ void ostctools_import(const char *file, struct dive_table *divetable) FILE *archive; device_data_t *devdata = calloc(1, sizeof(device_data_t)); dc_family_t dc_fam; - unsigned char *buffer = calloc(65536, 1), - *tmp; + unsigned char *buffer = calloc(65536, 1); + char *tmp; struct dive *ostcdive = alloc_dive(); dc_status_t rc = 0; int model = 0, i = 0; @@ -125,7 +125,7 @@ void ostctools_import(const char *file, struct dive_table *divetable) // a model number so will use 0. ostc_prepare_data(model, dc_fam, devdata); tmp = calloc(strlen(devdata->vendor)+strlen(devdata->model)+28,1); - sprintf(tmp,"%s %s (Imported from OSTCTools)", devdata->vendor, devdata->model); + sprintf(tmp, "%s %s (Imported from OSTCTools)", devdata->vendor, devdata->model); ostcdive->dc.model = copy_string(tmp); free(tmp); diff --git a/parse-xml.c b/parse-xml.c index 51d23ec..c3da4fa 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1736,14 +1736,14 @@ static const char *nodename(xmlNode *node, char *buf, int len) return "root"; } - if (node->type == XML_CDATA_SECTION_NODE || (node->parent && !strcmp(node->name, "text"))) + if (node->type == XML_CDATA_SECTION_NODE || (node->parent && !strcmp((const char *)node->name, "text"))) node = node->parent; /* Make sure it's always NUL-terminated */ p[--len] = 0; for (;;) { - const char *name = node->name; + const char *name = (const char *)node->name; char c; while ((c = *name++) != 0) { /* Cheaper 'tolower()' for ASCII */ @@ -1768,7 +1768,7 @@ static const char *nodename(xmlNode *node, char *buf, int len) static bool visit_one_node(xmlNode *node) { - char *content; + xmlChar *content; static char buffer[MAXNAME]; const char *name; @@ -1778,7 +1778,7 @@ static bool visit_one_node(xmlNode *node) name = nodename(node, buffer, sizeof(buffer)); - return entry(name, content); + return entry(name, (char *)content); } static bool traverse(xmlNode *root); @@ -1874,7 +1874,7 @@ static bool traverse(xmlNode *root) } do { - if (!strcmp(rule->name, n->name)) + if (!strcmp(rule->name, (const char *)n->name)) break; rule++; } while (rule->name); @@ -1921,7 +1921,7 @@ const char *preprocess_divelog_de(const char *buffer) return buffer; ctx = xmlCreateMemoryParserCtxt(buf, sizeof(buf)); - ret = xmlStringLenDecodeEntities(ctx, ret, strlen(ret), XML_SUBSTITUTE_REF, 0, 0, 0); + ret = (char *)xmlStringLenDecodeEntities(ctx, (xmlChar *)ret, strlen(ret), XML_SUBSTITUTE_REF, 0, 0, 0); return ret; } @@ -3138,17 +3138,17 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params) char *attribute; while (info->root) { - if ((strcasecmp(root_element->name, info->root) == 0)) { + if ((strcasecmp((const char *)root_element->name, info->root) == 0)) { if (info->attribute == NULL) break; - else if (xmlGetProp(root_element, info->attribute) != NULL) + else if (xmlGetProp(root_element, (const xmlChar *)info->attribute) != NULL) break; } info++; } if (info->root) { - attribute = xmlGetProp(xmlFirstElementChild(root_element), "name"); + attribute = (char *)xmlGetProp(xmlFirstElementChild(root_element), (const xmlChar *)"name"); if (attribute) { if (strcasecmp(attribute, "subsurface") == 0) { free((void *)attribute); diff --git a/planner.c b/planner.c index 3c9b9df..ad855e6 100644 --- a/planner.c +++ b/planner.c @@ -470,7 +470,7 @@ static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, { int i, gi, di; int total = dnr + gnr; - int *stoplevels = malloc(total * sizeof(int)); + unsigned int *stoplevels = malloc(total * sizeof(int)); /* no gaschanges */ if (gnr == 0) { @@ -866,7 +866,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool double tissue_tolerance = 0.0; struct gaschanges *gaschanges = NULL; int gaschangenr; - int *stoplevels = NULL; + unsigned int *stoplevels = NULL; bool stopping = false; bool clear_to_ascend; int clock, previous_point_time; diff --git a/uemis.c b/uemis.c index b2eda8f..e60e94a 100644 --- a/uemis.c +++ b/uemis.c @@ -90,7 +90,7 @@ static int uemis_convert_base64(char *base64, uint8_t **data) fprintf(stderr, "Out of memory\n"); goto bail; } - decode(base64, *data, len); + decode((unsigned char *)base64, *data, len); if (memcmp(*data, "Dive\01\00\00", 7)) fprintf(stderr, "Missing Dive100 header\n"); -- 1.9.5 (Apple Git-50.3)