aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib/param
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-28 21:52:26 -0700
committerpx4dev <px4@purgatory.org>2012-08-28 21:52:26 -0700
commitf0286d1a10343c573fac6382e3c2cb0b714a1f72 (patch)
tree3cd5c6b02eb1eaf45de99be76c9a28af78bf0336 /apps/systemlib/param
parent952f862dad7b3105ed6ad37f4836effe71938b91 (diff)
downloadpx4-firmware-f0286d1a10343c573fac6382e3c2cb0b714a1f72.tar.gz
px4-firmware-f0286d1a10343c573fac6382e3c2cb0b714a1f72.tar.bz2
px4-firmware-f0286d1a10343c573fac6382e3c2cb0b714a1f72.zip
Distinguish between the end of the top-level BSON object and an error so that parameter loading can complete.
Diffstat (limited to 'apps/systemlib/param')
-rw-r--r--apps/systemlib/param/param.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/systemlib/param/param.c b/apps/systemlib/param/param.c
index 9391558e9..b69efb77c 100644
--- a/apps/systemlib/param/param.c
+++ b/apps/systemlib/param/param.c
@@ -479,14 +479,14 @@ param_export(int fd, bool only_unsaved)
}
}
- if (bson_encoder_fini(&encoder))
- goto out;
-
result = 0;
out:
param_unlock();
+ if (result == 0)
+ result = bson_encoder_fini(&encoder);
+
return result;
}
@@ -499,7 +499,8 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
int result = -1;
/*
- * EOO means the end of the parameter object.
+ * EOO means the end of the parameter object. (Currently not supporting
+ * nested BSON objects).
*/
if (node->type == BSON_EOO) {
*(bool *)private = true;
@@ -513,8 +514,10 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
*/
param_t param = param_find(node->name);
- if (param == PARAM_INVALID)
- return 0;
+ if (param == PARAM_INVALID) {
+ debug("ignoring unrecognised parameter '%s'", node->name);
+ return 1;
+ }
/*
* Handle setting the parameter from the node
@@ -583,7 +586,8 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
tmp = NULL;
}
- result = 0;
+ /* don't return zero, that means EOF */
+ result = 1;
out:
@@ -607,16 +611,14 @@ param_import(int fd)
done = false;
- while (!done) {
+ do {
result = bson_decoder_next(&decoder);
- if (result != 0) {
- debug("error during BSON decode");
- break;
- }
- }
+ } while(result > 0);
out:
+ if (result < 0)
+ debug("BSON error decoding parameters");
return result;
}