parameters: delete unused BSON_BINDATA handling

This commit is contained in:
Daniel Agar
2021-03-09 13:03:59 -05:00
parent 4d288512b5
commit 684424bf73
3 changed files with 1 additions and 137 deletions
+1 -41
View File
@@ -207,7 +207,7 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
{
float f;
int32_t i;
void *v, *tmp = nullptr;
void *v = nullptr;
int result = -1;
struct param_import_state *state = (struct param_import_state *)priv;
@@ -260,60 +260,20 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
v = &f;
break;
case BSON_BINDATA:
if (node->subtype != BSON_BIN_BINARY) {
PX4_WARN("unexpected type for %s", node->name);
result = 1; // just skip this entry
goto out;
}
if (bson_decoder_data_pending(decoder) != param_size(param)) {
PX4_WARN("bad size for '%s'", node->name);
result = 1; // just skip this entry
goto out;
}
/* XXX check actual file data size? */
tmp = malloc(param_size(param));
if (tmp == nullptr) {
debug("failed allocating for '%s'", node->name);
goto out;
}
if (bson_decoder_copy_data(decoder, tmp)) {
debug("failed copying data for '%s'", node->name);
goto out;
}
v = tmp;
break;
default:
debug("unrecognised node type");
goto out;
}
if (param_set_external(param, v, state->mark_saved, true)) {
debug("error setting value for '%s'", node->name);
goto out;
}
if (tmp != nullptr) {
free(tmp);
tmp = nullptr;
}
/* don't return zero, that means EOF */
result = 1;
out:
if (tmp != nullptr) {
free(tmp);
}
return result;
}
-48
View File
@@ -1290,7 +1290,6 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
{
float f = 0.0f;
int32_t i = 0;
void *tmp = nullptr;
void *v = nullptr;
int result = -1;
param_import_state *state = (param_import_state *)priv;
@@ -1350,43 +1349,6 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
}
break;
case BSON_BINDATA: {
if (node->subtype != BSON_BIN_BINARY) {
PX4_WARN("unexpected subtype for %s", node->name);
result = 1; // just skip this entry
goto out;
}
if (bson_decoder_data_pending(decoder) != param_size(param)) {
PX4_WARN("bad size for '%s'", node->name);
result = 1; // just skip this entry
goto out;
}
/* XXX check actual file data size? */
size_t psize = param_size(param);
if (psize > 0) {
tmp = malloc(psize);
} else {
tmp = nullptr;
}
if (tmp == nullptr) {
PX4_ERR("failed allocating for '%s'", node->name);
goto out;
}
if (bson_decoder_copy_data(decoder, tmp)) {
PX4_ERR("failed copying data for '%s'", node->name);
goto out;
}
v = tmp;
}
break;
default:
PX4_DEBUG("unrecognised node type");
goto out;
@@ -1397,20 +1359,10 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
goto out;
}
if (tmp != nullptr) {
free(tmp);
tmp = nullptr;
}
/* don't return zero, that means EOF */
result = 1;
out:
if (tmp != nullptr) {
free(tmp);
}
return result;
}
-48
View File
@@ -1205,7 +1205,6 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
{
float f = 0.0f;
int32_t i = 0;
void *tmp = nullptr;
void *v = nullptr;
int result = -1;
param_import_state *state = (param_import_state *)priv;
@@ -1263,43 +1262,6 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
}
break;
case BSON_BINDATA: {
if (node->subtype != BSON_BIN_BINARY) {
PX4_WARN("unexpected subtype for %s", node->name);
result = 1; // just skip this entry
goto out;
}
if (bson_decoder_data_pending(decoder) != param_size(param)) {
PX4_WARN("bad size for '%s'", node->name);
result = 1; // just skip this entry
goto out;
}
/* XXX check actual file data size? */
size_t psize = param_size(param);
if (psize > 0) {
tmp = malloc(psize);
} else {
tmp = nullptr;
}
if (tmp == nullptr) {
PX4_ERR("failed allocating for '%s'", node->name);
goto out;
}
if (bson_decoder_copy_data(decoder, tmp)) {
PX4_ERR("failed copying data for '%s'", node->name);
goto out;
}
v = tmp;
}
break;
default:
PX4_DEBUG("unrecognised node type");
goto out;
@@ -1310,20 +1272,10 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
goto out;
}
if (tmp != nullptr) {
free(tmp);
tmp = nullptr;
}
/* don't return zero, that means EOF */
result = 1;
out:
if (tmp != nullptr) {
free(tmp);
}
return result;
}