Add explicit casts for the msvc C++ compiler.

This commit is contained in:
Jef Driesen 2014-11-10 21:07:14 +01:00
parent f228a5f9fc
commit dbcaa6946a
2 changed files with 10 additions and 10 deletions

View File

@ -96,7 +96,7 @@ static struct directory_entry *alloc_dirent(int type, int len, const char *name)
{ {
struct directory_entry *res; struct directory_entry *res;
res = malloc(offsetof(struct directory_entry, name) + len + 1); res = (struct directory_entry *) malloc(offsetof(struct directory_entry, name) + len + 1);
if (res) { if (res) {
res->next = NULL; res->next = NULL;
res->type = type; res->type = type;
@ -378,7 +378,7 @@ static struct directory_entry *parse_dirent(suunto_eonsteel_device_t *eon, int n
p += 8 + namelen + 1; p += 8 + namelen + 1;
len -= 8 + namelen + 1; len -= 8 + namelen + 1;
entry = alloc_dirent(type, namelen, name); entry = alloc_dirent(type, namelen, (const char *) name);
entry->next = old; entry->next = old;
old = entry; old = entry;
} }
@ -480,7 +480,7 @@ suunto_eonsteel_device_open(dc_device_t **out, dc_context_t *context, const char
if (out == NULL) if (out == NULL)
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
eon = calloc(1, sizeof(suunto_eonsteel_device_t)); eon = (suunto_eonsteel_device_t *) calloc(1, sizeof(suunto_eonsteel_device_t));
if (!eon) if (!eon)
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;

View File

@ -75,7 +75,7 @@ static int record_type(suunto_eonsteel_parser_t *eon, unsigned short type, const
ERROR(eon->base.context, "Unexpected type description: %.*s", len, name); ERROR(eon->base.context, "Unexpected type description: %.*s", len, name);
return -1; return -1;
} }
p = malloc(len-4); p = (char *) malloc(len-4);
if (!p) { if (!p) {
ERROR(eon->base.context, "out of memory"); ERROR(eon->base.context, "out of memory");
return -1; return -1;
@ -141,7 +141,7 @@ static int traverse_entry(suunto_eonsteel_parser_t *eon, const unsigned char *p,
return -1; return -1;
} }
record_type(eon, type, name, textlen-3); record_type(eon, type, (const char *) name, textlen-3);
end = data; end = data;
last = data; last = data;
@ -273,7 +273,7 @@ static void sample_cylinder_pressure(struct sample_data *info, unsigned char idx
static int traverse_samples(unsigned short type, const struct type_desc *desc, const unsigned char *data, int len, void *user) static int traverse_samples(unsigned short type, const struct type_desc *desc, const unsigned char *data, int len, void *user)
{ {
struct sample_data *info = user; struct sample_data *info = (struct sample_data *) user;
switch (type) { switch (type) {
case 0x0001: // group: time in first word, depth in second case 0x0001: // group: time in first word, depth in second
@ -298,7 +298,7 @@ static int traverse_samples(unsigned short type, const struct type_desc *desc, c
static dc_status_t static dc_status_t
suunto_eonsteel_parser_samples_foreach(dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata) suunto_eonsteel_parser_samples_foreach(dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata)
{ {
suunto_eonsteel_parser_t *eon = (void *)abstract; suunto_eonsteel_parser_t *eon = (suunto_eonsteel_parser_t *) abstract;
struct sample_data data = { eon, callback, userdata, 0 }; struct sample_data data = { eon, callback, userdata, 0 };
traverse_data(eon, traverse_samples, &data); traverse_data(eon, traverse_samples, &data);
@ -406,7 +406,7 @@ static void add_gas_he(suunto_eonsteel_parser_t *eon, unsigned char he)
static int traverse_fields(unsigned short type, const struct type_desc *desc, const unsigned char *data, int len, void *user) static int traverse_fields(unsigned short type, const struct type_desc *desc, const unsigned char *data, int len, void *user)
{ {
suunto_eonsteel_parser_t *eon = user; suunto_eonsteel_parser_t *eon = (suunto_eonsteel_parser_t *) user;
switch (type) { switch (type) {
case 0x0001: // group: time in first word, depth in second case 0x0001: // group: time in first word, depth in second
@ -448,7 +448,7 @@ static void initialize_field_caches(suunto_eonsteel_parser_t *eon)
static dc_status_t static dc_status_t
suunto_eonsteel_parser_set_data(dc_parser_t *parser, const unsigned char *data, unsigned int size) suunto_eonsteel_parser_set_data(dc_parser_t *parser, const unsigned char *data, unsigned int size)
{ {
suunto_eonsteel_parser_t *eon = (void *)parser; suunto_eonsteel_parser_t *eon = (suunto_eonsteel_parser_t *) parser;
memset(eon->type_desc, 0, sizeof(eon->type_desc)); memset(eon->type_desc, 0, sizeof(eon->type_desc));
initialize_field_caches(eon); initialize_field_caches(eon);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
@ -478,7 +478,7 @@ suunto_eonsteel_parser_create(dc_parser_t **out, dc_context_t *context, unsigned
if (out == NULL) if (out == NULL)
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
eon = calloc(1, sizeof(*eon)); eon = (suunto_eonsteel_parser_t *) calloc(1, sizeof(*eon));
parser_init(&eon->base, context, &suunto_eonsteel_parser_vtable); parser_init(&eon->base, context, &suunto_eonsteel_parser_vtable);