Fix some compiler warnings
The descriptor strings are dynamically allocated and owned by the struct. The const qualifiers are a bit misleading here, and result in warnings when trying to free the pointers again.
This commit is contained in:
parent
ea2272d4b0
commit
96bac1de13
@ -64,7 +64,7 @@ enum eon_sample {
|
|||||||
#define EON_MAX_GROUP 16
|
#define EON_MAX_GROUP 16
|
||||||
|
|
||||||
struct type_desc {
|
struct type_desc {
|
||||||
const char *desc, *format, *mod;
|
char *desc, *format, *mod;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
enum eon_sample type[EON_MAX_GROUP];
|
enum eon_sample type[EON_MAX_GROUP];
|
||||||
};
|
};
|
||||||
@ -290,9 +290,9 @@ static void
|
|||||||
desc_free (struct type_desc desc[], unsigned int count)
|
desc_free (struct type_desc desc[], unsigned int count)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < count; ++i) {
|
for (unsigned int i = 0; i < count; ++i) {
|
||||||
free((void *)desc[i].desc);
|
free(desc[i].desc);
|
||||||
free((void *)desc[i].format);
|
free(desc[i].format);
|
||||||
free((void *)desc[i].mod);
|
free(desc[i].mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,8 +463,8 @@ struct sample_data {
|
|||||||
dc_sample_callback_t callback;
|
dc_sample_callback_t callback;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
unsigned int time;
|
unsigned int time;
|
||||||
const char *state_type, *notify_type;
|
char *state_type, *notify_type;
|
||||||
const char *warning_type, *alarm_type;
|
char *warning_type, *alarm_type;
|
||||||
|
|
||||||
/* We gather up deco and cylinder pressure information */
|
/* We gather up deco and cylinder pressure information */
|
||||||
int gasnr;
|
int gasnr;
|
||||||
@ -613,7 +613,7 @@ static void sample_gas_switch_event(struct sample_data *info, unsigned short idx
|
|||||||
*
|
*
|
||||||
* "enum:0=NoFly Time,1=Depth,2=Surface Time,3=..."
|
* "enum:0=NoFly Time,1=Depth,2=Surface Time,3=..."
|
||||||
*/
|
*/
|
||||||
static const char *lookup_enum(const struct type_desc *desc, unsigned char value)
|
static char *lookup_enum(const struct type_desc *desc, unsigned char value)
|
||||||
{
|
{
|
||||||
const char *str = desc->format;
|
const char *str = desc->format;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -819,7 +819,7 @@ static void sample_event_alarm_value(const struct type_desc *desc, struct sample
|
|||||||
static void sample_setpoint_type(const struct type_desc *desc, struct sample_data *info, unsigned char value)
|
static void sample_setpoint_type(const struct type_desc *desc, struct sample_data *info, unsigned char value)
|
||||||
{
|
{
|
||||||
dc_sample_value_t sample = {0};
|
dc_sample_value_t sample = {0};
|
||||||
const char *type = lookup_enum(desc, value);
|
char *type = lookup_enum(desc, value);
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
DEBUG(info->eon->base.context, "sample_setpoint_type(%u) did not match anything in %s", value, desc->format);
|
DEBUG(info->eon->base.context, "sample_setpoint_type(%u) did not match anything in %s", value, desc->format);
|
||||||
@ -834,12 +834,12 @@ static void sample_setpoint_type(const struct type_desc *desc, struct sample_dat
|
|||||||
sample.ppo2 = info->eon->cache.customsetpoint;
|
sample.ppo2 = info->eon->cache.customsetpoint;
|
||||||
else {
|
else {
|
||||||
DEBUG(info->eon->base.context, "sample_setpoint_type(%u) unknown type '%s'", value, type);
|
DEBUG(info->eon->base.context, "sample_setpoint_type(%u) unknown type '%s'", value, type);
|
||||||
free((void *)type);
|
free(type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->callback) info->callback(DC_SAMPLE_SETPOINT, sample, info->userdata);
|
if (info->callback) info->callback(DC_SAMPLE_SETPOINT, sample, info->userdata);
|
||||||
free((void *)type);
|
free(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// uint32
|
// uint32
|
||||||
@ -1148,7 +1148,7 @@ static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *d
|
|||||||
{
|
{
|
||||||
int idx = eon->cache.ngases;
|
int idx = eon->cache.ngases;
|
||||||
dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC;
|
dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC;
|
||||||
const char *name;
|
char *name;
|
||||||
|
|
||||||
if (idx >= MAXGASES)
|
if (idx >= MAXGASES)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1170,7 +1170,7 @@ static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *d
|
|||||||
|
|
||||||
eon->cache.initialized |= 1 << DC_FIELD_GASMIX_COUNT;
|
eon->cache.initialized |= 1 << DC_FIELD_GASMIX_COUNT;
|
||||||
eon->cache.initialized |= 1 << DC_FIELD_TANK_COUNT;
|
eon->cache.initialized |= 1 << DC_FIELD_TANK_COUNT;
|
||||||
free((void *)name);
|
free(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user