From f962e9826b099d49a1c22fee0abc74abccea0ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 10 Jan 2018 20:40:58 +0100 Subject: [PATCH] param_export: reduce bson buffer size from 512 to 256 Some modules call this (and maybe in rare circumstances), which could lead to stack overflows. With our current headroom of >= 300bytes, 256 should be ok. This increases the export time from ~28ms to ~34ms in my case (on a Pixracer) --- src/modules/systemlib/param/param.c | 2 +- src/modules/systemlib/param/param.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index 19577ecf3c..53e08ad74d 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -1048,7 +1048,7 @@ param_export(int fd, bool only_unsaved) param_lock_reader(); - uint8_t bson_buffer[512]; + uint8_t bson_buffer[256]; bson_encoder_init_buf(&encoder, &bson_buffer, sizeof(bson_buffer)); /* no modified parameters -> we are done */ diff --git a/src/modules/systemlib/param/param.h b/src/modules/systemlib/param/param.h index 7a1cdf703f..4bcf1bceb4 100644 --- a/src/modules/systemlib/param/param.h +++ b/src/modules/systemlib/param/param.h @@ -299,6 +299,7 @@ __EXPORT void param_reset_excludes(const char *excludes[], int num_excludes); /** * Export changed parameters to a file. + * Note: this method requires a large amount of stack size! * * @param fd File descriptor to export to. * @param only_unsaved Only export changed parameters that have not yet been exported. @@ -365,6 +366,7 @@ __EXPORT const char *param_get_default_file(void); /** * Save parameters to the default file. + * Note: this method requires a large amount of stack size! * * This function saves all parameters with non-default values. *